Empty extractions after upgrade
selankon opened this issue ยท 5 comments
๐ Bug Report
On our project we updated React, Next and a bunch of libraries, including the i18next-parser, used to extract translations. Concretely from 3.7.0
to 7.7.0
. (here the list of packages upgraded https://github.com/vocdoni/explorer-ui/pull/67/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519)
But after the upgrade, when running i18next
from yarn or either npm, the only translation extracted is this:
{
"card": {
"block": ""
}
}
The translations on the project are made using the useTranslation
hook:
const { i18n } = useTranslation();
i18n.t('organizations.list.organizations_list_title')
And I tried, without success, to import directly t
:
const { t } = useTranslation();
t('organizations.list.organizations_list_title')
Any of this examples extracted translations.
The config file is here: https://github.com/vocdoni/explorer-ui/blob/master/i18next-parser.config.js
To Reproduce
I guess the best way to test it is cloning the project, and simply run:
git clone https://github.com/vocdoni/explorer-ui/
yarn
yarn i18n-extract
Probably you can point me some error made during the upgrade to research deeper without spending time on create an MVP, because is a complex case (a big upgrade from outdated libraries on a NextJS project). If not, I will try to code simpler example.
Expected behavior
The old translations are moved properly, but the new files are empty.
Your Environment
- runtime version: node v18.12.1 and v16.18.0
- i18next version: "^22.4.10",
- react-i18next": "^12.2.0",
- "i18next-parser": "^7.7.0",
- os: Linux
Hi, can somebody point me where to research? I have no idea where to look... Thanks in advance!
@selankon I unfortunately have limited bandwidth to review your code and I don't see anything obvious.
I tried with version "i18next-parser": "^8.2.0"
and still not working. How can I advance to find the bug origin? Or what you need to help me @karellm ?
As mentionned previously, I have limited time to work on this project atm. You are trying to make a big jump between versions and I would recommend that you upgrade one major version at a time to pin point where the issue comes from. Also I can already see that your output
value doesn't take the namespace into consideration. Empty catalogs are often due to an incorrect value for the output
. Please make sure you have both the $LOCALE
and $NAMESPACE
in it and report back.
Ok finally found the problem. Setting up the $NAMESPACE
I realized that one translation string was malformed (attention to last :
):
i18n.t('transaction.card.block:')
Causing the library to interpret that this was a namespace. Somehow, if the $NAMESPACE
is not set, it only generate the first namespace. So deleting this stupid typo everything starts to work as expected again, either withou the $NAMESPACE
variable.
Thanks for help!