gilbsgilbs / babel-plugin-i18next-extract

Babel plugin that statically extracts i18next and react-i18next translation keys.
https://i18next-extract.netlify.com
MIT License
161 stars 37 forks source link

Special characters are removed #183

Open JSteunou opened 3 years ago

JSteunou commented 3 years ago

Describe the bug

Special characters like unicode unbreakable space are removed

How to reproduce

Unbreakable spaces are important in some language like french, because you need a space before exclamation mark for example, but you don't want it to go on the next line and be separated from its previous word.

<Trans i18nKey="foo">bar\u00A0!<Trans> Should be extract as

{
  "foo": "bar\u00A0!"
}

Babel configuration:

cra project with override

        addBabelPlugin([
            'babel-plugin-i18next-extract',
            {
                keySeparator: null,
                outputPath: 'src/locales/{{locale}}/translations.json',
                locales: ['en', 'fr'],
                nsSeparator: '#NSS#',
                jsonSpace: 4,
                defaultValue: '',
                keyAsDefaultValue: ['en'],
            },
        ]),

Reproduction:

<Trans i18nKey="foo">bar\u00A0!<Trans> should be extracted as

Expected behavior

{
  "foo": "bar\u00A0!"
}

What actually happens

but is extracted as

{
  "foo": "bar !"
}

Your environment

Additional context