i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
452 stars 70 forks source link

backend refresh does only triggered for fallback + preload languages #155

Closed Dexus closed 1 month ago

Dexus commented 1 month ago

🐛 Bug Report

It loads only the fallback + preload languages.

To Reproduce

const i18nextOptions: InitOptions = {
        load: 'languageOnly' as const,
        // Default language.
        lng: 'ru',
        // Logging i18next information to the console.
        debug: true,
        nonExplicitSupportedLngs: true,
        preload: ['en', 'de'],
        initImmediate: false,
        ns: ['translation', 'common', 'category', 'ui'],
        defaultNS: 'translation',
        supportedLngs: ['de','es','pl','ru','pt','fr'],
        nsSeparator: false,
        keySeparator: false,
        // Interpolation option to escape passed in
        // values to avoid XSS injection.
        interpolation: {
            escapeValue: true,
        },
        // Language to use if translations in the
        // active language are not available.
        fallbackLng: "fr",
        saveMissing: true,
        backend: {
            loadPath: `${config.LOCALE_API_URL}/locales/{{lng}}/{{ns}}.json`,
            addPath: `${config.LOCALE_API_URL}/locales/{{lng}}/{{ns}}/`,
            reloadInterval: 3000
        }
    };

    console.log(i18nextOptions)
    i18next.use(HttpBackend).init(i18nextOptions).then(function (t) {
//...
})

Expected behavior

It should load all supported Languages or at least the current set language + the preload + fallback.

Your Environment

adrai commented 1 month ago

No, if you want all supportedLngs to be loaded, you need to put them into the preload option... The supportedLngs option does not influence the loading, but the language resolution