-
-
Notifications
You must be signed in to change notification settings - Fork 421
Open
Description
Creating two files,
locales/en-us.json
{
"hello": "Hello!",
"user.name": "Username"
}locales/sv-se.json
{
"hello": "Hej!"
}Running these in a file like this one;
const i18n = require("i18n");
i18n.configure({
directory: __dirname+'/locales',
defaultLocale: 'en-us',
autoReload: true,
updateFiles: false,
fallbacks: {'sv-se': 'en-us'},
retryInDefaultLocale: true
})
console.log(i18n.__('hello'))
console.log(i18n.__('user.name'))
i18n.setLocale('sv-se')
console.log(i18n.__h('user.name'))
console.log(i18n.__('hello'))
console.log(i18n.__('user.name'))I get the output
Hello!
Username
[ { 'en-us': 'Username' }, { 'sv-se': 'user.name' } ]
Hej!
user.name
As can be seen, the last string is outputted as the translation key, despite having set the fallbacks key in the configuration.
Having a global fallback would also be helpful.
FouadRaheb, Pajk, perfect-pixel, murceca and ahallez
Metadata
Metadata
Assignees
Labels
No labels