Open abzokhattab opened 3 years ago
you could setup fallbacks, ie.:
i18n.configure({
// setup some locales - other locales default to en silently
locales: ['en', 'de'],
// fallback from Dutch to German and from any localized German (de-at, de-li etc.) to German
fallbacks: { nl: 'de', 'de-*': 'de' },
//...
check tests for inspiration: https://github.com/mashpie/i18n-node/blob/master/test/i18n.fallbacks.js
Thanks, @mashpie for the reply however, i meant a default translation for a specific phrase not a fallback to another language:
consider this senario: i have only one locale file (en.json) with the following content:
{
"hi":"hola"
}
then i want to translate a phrase that isnt there in the locale file example ->
i18n.__("error")
results:
{
"hi":"hola",
"error","error"
}
as you can see the error
phrase was translated to error
because it is not presented in the file
What I'd like to do is add a default value for phrases that don't exist in the file. Here's what I'm expecting ->
i18n.__("error", {defaultValue:"Server error"})
results:
{
"hi":"hola",
"error","Server error"
}
is there such an option?
Looks like you are looking for https://github.com/mashpie/i18n-node#defaults
so in your case:
i18n.__("error:Server error")
should do
Hello everybody ,,
How to pass a default translation if a phrase isn't existed in the en.json file
i cant find any option to add a default translation if the translation is not found ?
example
howover i want to set a defualt value if the translation is not found to be --->