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.

May 30 (1 year ago)

Edited May 30 (1 year ago)
nPocTo_4eJI
API Scripter

https://app.roll20.net/forum/post/11002727/language-specific-styling/?pageforid=11002727#post-11002727

translation.json:

{
    "LanguageCode": "ru", //the one you need
    ...
}

HTML:

<script type="text/worker">
    on('sheet:opened', function() { $20('.charsheet.lang-undefined').addClass(`lang-${getTranslationByKey("LanguageCode")}`) });
    ...
</script>

CSS:
Styles for ".charsheet.lang-[2 char language code]" that you need.


May 30 (1 year ago)
vÍnce
Pro
Sheet Author

AFAIK, this is still broken.

May 30 (1 year ago)
nPocTo_4eJI
API Scripter

Refresh the page after adding new values ​​to translation.json, otherwise getTranslationByKey won't see them.

May 30 (1 year ago)
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.  Particularly a image based on someone's language.

May 30 (1 year ago)
nPocTo_4eJI
API Scripter

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.  Particularly a image based on someone's language.

You can add "removeClass" so that "lang-undefined" doesn't bother you.

on('sheet:opened', function() { 
    $20('.charsheet.lang-undefined').addClass(`lang-${getTranslationByKey("LanguageCode")}`)
    $20('.charsheet.lang-undefined').removeClass("lang-undefined")
});
May 30 (1 year ago)
vÍnce
Pro
Sheet Author

I might have to try that.  Makes me feel like a hacker.  Lol

May 31 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

What does this affect?

May 31 (1 year ago)
nPocTo_4eJI
API Scripter

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.

June 01 (1 year ago)
vÍnce
Pro
Sheet Author

https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks

I had some code that would change the sheet's logo displayed depending on the user's language.  I never could get it to work though.  I attributed it to the fact that "lang-undefined" seems to be ever-present regardless of the user's language.  I submitted a bug report in 2021 [#69268] .

June 01 (1 year ago)
nPocTo_4eJI
API Scripter

vÍnce said:

https://wiki.roll20.net/Character_Sheet_Translation#Changing_Language-Specific_Looks

I had some code that would change the sheet's logo displayed depending on the user's language.  I never could get it to work though.  I attributed it to the fact that "lang-undefined" seems to be ever-present regardless of the user's language.  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 does roll20's job for it, referencing the translation.json used.


In other words, everything should now work.

June 01 (1 year ago)
vÍnce
Pro
Sheet Author

Thanks nPocTo_4eJI.  I'll have to retry my image swap code for the Forbidden Lands sheet.

June 01 (1 year ago)
nPocTo_4eJI
API Scripter

You're welcome.

June 09 (1 year ago)
Andreas J.
Forum Champion
Sheet Author
Translator


vÍnce said:

Thanks nPocTo_4eJI.  I'll have to retry my image swap code for the Forbidden Lands sheet.


Wait, so might this have been fixed?