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
453 stars 70 forks source link

If I set the language is 'ko-KR', there will have two request 'ko' and 'ko-KR' #61

Closed Rem486 closed 3 years ago

Rem486 commented 3 years ago

🐛 Bug Report

A clear and concise description of what the bug is.

To Reproduce

A codesandbox example or similar or at least steps to reproduce the behavior:

import i18n from 'i18next';
import Backend from 'i18next-http-backend';

i18n
  .use(Backend)
  .init({
    fallbackLng: 'ko-KR',
    preload: ['ko-KR'],
    backend: {
      loadPath: `http://localhost/api/translation-resource/{{lng}}`,
    },
    interpolation: {
      escapeValue: false, // not needed for react as it escapes by default
    },
  });

image

Expected behavior

A clear and concise description of what you expected to happen.

only one request, or Is this normal ?

Your Environment

adrai commented 3 years ago

Yes, this is expected: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources default load option is 'all' image

try:

import i18n from 'i18next';
import Backend from 'i18next-http-backend';

i18n
  .use(Backend)
  .init({
    fallbackLng: 'ko-KR',
    preload: ['ko-KR'],
    load: 'currentOnly',
    backend: {
      loadPath: `http://localhost/api/translation-resource/{{lng}}`,
    },
    interpolation: {
      escapeValue: false, // not needed for react as it escapes by default
    },
  });