Replies: 1 comment 2 replies
-
Handlebars.registerHelper('t', function (key, context) {
const translations = { foo: "bar {{b}}" };
if (key in translations) {
const template = Handlebars.compile(translations[key]);
return template(context['data']['root']);
}
return key;
}) Maybe there is a better way... |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I implemented a custom localization helper, which gets a translation key and maps it to a value e.g.
<a href="www.some-link.com">{$t my.key}</a>
I would like my translation values to contain other mustache expressions, such as resolving a variable from the context. An example would be
"my.key": "click here for help with {{productName}}"
I would like for that returned value to then be treated as an expression and resolved. Is there a way to achieve that?
Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions