You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When extracting multiple languages from Trans component with ICU, it produces invalid result for 2nd and latter language. See examples below.
How to reproduce
Run script yarn run babel 'src/**/*.tsx' with babel below and React component above
import { Trans } from "react-i18next/icu.macro"
export const Demo = () => {
return (<Trans i18nKey="count-things" count={count}>{{count}} Thing</Trans>)
}
Expected behavior
{
"count-things": "{count, plural, one {{count} Thing} other {{count} Thing}"
}
What actually happens
On second and latter language produces invalid result
{
"count-things": "{count, plural, one {{count, plural, one {count} Thing} other {count} Thing}} other {{count, plural, one {count} Thing} other {count} Thing}}"
}
Your environment
OS (e.g. ArchLinux): OSX
Plugin version (e.g. 0.3.0): 0.8.2
Node version (e.g. 12.13.0): 14.15.4
Additional context
Why it happens: I tracked things down in the code and it is caused by the code in
The reason is that the first run (language) sets the extractedKey.parsedOptions.defaultValue to the ICU formatted and the second run wrap that again and another again and so on. The fix can be to run this default value set only once and then use it for all languages.
The text was updated successfully, but these errors were encountered:
Describe the bug
When extracting multiple languages from Trans component with ICU, it produces invalid result for 2nd and latter language. See examples below.
How to reproduce
Run script
yarn run babel 'src/**/*.tsx'
with babel below and React component aboveBabel configuration:
Reproduction:
Expected behavior
What actually happens
On second and latter language produces invalid result
Your environment
Additional context
Why it happens: I tracked things down in the code and it is caused by the code in
babel-plugin-i18next-extract/src/keys.ts
Lines 131 to 140 in 9169cb7
extractedKey.parsedOptions.defaultValue
to the ICU formatted and the second run wrap that again and another again and so on. The fix can be to run this default value set only once and then use it for all languages.The text was updated successfully, but these errors were encountered: