Migrating from 8.x to 9.x
June 9, 2024 ยท View on GitHub
Breaking changes
- Support for the
VueLexerhas been dropped as it creates compatibility problems when trying to parse Vue3 code bases. You must remove any references toVueLexerin your configuration files. For Vue3, you can simply useJavascriptLexerinstead. - Support for Node 16 is dropped. Node 18, 20 and 22 are supported.
Migrating from 7.x to 8.x
Breaking changes
- Support for Node 14 is dropped. Node 16, 18 and 20 are supported.
Migrating from 6.x to 7.x
Breaking changes
- The API to manage what default value is being used was getting too complicated. This version simplifies the API by deprecating the
skipDefaultValuesanduseKeysAsDefaultValuesoptions and adding avalueargument when thedefaultValueoption is used as a function. Here are couple example of how it can be used:
To replace skipDefaultValue, make the following change:
// 5.x.x
{
skipDefaultValues: true
}
// 6.x.x
{
defaultValue: function (locale, namespace, key, value) {
return '';
}
}
To replace useKeysAsDefaultValues, make the following change:
// 5.x.x
{
useKeysAsDefaultValues: true
}
// 6.x.x
{
defaultValue: function (locale, namespace, key, value) {
return key;
}
}
And now you have complete control over the logic:
// 6.x.x
{
defaultValue: function (locale, namespace, key, value) {
if (locale === 'fr') {
return '';
}
return value || key;
}
}
Migrating from 5.x to 6.x
Breaking changes
- We dropped support for node versions that are not LTS. Only even numbered versions will be supported going forward. Support is for Node 14+
- This project is now a pure ESM project. You can read about it here to help you transition your project.
Migrating from 4.x to 5.x
Breaking change
- The output format is now in JSON v4. To convert your existing translations to the new v4 format, have a look at i18next-v4-format-converter or this web tool.
Migrating from 2.x to 3.x
Breaking change
reactNamespaceoption is gone. To use jsx in js file, overwrite the lexer.
Migrating from 1.x to 2.x
Breaking change
- Drop support for Node 6 and 8 (EOL)
Migrating from 0.x to 1.x
Breaking changes
- Jade is not being tested anymore. If this is something you need, please make a PR with a Lexer for it
regexoption was deprecated. If you need to support a custom file format, please make a PR with a Lexer for itignoreVariableswas deprecated. Keys that are not string litterals now emit a warningwriteOldwas renamedcreateOldLibraries. It defaults totrue.namespacewas renameddefaultNamespace. It defaults totranslation.prefixwas deprecated. Useoutputsuffixwas deprecated. Useoutputfilenamewas deprecated. Useoutputextensionwas deprecated. Useoutput- catalogs are no longer sorted by default. Set
sorttotrueto enable this.
Improvements
defaultValue: replace empty keys with the given valueoutputsupport for$NAMESPACEand$LOCALEvariablesindentationlet you control the indentation of the catalogslineEndinglet you control the line ending of the catalogssortlet you enable sorting.
Lexers
Instead of writing a single regex to match all use cases or to run many regexes on all files, the new version introduce the concept of "Lexer". Each file format has its own Lexer. It adds some code but reduces complexity a lot and improves maintainability.
CLI
i18next input:outputsyntax was deprecated. Use the--outputoptionrecursivewas deprecated. You can now pass a globdirectoryFilterwas deprecated. You can now pass a globfileFilterwas deprecated. You can now pass a glob
0.x
i18next src --recursive --fileFilter '*.hbs,*.js' --directoryFilter '!.git'
1.x
i18next 'src/**/*.{js,hbs}' '!.git'