Comments (8)
lng comes before namespace
eg. lng de
fallback en
; namespace app
fallback common
- don't find it in de-app
- don't find it in de-common
- don't find it in en-app
- don't find it in en-common
- you had 4 chances to provide the translation -> we just show the key now...
from i18next-gitbook.
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
;
- don't find it in ru-RU-custom
- (don't find it in ru-custom)
- don't find it in en-GB-custom
- find it in ru-RU-default
- ...
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.
from i18next-gitbook.
you're right it will be:
- don't find it in de-app
- don't find it in en-app
- don't find it in de-common
- don't find it in en-common
- 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.
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.
guess it makes no difference...if stuff is not specified in a namespace that should be consistent for all languages
so current:
- don't find it in de-app
- don't find it in en-app
- find it in de-common
will be same result as:
- don't find it in de-app
- find it in de-common
from i18next-gitbook.
@chiefraccoon I just had a PR merged that I believe should solve this issue for you.
#56
from i18next-gitbook.
closing this for now...as documentation was improved to be more specific on this one.
from i18next-gitbook.
Related Issues (20)
- Migration guide for up to v19 HOT 4
- Extended example in "Getting Started" uses deprecated XHR backend HOT 1
- Need help to "Plurals" for muti-language support HOT 4
- Django-i18next is not related to i18next HOT 2
- Missing Keys when target="_blank" HOT 4
- loading translate not working a server side HOT 1
- Improve docs on nesting/multiple counts
- Getting started i18next.init() too complicated for beginners HOT 6
- copy paste issue in docs HOT 1
- Documentation contradicts itself concerning support of json format HOT 3
- "Supported frameworks" needs cleanup HOT 1
- Fallback parsing HOT 1
- How to use Interpolation in html attributes tag HOT 7
- Language change can be reflected to URL route? HOT 6
- node_modules/react-i18next/ts4.1/index.d.ts(259,35): error TS2344: Type 'undefined' does not satisfy the constraint 'KeyPrefix<N>'.
- Setting default language to 'dev' HOT 3
- 404 and Broken link! HOT 1
- Intellisense works only with TypeScript v5, while in documentation it's just recommendation to use v5 HOT 2
- Add dark mode? HOT 2
- Running documentation preview on local machine HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18next-gitbook.