GiGs said:
Scott C. said:
Personally, I've found more use for this syntax in javascript for creating dynamically translated roll queries and similar. Of course, that does require some custom javascript functions to really do.
I don't follow this part yet, but I remember seeing something about dunamic translation ibn the "explanatory" page, so will this become more obvious as I reread it?
The dynamic translation on the wiki page is referring to a specific part of the i18n functionality where you can have it use an attribute's value as the translation key.
What I'm talking about there is let's say that you have a sheet that needs to ask for a bonus to use on a roll. For things that there are a set number of in the system (say skills), you can just write a translation key for this query for every skill roll in the system so that you get something along the lines of "What's your bonus to acrobatics?" in the roll query prompt. But, what if you want to do this same roll query when the player rolls for a weapon attack. One way is to just have the query be "What's your bonus on your weapon attack?", but by using the i18n-vars syntax in our resolution of the translation key in javascript, we can make this highly dynamic where it will say "What's your bonus on your +1 Cutlass of Piracy?" and have everything except the weapon name translated (because presumably, the player has written the item name in a language they can understand). I do something like this in the Scion and They Came From ... sheets.
The K-Scaffold actually provides an alias for getTranslationByKey that allows this. So in the K-scaffold given a translation JSON of:
{
"What's your bonus on your {{weapon name}}?": "What's your bonus on your {{0}}?"
}
you can just write this to get the translated roll query prompt text and send it to the user:
getAttrs(['repeating_weapons_-oiuyoiu09s_name'],async (attributes) => {
const promptText = k.getTranslationByKey("What's your bonus on your {{weapon name}}?",[attributes['repeating_weapons_-oiuyoiu09s_name']]);
const roll = await startRoll(`&{template:default} {{bonus=?{${promptText}}}}`);
finishRoll(roll.rollId);
});
That's of course a barebones example, but should show some of the use cases.