Repository navigation
fix(deps): update dependency i18next to v27 - #290
Open
renovate[bot] wants to merge 2 commits into
Open
renovate[bot] wants to merge 2 commits into
renovate[bot] wants to merge 2 commits into
Conversation
|
Note renovate[bot] opened this pull request, so PR Lens left it undrawn. Comment
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
@wolfstar/plugin-api
@wolfstar/plugin-broker
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-opentelemetry
@wolfstar/plugin-scheduled-tasks
@wolfstar/plugin-sharder
@wolfstar/plugin-subcommands-advanced
commit: |
Contributor
Author
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^26.5.11→^27.1.1Release Notes
i18next/i18next (i18next)
v27.1.1Compare Source
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.0Compare Source
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.1Compare Source
cacheInBuiltFormats: true, and formats added withaddCached. The cache key holds allt()options, including the interpolated values, so every new amount, date or name added a formatter that was never released: about 50 MB per 100k values, growing without end in a long-running server. A dropped formatter is made again from the same language and options, so the output does not change. Thanks @liustack (#2467).v27.0.0Compare Source
This is a major breaking release. It changes defaults that most setups had to override, gives every instance its own logger and post-processors, refuses language codes that look like markup or paths, and removes options that were broken or had no effect. 26.7 warned in debug mode about most of the runtime changes. The migration guide has the details; to keep the v26 behavior where an option exists:
Changed defaults
fallbackLngdefaults tofalseinstead of['dev']. Without afallbackLng, i18next no longer requestsdevfrom the backend (/locales/dev/translation.jsonwith i18next-http-backend), andsaveMissingsends missing keys for the current language instead ofdev. WithsupportedLngsand nofallbackLng, an unsupported language leaveslanguageandlanguagesunset, asfallbackLng: falsealready did. SetfallbackLngto your main language, or to'dev'for the previous behavior.returnEmptyStringdefaults tofalse: an empty translation falls back like a missing value (to the fallback language, the default value or the key), asnullalready does. i18next-cli writes''for untranslated keys in the other languages, which now fall back instead of rendering blank. An explicit''default from code still counts:t('key', '')andt('key', { defaultValue: '' })return''. SetreturnEmptyString: true(ininit()and inCustomTypeOptions) if an empty translation is meant to render nothing, for example for a Locize project with "preserve empty strings" on.'EN'becomes'en'. Only the casing changes: aliases liketl,iworengstay as they are ('TL'becomes'tl'), and so do codes that are not BCP 47 (en_US,my_custom). i18next 26.7.0 and 26.7.1 warned that v27 turnsiwintoheortlintofil; that was wrong and 26.7.2 corrects it.iw,tland the like stay as they are. SetcleanCode: falseto keep codes without a region exactly as they are.cleanCodeis deprecated.strictInterpolationChecksdefaults totrue:t()needs the options for a string with variables, so a{{name}}cannot be left out of a call. Type a wrapper aroundt()withParseKeysWithoutVariables, declare the variablesinterpolation.defaultVariablesfills in withdefaultVariablesinCustomTypeOptions, or setstrictInterpolationChecks: falseto keep the v26 types (also for ICU and MF2 messages, whose arguments are required either way). The fixes below close the gap plural keys left.returnEmptyStringdefaults tofalseinTypeOptionstoo, so a key whose value is''is typed as the key.Changed behavior
use()of a logger or a post-processor on one instance no longer changes the others, and theinit()of one instance no longer rewires the logging of all of them. An instance fromcreateInstance()does not see what the defaulti18nextinstance (or any other) registered: calluse()on each instance. A clone (cloneInstance()) keeps its parent's logger and post-processors, also those its parent registers later, and what it registers itself stays its own. A plugin that callsuse()from its owninit()(the Locize InContext editor) registers right away, as before.services.loggerstays the instance's logger, withforward(). In debug mode, apostProcessname that is not registered on the instance logs a warning.returnObjectsis handled like a missing key:t()returns the default value if one is passed, else the key (withappendNamespaceToMissingKey,parseMissingKeyHandlerand the post-processors applied), instead of the sentencekey '... (en)' returned an object instead of string., which ended up in the UI. It is not saved as missing, since the key exists. The debug warning stays, andreturnedObjectHandlerstill decides what is returned when it is set (returnedObjectHandler: (key) => `key '${key}' returned an object instead of string.`brings a sentence back).addResources()keeps every value: numbers, booleans and objects were dropped silently, only strings and arrays were added./:'$10/month'stays'$10/month'instead of'$10/month', and dates in react-i18next'sTransno longer render as17/12/2025(discussion 2199).&,<,>,"and'are still escaped, which covers HTML text and quoted attributes; a/cannot end either. Update snapshots that contain/, or pass your owninterpolation.escapeto keep escaping it.lng,changeLanguage(), a language detector orloadLanguages()that does not have the shape ofisSafeLanguageCode()(letters, digits,-,_,@and., no.., at most 128 characters) is refused unless it is configured: listed insupportedLngs, in afallbackLngthat is not a function or inpreload, or a language inresources, as given toinit().changeLanguage()continues as with an unsupported code: with the detector's next code, else the fallback language, else none (withfallbackLng: false, a code refused atinit()leaveslanguageunset);loadLanguages()skips it. WithsupportedLngs, the input is matched as before ('de-DE;q=0.9'still gives'de'), and only an unsafe match is refused, which onlynonExplicitSupportedLngscan return ('de-<x>'for a supported'de'). WithoutsupportedLngs, a detector that returned"><img src=x onerror=alert(1)>made that stringi18next.language, which apps put into<html lang>, and backends were asked to load it. BCP 47, POSIX (en_US.UTF-8@euro,sr@latin) and private-use codes (en-x-pirate) pass; to use a code with other characters (+, spaces,/), list it insupportedLngs. In debug mode a refused code logs a warning.createInstance(options)merges the defaults right away, without initializing: beforeinit(),instance.optionshas the defaults,getFixedT()no longer throws (t()returns''untilinit()), anddebug: truealready shows the warnings beforeinit().init()still tells the options you set from the defaults, so akeySeparatorornsSeparatorpassed tocreateInstance()counts as set by you (#2426).loadNamespaces()beforeinit()does nothing and calls back, as it did for an instance without options.keySeparator: falsemeans flat keys only: a lookup no longer splits a key at the textfalse(t('nestedfalsec')returned the value ofnested.c), and a selector path is joined with.like a key prefix, so selectors work on the flat keys ($ => $['a.b']and$ => $.a.blook up the flat key'a.b';$ => $.nested.cno longer resolvesnested, thenc). types: withkeySeparator: falseinCustomTypeOptions, the keys are the flat keys (nonestedfalseckeys), a key containingfalseis no longer split, andkeyPrefixtakes the parts of the flat keys before a., which is howgetFixedT()joins it ('nested'for'nested.c'). A key prefix combined with selectors is not typed for flat keys.Removed
getResource('en.translation.key'),addResource('en.translation.key', value)andaddResourceBundle('en.translation', resources). Pass language, namespace and key as separate arguments;addResource(),addResources()andaddResourceBundle()throw aTypeErrorfor the dotted form. A language code with a.(de_DE.UTF-8) is now a language like any other.interpolation.prefixEscaped,suffixEscaped,nestingPrefixEscapedandnestingSuffixEscaped, which were inserted into the RegExp unescaped. Pass the literal delimiters asprefix,suffix,nestingPrefixandnestingSuffix.compatibilityJSON(it had no effect since v24).locizeLastUsedis declared by locize-lastused (5.1.0 and later).ReactOptionsstays importable from'i18next'but is empty: react-i18next fills it in (17.1.13 and later, and 18), so thereactoptions are checked when react-i18next is in the program._and$helpers intypescript/t.d.tsandtypescript/options.d.ts($FirstNamespace,_ValueOfand 84 more) are no longer importable; every declaration of those files counted as exported. The other types of those files (TOptionsBase,TFunctionSignature,ParseTReturn, ...) are now exported on purpose. If you imported one of the hidden helpers, please open an issue: exporting it again does not break anything.index.js, a CommonJS shim that theexportsmap made unreachable.Support
engines); CI tests 22, 24 and 26.defaults, which moved with every update of the browser data. The output is the same as 26.7's.^5 || ^6 || ^7, unchanged.Kept
callbackApistill work; i18next guesses their calling convention from the number of parameters and logs a deprecation warning in debug mode.isInitialized,initializedStoreOnceandinitializedLanguageOncestay writable, so react-i18next 17'suseSSRand next-i18next's Pages Router work with 27. Writing them is deprecated: callhydrate().services.backendConnector.backendstays readable.Type fixes for
strictInterpolationChecksstrictInterpolationChecks, a plural key no longer switches the check off. Withoutcounta plural key likeitem(item_one,item_other) has no value of its own, and thestringit resolved to hid the variables of every other key in a union:(key: 'greeting' | 'item') => t(key)and(key: ParseKeys<'ns'>) => t(key)compiled as soon as the namespace had a plural key, while the same wrapper without one failed. Now such a call is checked against the plural forms, ordinal ones and'ns:item'keys included:t('item')needscountwhen the forms use it, and a wrapper over a union with a plural key fails as it does without one. To migrate, passcount, or type the wrapper withParseKeysWithoutVariables.strictInterpolationChecks, a call with options needs the variables of a plural key's forms too:t('item', { defaultValue: 'x' })and(key: 'plain' | 'item') => t(key, { defaultValue: 'x' })needcountwhen the forms use it, ast('item')does. Before, any options object turned the check off for a plural key withoutcount. Without the flag the options types are unchanged.ParseKeysWithoutVariablesleaves out a key whose ordinal forms takecount, and keeps a key that has its own value next to its plural forms, sincet()returns that value withoutcount.t('ns:item')for a plural key withoutcountreturnsstring, ast('item')does, instead ofnever.v26.7.2Compare Source
'iw'into'he'or'tl'into'fil'and asked you to rename them. v27 only gives such codes their canonical casing ('EN'becomes'en','IW'becomes'iw'), soiw,tl,engand similar codes stay as they are. If you renamed them because of that warning, you can keep or restore the old codes. The warning now only appears when the casing changes.v26.7.1Compare Source
reloadResources()retries the bundles that failed to load. The load queue skipped them also when reloading, so a language whose first load failed (a backend or network outage at startup) stayed missing. i18next-http-backend 4.0.8, i18next-chained-backend 5.0.7 and i18next-locize-backend 10.0.5 reload throughreloadResources()with i18next 26.7, so theirreloadIntervalno longer recovered from such a failure, as their own reload did before.reloadResources()without languages reloads the current languages and every language the backend loaded or tried to load, for the instance and its clones, as the API docs describe ("pass languages and namespaces if you don't want to reload all"). It reloaded only the current languages, so on a server (one clone per request with i18next-http-middleware) a backend'sreloadIntervalnever refreshed the languages loaded for requests. It never requestscimode. With languages given, nothing changes.v26.7.0Compare Source
The last 26.x minor before v27, which follows in about a week. It adds the APIs v27 builds on, and with
debug: trueit warns wherever a setup relies on something v27 changes. Most of the v27 defaults are existing options, so you can try them now:The other v27 changes (
/no longer escaped in values, a logger and post-processors per instance, the key instead of a sentence for an object hit, the dotted-language store calls and*Escapedoptions removed) have no switch; the debug warnings below show where they apply.skipOnVariables: true, a missing interpolation variable is now logged in debug mode, once per string and variable:missed to pass in variable name for interpolating Hello {{name}}. The raw{{name}}reached the UI without any log line, even withdebug: true, because the warning only ran withskipOnVariables: false. A variable passed asundefinedand amissingInterpolationHandlerstill log nothing.i18next.hydrate(resources, lng)puts resources rendered on the server into the store and changes to the server's language, each only the first time. It does what react-i18next'suseSSRdid by writingresourceStore.data,options.ns,isInitialized,initializedStoreOnceandinitializedLanguageOncedirectly, and sets the same flags, so integrations can switch to it and stay compatible with code that still reads or writes them. On a clone it does nothing, asuseSSRdoes: a clone shares its parent's store (one clone per request with i18next-http-middleware). Called beforeinit(), it logs a warning and changes nothing.services.utils.reloadResources()lets a backend reload its bundles through i18next (asi18next.reloadResources(), with retries and theloadedevent), instead of callingbackendConnector.read()andloaded()itself as thereloadIntervalof i18next-http-backend and i18next-chained-backend does. Without languages (nolng, no detector, the defaultfallbackLng),reloadResources()reloads nothing instead of throwingCannot read properties of undefined (reading 'forEach'); a backend that also reloadspreloadpasses its languages.callbackApi(an instance or static property).true:read(language, namespace, callback),create(languages, namespace, key, fallbackValue, callback, options)anddetect(callback);false: they return a promise or a value, andcreategets the options as its fifth argument. Without it, i18next keeps guessing from the number of parameters (Function.length), which default and rest parameters change: i18next-chained-backend'screate(..., clb = () => {}, opts = {})has length 4 and never got its options (isUpdate), and i18next-http-backend's callback form ofcreatehas length 5, the length reserved for the callback-less form. Guessing is deprecated: in debug mode an unmarked backend or async detector logs a deprecation warning, once perinit().isSafeLanguageCode(code)is exported for plugins that take a language from a request, a URL or storage: letters, digits,-,_,@and.(no..), at most 128 characters, not a prototype key. It is not a BCP 47 check, soen_US,zh_Hant_TW,sr@latinandde_DE.UTF-8pass; markup, slashes and spaces do not. The language detector, i18next-http-middleware and i18next-http-backend each have their own rule today.use()logs a warning in debug mode when a second backend, language detector,i18nFormator formatter replaces the first one; only one of each is used per instance, and losing an ICU setup this way was silent. Asuse()usually runs beforeinit(), the warning is printed onceinit()has set up the logger.ParseKeysWithoutVariables<Ns, KPrefix>, the keyst()takes without options: their string has no variables, and a plural key is left out when its forms takecount. A wrapper typed with it, like(key: ParseKeysWithoutVariables<'common'>) => t(key), compiles withstrictInterpolationCheckswithout a cast.defaultVariablesinCustomTypeOptionsdeclares the variablesinterpolation.defaultVariablesfills in at runtime (defaultVariables: { appName: string }). They become optional in thet()options, also withstrictInterpolationChecks; passed, they keep their type.interpolationFormatSeparatorinCustomTypeOptionsfor a custominterpolation.formatSeparator: the types split{{price, currency}}at a hard-coded,, so withformatSeparator: ';'the format was not recognized. The per-callskipInterpolationoption is typed, andreturnedObjectHandlermay return a value (what it returns is whatt()returns; it was typed as returningvoid).SelectorFn,ApplyTarget,ConstrainTargetandGetSourceare exported on purpose, under their current names. react-i18next imports them forTrans; they were importable only because every declaration in the type files counts as exported.nsSeparator: falseinCustomTypeOptions, the key union no longer containsnsfalsekey-style keys for the other namespaces, and a key that contains the textfalse(isfalsey) is no longer split at it, which typed itst()result asnever.saveMissingnow checks that the namespace is loaded for the instance that misses the key. EachcloneInstance()pointed the parent'sservices.utils.hasLoadedNamespaceat the new clone, and the backend connector, which all clones share, used that one: a key missing in one request was not saved (did not save key ... as the namespace ... was not yet loaded) while a newer request was still loading its language, and the parent'sservices.utilsanswered for the newest clone. A clone'sservices.utilsis now bound to the clone, and the parent keeps its own. A directservices.backendConnector.saveMissing()call, like the missing keys route of i18next-http-middleware, still checks the newest clone (follow-up to #1413).dir()without a language (beforeinit(), or with no language resolved) returns'ltr'instead of'rtl'(discussion #2135).t()beforeinit()returns an empty string, as typed (with a warning when debug logging is already on); it returnedundefined.off('a b', listener)removes the listener from both events, ason('a b', listener)adds it to both. It looked for an event named'a b', soonce('a b', listener)never removed its listener and ran it on every event.getResource('en.translation.key'),addResource('en.translation.key', value),addResourceBundle('en.translation', resources)) log a deprecation warning in debug mode; they are removed in v27. Pass language, namespace and key as separate arguments.interpolation.prefixEscaped,suffixEscaped,nestingPrefixEscapedandnestingSuffixEscaped(inserted into the RegExp unescaped) log a deprecation warning in debug mode and are marked@deprecated; they are removed in v27. Pass the literal delimiters asprefix,suffix,nestingPrefixandnestingSuffix.compatibilityJSONis marked@deprecated(it has no effect since v24) and removed from the types in v27.'EN'stays'EN'today and becomes'en'in v27,'iw'becomes'he'.cleanCode: truealready lower-cases them.fallbackLngis not set, the first request for the default fallback languagedev(loading it, or saving missing keys to it) logs a notice in debug mode: v27 defaults tofallbackLng: falseand no longer requestsdev. SetfallbackLngto your source language, or to'dev'to keep the current behavior.lng,changeLanguage()or the language detector, is not configured (supportedLngs,fallbackLng,preloador the resources) and failsisSafeLanguageCodelogs a deprecation warning, once per code: withoutsupportedLngs, a detector that returns"><img src=x onerror=alert(1)>makes that stringi18next.language, and apps put it into<html lang>. Nothing changes in 26.7; v27 is planned to refuse such codes and continue as with an unsupported code. Language codes are still not bound to a format.use()logs a deprecation warning (calluse()on this instance too), and a non-cloneinit()that replaces the logger another instance set withuse()logs one through that logger./under the default escape logs that v27 no longer escapes/($10/monthrenders as$10/monthtoday; not withescapeValue: false, where react-i18next'sTransescapes one call itself and decodes the entities afterwards), and an object or array hit withoutreturnObjectslogs that v27 returns the key instead of the sentencekey '... (en)' returned an object instead of string..fileswhitelist instead of.npmignore, which had to mirror every local or secret file by hand. The tarball is unchanged. The rooti18next.jsandi18next.min.js(copies ofdist/umd/, still published for the unversioned unpkg URLs) are built bynpm run buildand no longer tracked in git.v26.6.0Compare Source
strictInterpolationCheckstype option (defaultfalse). WithstrictInterpolationChecks: trueinCustomTypeOptions,t()needs its options for a string with{{variables}}: for'Hello {{name}}!',t('greeting')is a type error andt('greeting', { name })compiles. Left out, the variable reaches the UI as the raw{{name}}placeholder. This applies to string keys, selectors, selector arrays andgetFixedT, and withstrictKeyChecksalso tot(key, defaultValue). Without the flag nothing changes. With the flag on, a wrapper that passes on a key type ((key: ParseKeys<'ns'>) => t(key), or a genericK extends ParseKeys) no longer compiles without options, as the variables of its string are not known there.parseInterpolation: 'icu'and'mf2'require their arguments as before. Thanks @Alex0007 (#2465).count, as a single selector does since v25.9.0. Withoutcount, i18next skips the plural member at runtime, sot([($) => $.item, ($) => $.plain])returned theplainvalue while typed as the plural forms. An array of selectors withdefaultValuenow returns the literal values and the default value ('a' | 'b' | 'x') instead ofstring. Thanks @Alex0007 (#2465).Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.