Romanchuk / angular-i18next

angular v10+ integration with i18next v19.4+
MIT License
131 stars 33 forks source link

i18next::translator: missingKey on simple implementation #94

Closed stormfar closed 1 year ago

stormfar commented 1 year ago

Running

"i18next": "^21.9.2",
"angular-i18next": "^14.0.5",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-http-backend": "^2.0.1",

Following the readme, I have this in app modules,

const i18nextOptions = {
    whitelist: ['en', 'de'],
    fallbackLng: 'en',
    debug: true,
    returnEmptyString: false,
    ns: ['translations'],
    interpolation: {
        format: I18NextModule.interpolationFormat(defaultInterpolationFormat)
    },
    backend: {
        loadPath: 'locales/{{lng}}.{{ns}}.json'
    },
};

then in src/locales, I have an en.translations.json and de.translations.json with this:

{
    "test": "Test String"
}

In my component.html, I have {{ 'test' | i18next }}, but when running my app, I just the key instead of the value, with this message in the console.

i18next::translator: missingKey en translations test test

Am I missing something?

I should note it works when I add translations via the resources i18next option.

stormfar commented 1 year ago

Figured it out. Needed to add "src/locales" to the assets list in angular.json. I guess this was more related to i18next-http-backend.