Git Product home page Git Product logo

Comments (8)

jamuhl avatar jamuhl commented on June 3, 2024

lng comes before namespace

eg. lng de fallback en; namespace app fallback common

  1. don't find it in de-app
  2. don't find it in de-common
  3. don't find it in en-app
  4. don't find it in en-common
  5. you had 4 chances to provide the translation -> we just show the key now...

from i18next-gitbook.

chiefraccoon avatar chiefraccoon commented on June 3, 2024

it seems logical, but i am asking because we have faced with opposite behaviour:

eg. lng ru-Ru fallback en-Gb; namespace custom-translations fallback default-translations,
providing key that is specified in ru-Ru - default-translations;

  1. don't find it in ru-RU-custom
  2. (don't find it in ru-custom)
  3. don't find it in en-GB-custom
  4. find it in ru-RU-default
  5. ...

So it attempts to lookup key within one namespace, using fallback lang, and only then goes to another namespace.

Here is debug session record:
https://i.gyazo.com/621441f9c15af796616f80ce7fd9d348.mp4

And here is config:

this.i18nextInstance = i18next.use(reactI18nextModule).init({
            resources: {
                'en-GB': {
                    [TRANSLATION_NAME_SPACES.DEFAULT]: initialTranslations
                }
            },
            fallbackLng: 'en-GB',
            ns: [TRANSLATION_NAME_SPACES.CUSTOM, TRANSLATION_NAME_SPACES.DEFAULT],
            fallbackNS: [TRANSLATION_NAME_SPACES.CUSTOM, TRANSLATION_NAME_SPACES.DEFAULT],
            defaultNS: TRANSLATION_NAME_SPACES.CUSTOM,
            debug: false,
            react: {
                wait: true,
                nsMode: 'fallback'
            },
            saveMissing: true,
            missingKeyHandler: (...args) => {
                // need to disable linter, to emphasize missing key message in console
                // tslint:disable-next-line
                console.error('MISSING KEY', args);
            }
        });

version of i18next - 11.3.6

from i18next-gitbook.

jamuhl avatar jamuhl commented on June 3, 2024

from i18next-gitbook.

jamuhl avatar jamuhl commented on June 3, 2024

you're right it will be:

  1. don't find it in de-app
  2. don't find it in en-app
  3. don't find it in de-common
  4. don't find it in en-common
  5. you had 4 chances to provide the translation -> we just show the key now...

namespace has prio over https://github.com/i18next/i18next/blob/master/src/Translator.js#L239 language code https://github.com/i18next/i18next/blob/master/src/Translator.js#L243

from i18next-gitbook.

chiefraccoon avatar chiefraccoon commented on June 3, 2024

It seems it's not what the majority expect, even you described more logical behavior at first.
The current one changes the language two times... which is confusing.
Could you consider to make this behavior configurable? And it would be better to describe how it is now in doc though.

from i18next-gitbook.

jamuhl avatar jamuhl commented on June 3, 2024

guess it makes no difference...if stuff is not specified in a namespace that should be consistent for all languages

so current:

  1. don't find it in de-app
  2. don't find it in en-app
  3. find it in de-common

will be same result as:

  1. don't find it in de-app
  2. find it in de-common

from i18next-gitbook.

kevin-lindsay-1 avatar kevin-lindsay-1 commented on June 3, 2024

@chiefraccoon I just had a PR merged that I believe should solve this issue for you.
#56

from i18next-gitbook.

jamuhl avatar jamuhl commented on June 3, 2024

closing this for now...as documentation was improved to be more specific on this one.

from i18next-gitbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.