__lng__
is the language to load
__ns__
is the namespace to load
Basically it means that if you initialise with lng: 'en-US'
it will try to load:
_this.buildPath + _this.i18nPath + 'en-US/translation.json'
_this.buildPath + _this.i18nPath + 'en/translation.json'
_this.buildPath + _this.i18nPath + 'dev/translation.json'
Because dev is the default falback language & translation is the default namespace.
You may find the docs here useful as it shows some more ways of using them depending on how your backend works.
EDIT: There are a number of ways to set the language which is loaded. The simplest way to do this is by passing the value as the lng
parameter of i18n.init()
. An example of this would be:
i18n.init({
debug: false,
getAsync: false,
lng: _this.language,
fallbackLng: _this.defaultLanguage,
resGetPath: _this.buildPath + _this.i18nPath + '__lng__/__ns__.json'
});
This example is the same as yours but explicitly sets the language. I also set fallbackLng
but this is mainly useful if you accept the language from a user in some way (e.g from browser language) so that any unsupported languages will fallback to a default. If you only allow selection from pre-approved values then this may not be required.