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

Translation inside roll templates with parameters?

1547575176

Edited 1547575241
Quinn
Pro
Sheet Author
I'm working on a character sheet, and I want to add some pretty simple information to the roll when using healing abilities to display how much HP is restored. At present, I've got this: Restores <span class="healing-number">{{healing}}</span> HP 'healing' is passed in as an argument to the roll, and the resulting string says "Restores 45  HP", with the 45 in green due to definitions in the CSS file. This all works perfectly fine, but before I submit the sheet to the github, I want to get everything translation-friendly. So, I did this: <span data-i18n="template-restores-hp">Restores <span class="healing-number">{{healing}}</span> HP</span> ... {     "template-restores-hp": "Restores <span class=\"sheet-healing-number\">{{healing}}</span> HP" } And when I run this, it says "Restores {{healing}}  HP". Is there something special I have to do in order to communicate a roll template parameter into a translated string? The only alternative I can think of is having a 'template-restores-hp-before' key with value 'Restores ' and a 'template-restores-hp-after' key with value ' HP', but that just seems messy. There was something on the wiki about "^{ [key] }" notation, but the explanation was difficult to parse, so I'm not sure if that applies here or not.
1547576356
Quinn
Pro
Sheet Author
Update: Solved it myself! The solution was adding 'data-i18n-vars="{{damage}}|{{defres}}"' to the span.
1547583548

Edited 1547583572
Natha
KS Backer
Sheet Author
API Scripter
Nice tip! Thanks for sharing. As for the "^{key}" if the translation key for the word "Healing" is "healing", and the key for HP "hp", you could have passed the translation this way: {{healing=^{healing} [[your formula or dice roll]] ^{hp}}}
1547583684

Edited 1547583703
Natha
KS Backer
Sheet Author
API Scripter
Otherwise this should have worked: <span data-i18n="restore">Restores</span> <span class="healing-number">{{healing}}</span> <span data-i18n="hp">HP</span>
1547651526
Quinn
Pro
Sheet Author
I did consider doing something along those lines, but I wanted a solution that elegantly supports languages for which the HP number would be at the beginning or end of the string. Both would've worked, so it's just a matter of preference. Thanks for clarifying the ^{key} syntax!