Closed mayteio closed 4 years ago
https://www.i18next.com/translation-function/essentials#accessing-keys-in-different-namespaces
That is not an inconsistency - when adding resources on init you will have to additionally give i18next the namespace.
Loading: translation.json
{
"example": "Example"
}
// it nows the namespace and loads one by one
Passing resources
{
"translation": {
"example": "Example"
}
}
// it does not know the namespace upfront and gets passed in multiple
Got it, so I have to pass in the 'translation' namespace explicitly when passing resources into init. Cheers.
https://www.i18next.com/how-to/add-or-load-translations might help too
Fantastic, thanks mate.
🐛 Bug Report
Given the json file:
You can access example via
t
like so:t("ns:example")
by passing inresources
option to init.When using i18next-http-backend to load the resource, i.e.
loadPath: "/translations/{{lng}}.json"
, it seems the namespace is lost and you must access it via dotty notationt("ns.example")
.To Reproduce
codesandbox
Expected behavior
Accessing keys should be consistent between the two packages.
Your Environment
Chrome latest "i18next": "^19.6.3", "i18next-http-backend": "^1.0.18", MacOS