Interpolation in combination with returnObjects does not work
See original GitHub issueDescribe the bug
Interpolation in combination with returnObjects
does not work, because the placeholder is not replaced.
Occurs in react-i18next version
{
"i18next": "^19.4.4",
"i18next-xhr-backend": "^3.2.2",
"react-i18next": "^11.4.0"
}
To Reproduce
{
"requirements": [
"Lorem Ipsum",
"Lorem Ipsum",
"Hello {{name}}"
]
}
const Test = ({ t }) => (
<ul>
{t('requirements', { returnObjects: true, name: 'Elon' }).map((r) => <li key={r}>{r}</li>)}
</ui>
)
export default withTranslation()(Test)
Expected behaviour
[
"Lorem Ipsum",
"Lorem Ipsum",
"Hello Elon"
]
instead of
[
"Lorem Ipsum",
"Lorem Ipsum",
"Hello {{name}}"
]
OS:
- Device: MacBook Pro 13" (2017) with macOS 10.15.3
- Browser: Chrome 81.0.4044.129
Additional context
If I use joinArrays
instead of returnObjects
the interpolation works.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Objects and Arrays - i18next documentation
You can return objects or arrays to be used by third party modules localization: · keys · sample · The returned value supports...
Read more >Translation features - i18next
Hint 1: You can change pre-/suffix by setting options on init or on calling t function with options: interpolationPrefix = '__',; interpolationSuffix =...
Read more >i18next interpolation on nested data not displaying content of ...
You need to define a format function: https://www.i18next.com/translation-function/formatting#legacy-format-function-i18next-less-than-21.3.
Read more >Mastering Multiple Language Support in React Native: Part 3
t("funnyLoadingMessages", { returnObjects: true });. You can apply interpolation and pluralization on the return as well. REFERENCING OTHER KEYS
Read more >View Raw - UNPKG
FormatFunction; /** * Used to separate format from interpolation value * @default ' ... Helps finding issues with loading not working.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
try to set keySeparator to ‘.’, or just not false
If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project. If you liked my support / work - I would enjoy a coffee sponsored using the “💜Sponsor Button”. There are many ways to help this project 🙏