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

Additional configuration options in react-1i8next are not supported #83

Closed culshaw closed 5 years ago

culshaw commented 5 years ago

There are two specific react options in the react-i18next package which I think aren't supported as part of extraction. (from https://react.i18next.com/latest/i18next-instance)

transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],

With the following Trans component.

<Trans ns="onboarding" i18n={props.i18n}>
    Thank you, {{firstName: props.firstName}}!
    <br />
    Welcome to the party
</Trans>

The extraction is attempting to overwrite a key I have defined already:

-"Thank you, {{firstName}}!<br/>Welcome to the party": "Thank you, {{firstName}}!<br/>Welcome to the party"
+"Thank you, {{firstName}}!<3>Welcome to the party": "Thank you, {{firstName}}!<3>Welcome to the party",

I'm using the babel plugin as part of a webpack stack. .babelrc

                ["i18next-extract", { 
                    "defaultNS": "common",
                    "locales": ["en_GB", "de_DE", "en_MX"], 
                    "jsonSpace": 4,
                    "keySeparator": null,
                    "nsSeparator": null,
                    "keyAsDefaultValue": ["en_GB"],
                    "keyAsDefaultValueForDerivedKeys": false, 
                    "tFunctionNames": [
                        "i18next.t",
                        "i18n.t",
                        "this.props.t",
                        "props.t",
                        "t"
                    ],
                    "outputPath": "./i18n/{{locale}}/{{ns}}.json"
                }]
gilbsgilbs commented 5 years ago

Nice catch, thanks for raising this issue. These options appear to be enabled by default which makes it a bug rather than an improvement IMO.