Page 1 of 1

CSS Language must be in dictionary

PostPosted: Fri Apr 06, 2012 3:09 pm
by dagaben
Hi
I want to style Chinese characters to display bigger and in the font I chose. So I followed the instructions here and added this to article-style.css

Code: Select all
:lang(zh)
{
  font-family: "AR PL UMing HK";
  font-size: 48px;
}


It doesn't work, and it seems the language must be set by the dictionary itself. I'm using stardict dictionaries.
Here's the body of a saved article, for the word 'zhongshang'.

Code: Select all
<title>中上</title><script language="JavaScript">function gdMakeArticleActive( newId ) {if ( gdCurrentArticle != 'gdfrom-' + newId ) {document.getElementById( gdCurrentArticle ).className = 'gdarticle';document.getElementById( 'gdfrom-' + newId ).className = 'gdarticle gdactivearticle';gdCurrentArticle = 'gdfrom-' + newId; eval( 'gdActivateAudioLink_' + newId + '();' ); } }</script></head><body><script language="JavaScript">var gdCurrentArticle="gdfrom-ddd286c5b207444bcc9969f3c5dfe86c";</script><script language="JavaScript">var gdArticleContents; if ( !gdArticleContents ) gdArticleContents = "ddd286c5b207444bcc9969f3c5dfe86c "; else gdArticleContents += "ddd286c5b207444bcc9969f3c5dfe86c ";</script><span class="gdarticle gdactivearticle" id="gdfrom-ddd286c5b207444bcc9969f3c5dfe86c" onclick="gdMakeArticleActive( 'ddd286c5b207444bcc9969f3c5dfe86c' );" oncontextmenu="gdMakeArticleActive( 'ddd286c5b207444bcc9969f3c5dfe86c' );"><div class="gddictname"><span class="gdfromprefix">From </span>Hanzi Master 1.3</div><span class="gdarticlebody gdlangfrom-" lang=""><h3>中上</h3><div class="sdct_m">zhongshang [4]</div></span></span></body>


As you can see the lang property is empty and the gdlangfrom class is incomplete.
Setting the same font for the entire article won't do. What can I do with the dictionary to make it display as I want it. Do I need to convert it to another dictionary format?

Thanks
D

Re: CSS Language must be in dictionary

PostPosted: Fri Apr 06, 2012 3:59 pm
by chulai
You can follow the instructions here: viewtopic.php?f=4&t=1632#p7243
These ids might change if you move GoldenDict or the dictionaries to a different folder. But other than that they are fixed.

On the other hand, GoldenDict looks for the source and target languages on the dict filename. It uses the format sourceLang-TargetLang. Examples:
MyDictionary (en-en).dict
MyDictionary [en-en].dict
MyDictionary [eng-eng].dict

If it can't find the language info in the dict filename then it follow the same procedure but by looking to the bookname property which is inside the *.ifo file.

If you rename the *.dict filename or change the *.ifo file remember to rescan the files for GoldenDict to take the changes.

Re: CSS Language must be in dictionary

PostPosted: Fri Apr 06, 2012 5:20 pm
by dagaben
Thanks so much. I took the option of renaming the bookname property.
Its not good style to mix style with content but I'm sure you know that. A solution based on the group the dictionary sits in would be better.

My articles-style.css looks like this:
Code: Select all
body
{
  background: Ivory;
  font-size: 16px;
}

:lang(bo)
{
  font-family: "Jomolhari";
  font-size: 36px;
  font-weight: normal;
}

:lang(zh)
{
  font-family: "AR PL UMing HK";
  font-size: 28px;
  font-weight: normal;
}

span.gdlangfrom-bo h3{
  font-family: "Jomolhari";
  font-size: 36px;
  font-weight: normal;
}

span.gdlangfrom-zh h3{
  font-family: "AR PL UMing HK";
  font-size: 28px;
  font-weight: normal;
}


qt-style.css:
Code: Select all
MainWindow #searchPane #translateLine[currentGroup="Tibetan"], MainWindow #searchPane #wordList[currentGroup="Tibetan"]
{
  background: white;
  color: black;
  font-family: "Jomolhari";
  font-size: 36px;
  font-weight: normal;
}

MainWindow #searchPane #translateLine[currentGroup="Chinese"], MainWindow #searchPane #wordList[currentGroup="Chinese"]
{
  background: white;
  color: black;
  font-family: "AR PL UMing HK";
  font-size: 28px;
  font-weight: normal;
}

Re: CSS Language must be in dictionary

PostPosted: Tue Aug 10, 2021 12:11 am
by steveja
chulai wrote:You can follow the instructions here: viewtopic.php?f=4&t=1632#p7243
These ids might change if you move GoldenDict or the dictionaries to a different folder. But other than that they are fixed.

On the other hand, GoldenDict looks for the source and target languages on the dict filename. It uses the format sourceLang-TargetLang. Examples:
MyDictionary (en-en).dict
MyDictionary [en-en].dict
MyDictionary [eng-eng].dict

If it can't find the language info in the dict filename then it follow the same procedure but by looking to the bookname property which is inside the *.ifo file.

If you rename the *.dict filename or change the *.ifo file remember to rescan the files for GoldenDict to take the changes.


How do you specify spanish as the language of the dictionary? For a spanish to english dictionary I've tried the following in the bookname but the spanish part is not recognized:
(sp-en) (spa-en) (spanish-en) (es-en) (esp-en)