i18next-parser: Exception when trying to parse Trans element JSX with interpolation
- Is this a bug or a feature request? bug
- What version are you running (
0.x
or1.x
)? 1.0.0-beta13 - Which runner (cli, gulp…)? cli
What I’m trying to do?
Extract translations from a Trans tag that uses interpolation
How am I doing it?
./node_modules/.bin/i18next ‘trans-tmp/components/*.jsx’ -c i18n.config.js
Example React code being parsed:
…
<DialogHeaderTitle> <Trans>Consumer Information for {{name}}</Trans> </DialogHeaderTitle>
…
Here is my config file:
module.exports = { reactNamespace: true, locales: [‘fr’, ‘en’], output: ‘locales’ };
What was the result?
i18next Parser
Input: ‘trans-tmp/components/*.jsx’ Output: locales
[read] C:\GIT\react-component-final\trans-tmp\components\Component.jsx [read] C:\GIT\react-component-final\trans-tmp\components\ComponentConsumers.jsx [read] C:\GIT\react-component-final\trans-tmp\components\ComponentDependencies.jsx [read] C:\GIT\react-component-final\trans-tmp\components\ComponentList.jsx [read] C:\GIT\react-component-final\trans-tmp\components\Header.jsx [read] C:\GIT\react-component-final\trans-tmp\components\TitleBar.jsx [write] C:\GIT\react-component-final\locales\fr\Consumer Information for <1>{{ name.json [write] C:\GIT\react-component-final\locales\fr\Consumer Information for <1>{{ name_old.json [write] C:\GIT\react-component-final\locales\fr\translation.json [write] C:\GIT\react-component-final\locales\fr\translation_old.json [write] C:\GIT\react-component-final\locales\en\Consumer Information for <1>{{ name.json [write] C:\GIT\react-component-final\locales\en\Consumer Information for <1>{{ name_old.json [write] C:\GIT\react-component-final\locales\en\translation.json [write] C:\GIT\react-component-final\locales\en\translation_old.json
Stats: 6 files were parsed events.js:183 throw er; // Unhandled ‘error’ event
Error: ENOENT: no such file or directory, open ‘C:\GIT\react-component-final\locales\fr\Consumer Information for <1>{{ name.json’
What was I expecting?
Proper output translation key: EX:
“Consumer Information for <1>{{name}}</1>”: “Information du consommateur pour <1>{{name}}</1>”,
Not sure why the parser is attempting to output the new files with an improperly-parsed key.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (13 by maintainers)
I’ll have one minor tweak here soon, just as soon as I confirm the behaviour of i18n-react.
Taking a look.