You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I've tried to use this lib in my own project. But basic configuration doesn't work for me.
Here's the language files: locales/en.json
{
"Hello": "Hello EN",
....
}
locales/de.json
{
"Hello": "Hello DE",
....
}
Here's the express.js:
var i18n = new (require('i18n-2'))({
// setup some locales - other locales default to the first locale
locales: ['en', 'de'],
extension: '.json',
directory: path.join(__dirname, '/locales')
});
// Use it however you wish
console.log( 'i18n-2 Hello value: ', i18n.__("Hello") );
This console gives thee Hello instead of Hello EN.
Okay, in my case it was the missing defaultLocale setting.
But in your case (I can see that you've submitted this a few months ago but maybe someone will have a similar issue), I think you need to add a parse function that will transform your json into a JS object.
Hello!
I've tried to use this lib in my own project. But basic configuration doesn't work for me.
Here's the language files:
locales/en.json
locales/de.json
Here's the
express.js
:This console gives thee
Hello
instead ofHello EN
.Additionally, my
i18n
object looks like this:Thanks in advance!
The text was updated successfully, but these errors were encountered: