gilbsgilbs/babel-plugin-i18next-extract

Special characters are removed

JSteunou opened this issue · 0 comments

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

  • OS (e.g. ArchLinux): ? Ubuntu 20.04
  • Plugin version (e.g. 0.3.0): ? 0.8.2
  • Node version (e.g. 12.13.0): ? 14.15.4

Additional context