-
-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested translation resolution between languages uses the fallback language for nested translations #2216
Labels
Comments
Not able to reproduce... i18next
.init({
resources: {
en: {
translations: {
"one": "one",
"one_dollar": "$$t(one)"
},
},
fr: {
translations: {
"one": "un"
},
},
},
supportedLngs: ["en", "fr"],
fallbackNS: "translations",
defaultNS: "translations",
fallbackLng: "en",
defaultLng: "en",
})
.then((t) => {
console.log('en: ' t("one_dollar", { lng: 'en' })); // en: $one
console.log('fr: ' t("one_dollar", { lng: 'fr' })); // fr: $un
}); |
Sorry, I somehow copied wrong link to the codesandbox, now updated I'm not talking about passing a language to So you can reproduce with this i18next
.init({
resources: {
en: {
translations: {
"one": "one",
"one_dollar": "$$t(one)",
"two": "two",
"two_dollars": "$$t(two)"
},
},
fr: {
translations: {
"one": "un",
"two": "deux",
"two_dollars": "$$t(two)"
},
},
},
supportedLngs: ["en", "fr"],
fallbackNS: "translations",
defaultNS: "translations",
fallbackLng: "en",
defaultLng: "en",
})
.then((t) => {
console.log("en: " t("one_dollar")); // en: $one
console.log("en: " t("two_dollars")); // en: $two
i18next.changeLanguage("fr");
console.log("fr: " t("one_dollar")); // fr: $one
console.log("fr: " t("two_dollars")); // fr: $deux
}); |
Please try with v23.12.2 |
yes, now it works! thank you 🙏 lightning-fast fix |
heharm
pushed a commit
to wanderlog/i18next
that referenced
this issue
Aug 15, 2024
…k language for nested translations i18next#2216 by preserving issue fix "`lng` is undefined when formatter used in `$t( )`" i18next#1938
This was referenced Sep 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐛 Bug Report
Unexpected translation resolution takes place in case of translation nesting. You can see it in the example, but in a few words: English is default, French is another language; we have the
one_dollar
key that's translated as$$t("one")
, resulting into $one in English and $un in French (expectedly), but i18next actually produces $one in both casesTo Reproduce
A codesandbox example
Expected behavior
Your Environment
The text was updated successfully, but these errors were encountered: