i18next-parser
i18next-parser copied to clipboard
Nesting t calls causes unwanted key removal
🐛 Bug Report
Nesting t calls causes unwanted removal of keys
To Reproduce
const condition = true
t('test.outer', { subString: condition ? t('test.inner1') : t('test.inner2') })
The keys test.inner1 and test.inner2 will be removed from the translations file.
Expected behavior
Keys should not be removed.
Your Environment
- runtime version: node 20
- i18next-parser version: 9.0.1 (happens also in v8)
- os: macos 14.3
You can prevent the removal of false i18n keys like this!
condition ?
t('test.outer', { subString: t('test.inner1') }) :
t('test.outer', { subString: t('test.inner2') })
or
const testOuterSubString = condition ? t('test.inner1') : t('test.inner2')
t('test.outer', { subString: testOuterSubString })