Closed tehmas closed 2 years ago
there is config for such:
// use mustache with customTags (https://www.npmjs.com/package/mustache#custom-delimiters) or disable mustache entirely
mustacheConfig: {
tags: ['{{', '}}'],
disable: false
}
@mashpie Thanks for the answer. Ah, I guess it is a very naive follow-up question but are you suggesting to do it in the global configuration as suggested in the README and here?
I only need it to ignore the custom tags while calling i18n.__()
in a particular situation.
Cite from https://www.npmjs.com/package/mustache
If you want {{name}} not to be interpreted as a mustache tag, but rather to appear exactly as {{name}} in the output, you must change and then restore the default delimiter. See the Custom Delimiters section for more information.
so, for now you could choose custom delimiters for backend and use defaults for frontend.
Or... create two i18n instances similar to how it's done in this test https://github.com/mashpie/i18n-node/blob/master/test/i18n.configureMustache.js
Thanks for the response.
Consider the following key/value example pair in
en.json
file:"required": "The {{key}} is required"
Using
i18n.__("required")
returns:The is required
I have a usecase in which I do not want the
{{key}}
to be substituted byi18n.__()
and I need to get the string without substitution i.e.:The {{key}} is required