Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

CSS language specific styling (lang-undefined). Kludge.

1717062174

Edited 1717062232
nPocTo_4eJI
API Scripter
<a href="https://app.roll20.net/forum/post/11002727/language-specific-styling/?pageforid=11002727#post-11002727" rel="nofollow">https://app.roll20.net/forum/post/11002727/language-specific-styling/?pageforid=11002727#post-11002727</a> translation.json: { &nbsp; &nbsp; "LanguageCode" : "ru" , //the one you need &nbsp;&nbsp;&nbsp;&nbsp;... } HTML: &lt; script type = "text/worker" &gt; &nbsp; &nbsp; on ( 'sheet:opened' , function () { $20 ( '.charsheet.lang-undefined' ). addClass ( `lang- ${ getTranslationByKey ( "LanguageCode" ) } ` ) }); &nbsp;&nbsp;&nbsp;&nbsp;... &lt;/ script &gt; CSS: Styles for ".charsheet.lang-[ 2 char language code ]" that you need.
1717063084
vÍnce
Pro
Sheet Author
AFAIK, this is still broken.
Refresh the page after adding new values ​​to translation.json, otherwise getTranslationByKey won't see them.
1717081903
vÍnce
Pro
Sheet Author
Sorry, yes refresh works. +1 I focused in on the "lang-undefined" which has been a long standing bug for serving up language-specific css/html.&nbsp; Particularly a image based on someone's language.
vÍnce said: Sorry, yes refresh works. +1 I focused in on the "lang-undefined" which has been a long standing bug for serving up language-specific css/html.&nbsp; Particularly a image based on someone's language. You can add "removeClass" so that "lang-undefined" doesn't bother you. on('sheet:opened', function() {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; $20('.charsheet.lang-undefined').addClass(`lang-${getTranslationByKey("LanguageCode")}`) &nbsp;&nbsp;&nbsp;&nbsp; $20('.charsheet.lang-undefined').removeClass("lang-undefined") });
1717083549
vÍnce
Pro
Sheet Author
I might have to try that.&nbsp; Makes me feel like a hacker.&nbsp; Lol
1717169416
GiGs
Pro
Sheet Author
API Scripter
What does this affect?
GiGs said: What does this affect? The mechanics that, depending on the player's language settings, should assign a "charsheet" to a certain class are not working right now. This kludge fixes the problem by assigning the class manually.
1717228412
vÍnce
Pro
Sheet Author
<a href="https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks" rel="nofollow">https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks</a> I had some code that would change the sheet's logo displayed depending on the user's language.&nbsp; I never could get it to work though.&nbsp; I attributed it to the fact that "lang-undefined" seems to be ever-present regardless of the user's language.&nbsp; I submitted a bug report in 2021 [#69268] .
vÍnce said: <a href="https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks" rel="nofollow">https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks</a> I had some code that would change the sheet's logo displayed depending on the user's language.&nbsp; I never could get it to work though.&nbsp; I attributed it to the fact that "lang-undefined" seems to be ever-present regardless of the user's language.&nbsp; I submitted a bug report in 2021 [#69268] . Displaying different elements from the presence of a “class” is only a matter of CSS, Roll20 does not affect this in any way. Roll20 only emits the required class depending on the user's settings (which doesn't work now) and changes the translation.json used (which does work). This kludge&nbsp; does roll20's job for it, referencing the translation.json used. In other words, everything should now work.
1717271588
vÍnce
Pro
Sheet Author
Thanks nPocTo_4eJI.&nbsp; I'll have to retry my image swap code for the Forbidden Lands sheet.
You're welcome.
1717935458
Andreas J.
Forum Champion
Sheet Author
Translator
vÍnce said: Thanks nPocTo_4eJI.&nbsp; I'll have to retry my image swap code for the Forbidden Lands sheet. Wait, so might this have been fixed?