chore(deps): bump i18next from 22.5.1 to 27.2.6
DE
9d ago+18+18+01234567890123456789-10-10-01234567890123456789
Bumps i18next from 22.5.1 to 27.2.6.
Release notes
Sourced from i18next's releases.
v27.2.6
- fix: an empty plural default value counts, like
defaultValue: '':t('key', { count: 0, defaultValue_zero: '', defaultValue_other: '{{count}} items' })returns''instead of "0 items", and saveMissing saves''for a form given as''(key_zerotoo) instead of another form's text. A form without its own default savesdefaultValue, then theotherdefault, instead of the default resolved for the current count. Thanks@arba-octo(#2480)v27.2.5
- fix(types):
LoggerModule'slog,warnanderrortake one array, the way i18next calls them (log(args)); they were typed with rest parameters, so a logger typed to spread...argsgot the array as its only argument. Loggers typed either way still compile.- fix(types):
I18nFormatModuledeclares the members i18next calls:init,parse,addLookupKeys,handleAsObjectandgetResource, all optional. It declared onlytype, so an object-literal i18n format with these members failed to compile.v27.2.4
- fix(types):
BackendModule.createtakes the parameters i18next passes it: a backend withcallbackApi: truegetscreate(languages, namespace, key, fallbackValue, callback, options), one withcallbackApi: falsegetscreate(languages, namespace, key, fallbackValue, options)and may return a promise. The types declared only the first four parameters, so a required fifth or sixth parameter failed to compile and an object-literal backend could not take them at all. One rare case now fails: acreate: (...args) => other.create(...args)that forwards to acreatetyped with exactly four parameters. The doc comments ofreadandreadMultinow describe their promise form (read(language, namespace)returning the data or a promise of it), which the types already accepted.- fix(types):
getFixedT()takes its fourth parameter,{ scopeNs }, the full list of namespaces the returnedtis bound to, which selector keys use to find a namespace prefix; lookups still usens(react-i18next'suseTranslationpasses it).- fix(types): the doc comment of
saveMissingPluralssays@default true, the runtime default since the option came in 10.3.0, notfalse.v27.2.3
- fix: a variable in the options of a nested
$t(key, { "name": "{{name}}" })is escaped once. With the defaultescapeValue: trueit was escaped for HTML before the options were parsed and again by the nestedt(), soTom & Jerrycame out asTom & Jerry(and react-i18next'sTranshas shownTom & Jerrysince 17.1.10, withescapeValue: falsetoo). These variables are now escaped for the options' JSON, whateverescapeValueis, and the nestedt()escapes them like the values of a direct call;defaultValueandjoinArraysthere, which it does not interpolate, stay escaped once. A value with",',\or a line break no longer breaks the options, withescapeValue: falsea value can no longer inject options such aslng, and withskipOnVariablesa{{placeholder}}inside a value is no longer interpolated a second time. The warning added in 26.0.6 now covers{{- var}}in these options, the one form still inserted unescaped, instead ofescapeValue: false.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)v27.1.5
- fix:
off(event, listener)removes a listener added withonce().once()registers a wrapper, sooff()with the listener itself found nothing and the listener still ran on the next event. Aonce()listener is now also removed before it runs, so one that emits the same event again (like callingchangeLanguage()fromlanguageChanged) or throws runs only once. Thanks@SudeepGowda55(#2475)v27.1.4
- fix(types): with
enableSelector, assigning atfunction to a widerTFunction(TFunction<'ns'>toTFunction<'ns', string>orTFunction<Namespace>, or a key prefix to a wider one) failed with TS2590 "Expression produces a union type that is too complex to represent" once the namespaces had about 600 top-level keys together. This started in 26.3.3. Selector results for JSON arrays that mix arrays with objects or strings also keep the inner arrays as arrays. Thanks@reckter(#2474)v27.1.3
- security: a language code named after a property every object inherits (
hasOwnProperty,isPrototypeOf,toLocaleString,__defineGetter__, ...) made the backend connector throwobj[k].push is not a functionwhen its load finished. A language detector passes such a code on from a request (?lng=hasOwnProperty), and with an asynchronous backend nothing caught the throw, so one request ended a Node.js server process (in a browser,init()never resolved). Now these codes load like any other unknown language. Thanks@superbot-helper(GHSA-q76c-gcvw-89x9)- fix: with an object
fallbackLng, a language code named like anObject.prototypeproperty (constructor,toString,hasOwnProperty,constructor-US) gets thedefaultfallback instead of makingt(),exists(),getFixedT()andchangeLanguage()throwfallbackCodes.forEach is not a function. Thanks@cyphercodes(#2473, #2472)v27.1.2
- security: language codes and namespaces that come from requests no longer grow the memory of a server without end. The backend connector kept one entry per failed load, so that it does not read it again, and the language hierarchy and plural rule caches kept one entry per language code. With the default
supportedLngs: false, every made-up language a detector found (?lng=xx1,?lng=xx2, ...) or every made-up namespace requested from i18next-http-middleware'sgetResourcesHandleradded about 180 bytes for good. Now only the most recent 1000 failed loads are kept (an older one is read again when it is needed), and both caches are emptied at 1000 codes, as the formatted language codes already were. Pairs with i18next-http-middleware 3.10.1 (GHSA-mjcw-gfh6-3cxm).v27.1.1
- perf:
t()skips the interpolation and nesting regexp scans when the text has no interpolation or nesting prefix, about 6-14% faster for short texts and up to 75% for long ones. The output does not change. Thanks@g4lb(#2469)v27.1.0
- feat: when the plural form selected for
countis missing,t()uses the_otherform of the same language before the next fallback language, as CLDR does (lateral inheritance), instead of returning the key. Current CLDR data gives French, Spanish, Italian and Portuguese amanyform for exact millions, so files with only_oneand_othershowed the key (or the fallback language) forcount: 1000000. The plain key still comes first, sokey+key_otherkeeps resolvingkey; with a context,key_<context>_othercomes beforekey_other; ordinals use_ordinal_other; anddefaultValue_otheris used afterdefaultValue. A form filled in from_otheris no longer reported as missing (saveMissing,missingKeyHandler,exists()). Thanks@TenPotatoes(#2468)v27.0.1
... (truncated)
Changelog
Sourced from i18next's changelog.
27.2.6
- fix: an empty plural default value counts, like
defaultValue: '':t('key', { count: 0, defaultValue_zero: '', defaultValue_other: '{{count}} items' })returns''instead of "0 items", and saveMissing saves''for a form given as''(key_zerotoo) instead of another form's text. A form without its own default savesdefaultValue, then theotherdefault, instead of the default resolved for the current count. Thanks@arba-octo(#2480)27.2.5
- fix(types):
LoggerModule'slog,warnanderrortake one array, the way i18next calls them (log(args)); they were typed with rest parameters, so a logger typed to spread...argsgot the array as its only argument. Loggers typed either way still compile.- fix(types):
I18nFormatModuledeclares the members i18next calls:init,parse,addLookupKeys,handleAsObjectandgetResource, all optional. It declared onlytype, so an object-literal i18n format with these members failed to compile.27.2.4
- fix(types):
BackendModule.createtakes the parameters i18next passes it: a backend withcallbackApi: truegetscreate(languages, namespace, key, fallbackValue, callback, options), one withcallbackApi: falsegetscreate(languages, namespace, key, fallbackValue, options)and may return a promise. The types declared only the first four parameters, so a required fifth or sixth parameter failed to compile and an object-literal backend could not take them at all. One rare case now fails: acreate: (...args) => other.create(...args)that forwards to acreatetyped with exactly four parameters. The doc comments ofreadandreadMultinow describe their promise form (read(language, namespace)returning the data or a promise of it), which the types already accepted.- fix(types):
getFixedT()takes its fourth parameter,{ scopeNs }, the full list of namespaces the returnedtis bound to, which selector keys use to find a namespace prefix; lookups still usens(react-i18next'suseTranslationpasses it).- fix(types): the doc comment of
saveMissingPluralssays@default true, the runtime default since the option came in 10.3.0, notfalse.27.2.3
- fix: a variable in the options of a nested
$t(key, { "name": "{{name}}" })is escaped once. With the defaultescapeValue: trueit was escaped for HTML before the options were parsed and again by the nestedt(), soTom & Jerrycame out asTom &amp; Jerry(and react-i18next'sTranshas shownTom & Jerrysince 17.1.10, withescapeValue: falsetoo). These variables are now escaped for the options' JSON, whateverescapeValueis, and the nestedt()escapes them like the values of a direct call;defaultValueandjoinArraysthere, which it does not interpolate, stay escaped once. A value with",',\or a line break no longer breaks the options, withescapeValue: falsea value can no longer inject options such aslng, and withskipOnVariablesa{{placeholder}}inside a value is no longer interpolated a second time. The warning added in 26.0.6 now covers{{- var}}in these options, the one form still inserted unescaped, instead ofescapeValue: false.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)27.1.5
- fix:
off(event, listener)removes a listener added withonce().once()registers a wrapper, sooff()with the listener itself found nothing and the listener still ran on the next event. Aonce()listener is now also removed before it runs, so one that emits the same event again (like callingchangeLanguage()fromlanguageChanged) or throws runs only once. Thanks@SudeepGowda55(#2475)27.1.4
- fix(types): with
enableSelector, assigning atfunction to a widerTFunction(TFunction<'ns'>toTFunction<'ns', string>orTFunction<Namespace>, or a key prefix to a wider one) failed with TS2590 "Expression produces a union type that is too complex to represent" once the namespaces had about 600 top-level keys together. This started in 26.3.3. Selector results for JSON arrays that mix arrays with objects or strings also keep the inner arrays as arrays. Thanks@reckter(#2474)27.1.3
- security: a language code named after a property every object inherits (
hasOwnProperty,isPrototypeOf,toLocaleString,__defineGetter__, ...) made the backend connector throwobj[k].push is not a functionwhen its load finished. A language detector passes such a code on from a request (?lng=hasOwnProperty), and with an asynchronous backend nothing caught the throw, so one request ended a Node.js server process (in a browser,init()never resolved). Now these codes load like any other unknown language. Thanks@superbot-helper(GHSA-q76c-gcvw-89x9)- fix: with an object
fallbackLng, a language code named like anObject.prototypeproperty (constructor,toString,hasOwnProperty,constructor-US) gets thedefaultfallback instead of makingt(),exists(),getFixedT()andchangeLanguage()throwfallbackCodes.forEach is not a function. Thanks@cyphercodes(#2473, #2472)
... (truncated)
Commits
4f8ce9927.2.6de03306changelog for 27.2.63a3bdfbfix: saveMissing gives a plural form without its own default the plain or "ot...87fabd7fix: preserve empty plural default values (#2480)4b6860e27.2.557ada53changelog for 27.2.570a1fb8fix(types): LoggerModule takes one array, I18nFormatModule declares the membe...7dc41f0docs: README links the docs pages directly, and docs PRs go to i18next/www7b3e42a27.2.4afeb5aachangelog for 27.2.4- Additional commits viewable in compare view
Install script changes
This version modifies prepare script that runs during installation. Review the package contents before updating.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the Security Alerts page.