Sourced from i18next's releases.
v27.2.2
- fix:
setDefaultNamespace()works on a clone. A clone's translator keeps its own options object, so the call changedi18n.options.defaultNSwhilet()kept using the old default namespace. i18next-http-middleware hands every request a clone, soreq.i18n.setDefaultNamespace()did nothing there. (#2106)- fix:
supportedLngsworks in any casing. Every other language code is formatted (pt-brtopt-BR,ENtoen, all lowercase withlowerCaseLng), butsupportedLngswas compared as written, sosupportedLngs: ['pt-br'],['EN'], or['pt-BR']withlowerCaseLng: truerefused that language and fell back. They are now compared in that formatted form (also byloadLanguages()), whileoptions.supportedLngsstays as written. (#1791)- fix(types): resources typed with named
interfaces get their nested keys. The key types only walked into objects with an index signature, which a type alias has and an interface does not, sot('nested.key')failed with TS2345 whilet('nested')compiled. Interfaces now give the same keys as type aliases, sot('nested')withoutreturnObjectsis rejected for them too. (#2326)- fix(types): typed keys work with
strictNullChecks: false. Without strict null checksundefinedpassesextends string, so the key prefix, namespace and context checks took a missingkeyPrefix,nsorcontextfor a value:t('title')was rejected (onlyt('ns:title')compiled),t()returnedstring, and react-i18next'sTransaccepted noi18nKey. A new type test project compiles withstrictNullChecks: false; with strict null checks the types resolve as before. (#2085)v27.2.1
- fix: a variable passed as
undefinedrenders as an empty string when its placeholder has a format too ({{amount, number}}), as{{amount}}already did. The placeholder stayed in the result with the defaultskipOnVariables: true, and debug mode logged "missed to pass in variable" with either setting. Thanks@Vineet829(#2479)v27.2.0
- fix: an error thrown by a load callback or a listener (the callback of
init,changeLanguage,loadNamespacesorloadLanguages, or alanguageChanged/loadedlistener) is no longer handed back to the backend connector as if the read had failed. With a backend whosereadreturns a value or a promise, the connector got that error a second time: the namespace that had loaded was marked as failed,failedLoadingwas emitted with your error and the count of running reads dropped to -1. The error now reaches your app: it is thrown from the call that started the load for areadthat returns a value, and it is an unhandled rejection for areadthat returns a promise, which ends a Node.js process unless you handleunhandledRejection. Thanks@SudeepGowda55(#2477)- fix: when a load callback throws, the other callbacks waiting for the same namespaces are still called and the
loadedevent is still emitted, and the error is thrown on after that. A secondloadNamespaces()for the same namespace never called back before.- fix:
addResourceBundle(lng, ns, resources, true, true)overwrites numbers and booleans too. Only strings were replaced, so{ n: 0 }stayed 0 after adding{ n: 5 }, and adding an object where the bundle had a number, boolean or null threwCannot create property ... on number, also withoutoverwrite. Withoverwrite, a number, boolean or null now also replaces a nested object, as a string already did. Thanks@SudeepGowda55(#2476)- fix: with
keySeparator: false, a namespace separator inside the key after the namespace is kept.t('common:errors:required')looked up'errorsfalserequired'instead of the flat key'errors:required'that i18next-cli extracts (also for a selector like$ => $.common['errors:required']), and reported the missing key under that name. This dates back to 11.3. Thanks@SudeepGowda55(#2478)
Sourced from i18next's changelog.
27.2.2
- fix:
setDefaultNamespace()works on a clone. A clone's translator keeps its own options object, so the call changedi18n.options.defaultNSwhilet()kept using the old default namespace. i18next-http-middleware hands every request a clone, soreq.i18n.setDefaultNamespace()did nothing there. (#2106)- fix:
supportedLngsworks in any casing. Every other language code is formatted (pt-brtopt-BR,ENtoen, all lowercase withlowerCaseLng), butsupportedLngswas compared as written, sosupportedLngs: ['pt-br'],['EN'], or['pt-BR']withlowerCaseLng: truerefused that language and fell back. They are now compared in that formatted form (also byloadLanguages()), whileoptions.supportedLngsstays as written. (#1791)- fix(types): resources typed with named
interfaces get their nested keys. The key types only walked into objects with an index signature, which a type alias has and an interface does not, sot('nested.key')failed with TS2345 whilet('nested')compiled. Interfaces now give the same keys as type aliases, sot('nested')withoutreturnObjectsis rejected for them too. (#2326)- fix(types): typed keys work with
strictNullChecks: false. Without strict null checksundefinedpassesextends string, so the key prefix, namespace and context checks took a missingkeyPrefix,nsorcontextfor a value:t('title')was rejected (onlyt('ns:title')compiled),t()returnedstring, and react-i18next'sTransaccepted noi18nKey. A new type test project compiles withstrictNullChecks: false; with strict null checks the types resolve as before. (#2085)27.2.1
- fix: a variable passed as
undefinedrenders as an empty string when its placeholder has a format too ({{amount, number}}), as{{amount}}already did. The placeholder stayed in the result with the defaultskipOnVariables: true, and debug mode logged "missed to pass in variable" with either setting. Thanks@Vineet829(#2479)27.2.0
- fix: an error thrown by a load callback or a listener (the callback of
init,changeLanguage,loadNamespacesorloadLanguages, or alanguageChanged/loadedlistener) is no longer handed back to the backend connector as if the read had failed. With a backend whosereadreturns a value or a promise, the connector got that error a second time: the namespace that had loaded was marked as failed,failedLoadingwas emitted with your error and the count of running reads dropped to -1. The error now reaches your app: it is thrown from the call that started the load for areadthat returns a value, and it is an unhandled rejection for areadthat returns a promise, which ends a Node.js process unless you handleunhandledRejection. Thanks@SudeepGowda55(#2477)- fix: when a load callback throws, the other callbacks waiting for the same namespaces are still called and the
loadedevent is still emitted, and the error is thrown on after that. A secondloadNamespaces()for the same namespace never called back before.- fix:
addResourceBundle(lng, ns, resources, true, true)overwrites numbers and booleans too. Only strings were replaced, so{ n: 0 }stayed 0 after adding{ n: 5 }, and adding an object where the bundle had a number, boolean or null threwCannot create property ... on number, also withoutoverwrite. Withoverwrite, a number, boolean or null now also replaces a nested object, as a string already did. Thanks@SudeepGowda55(#2476)- fix: with
keySeparator: false, a namespace separator inside the key after the namespace is kept.t('common:errors:required')looked up'errorsfalserequired'instead of the flat key'errors:required'that i18next-cli extracts (also for a selector like$ => $.common['errors:required']), and reported the missing key under that name. This dates back to 11.3. Thanks@SudeepGowda55(#2478)
cb3add8
27.2.28bfb33b
changelog for 27.2.29afc4bf
fix(types): nested keys for resources typed with interfaces, and typed
keys w...ef8c31a
fix: supportedLngs works in any casingedfea35
fix: setDefaultNamespace() works on a clone5d8505d
27.2.1ddbf812
changelog for 27.2.16ba661c
fix: render a formatted variable passed as undefined as an empty string
(#2479)7c7a49a
27.2.0ad31df5
changelog for 27.2.0