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

Translate text that originates from sheetworker

1554244568
vÍnce
Pro
Sheet Author
I've created a new problem for myself... I have a sheetworker that sets the text for a hidden attribute " current_preset" .  On the sheet I display the text as a named span. <span name=" attr_current_preset " data-i18n-dynamic ></span>   I also include the attribute in sheet rolls which are displayed using a roll template. {{subtitle=^{ @{current_preset} }}} How do I add localization code for the text displayed, both on the sheet and as it's displayed with a sheet roll/roll template? here's some sample code I'm working with sheetworker /* set armor dice pool */ on("clicked:armor-roll", function() { console.log(">>> Change Detected: Armor - button clicked <<<"); getAttrs(["ar"], function(values) { const ar = parseInt(values.ar,10)||0; setAttrs({ gear: ar, current_preset : `Armor Roll`, include_with_roll: "" }); }); }); html (I thought to try  data-i18n-dynamic  on the span, but I have a feeling this only works for a referenced select attribute...? ) <span class="sheet-label" data-i18n="current-preset" >Current Preset</span> <input class="sheet-input" type="hidden" name=" attr_current_preset " value="" readonly /> <span name=" attr_current_preset " data-i18n-dynamic ></span> example sheet roll (notice I'm trying to use ^{foo} to get a translation) <button class="dice-pool" type="roll" name="roll_the_dice" value="&{template:forbiddenlands} {{subtitle=^{ @{current_preset} }}}"></button> Thanks
1554259160
Finderski
Pro
Sheet Author
Compendium Curator
You want to use getTranslationByKey.  Here's an example of how to use: let qString = getTranslationByKey('bonus-damage-die-type');
1554259222

Edited 1554259360
vÍnce
Pro
Sheet Author
Where did you find that Finderski?  Is it just a js thing or something in the wiki?
1554259420
Finderski
Pro
Sheet Author
Compendium Curator
I found it in the forums...LOL But it's also in the wiki . You'll need to do a CTRL+F to find it...it's not very well documented. Kind of like the data-i18n-vars. :-/
1554259487

Edited 1554259618
vÍnce
Pro
Sheet Author
I must have skipped over that... (It's under Roll Queries, silly me for not seeing it used a sheetworker example.  lol) Thank you much.  I'll dig in.  Cheers