Repository navigation
chore(deps): update i18next packages - #162
Merged
Merged
Conversation
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.2→26.5.118.2.1→8.2.317.1.0→17.1.9Release Notes
i18next/i18next (i18next)
v26.5.11Compare Source
false,0or''is now returned when a flat key with the same dotted name also exists. With{ a: { b: false }, 'a.b': 'flat' },getResource('en', 'translation', 'a.b')andt('a.b')returned'flat': the nested result was checked for truthiness, so these present values fell through to the flat-key lookup. Without such a flat key they were already returned. A nestednull, which is not a valid lookup by default (returnNull: false), still falls back to the flat key. Thanks @lprnmns (#2461).v26.5.10Compare Source
supportedLngs, the best match no longer picks a different language whose code only starts with the same letters. The last fuzzy check took any supported code starting with the language part, so withsupportedLngs: ['en', 'fil-PH']a Finnish user (fi-FI) got Filipino instead of the fallback language, andha(Hausa) pickedhaw-US(Hawaiian). Other regions of the same language still match as before (de-CH→de-DE,pt-PT→pt-BR,fil→fil-PH). Compatibility note: a two-letter code no longer matches a supported three-letter code that extends it, likear→arz-EG,sw→swh-KEorno→nob-NO; list the two-letter code insupportedLngs(or map it withfallbackLng) if you relied on that. Thanks @Pharex38 (#2460).v26.5.9Compare Source
constructor,toStringormap. Only the top level was guarded, so{{constructor}}was treated as missing, but{{user.constructor}}rendered the function source (with a class instance, the full source code of the class), and{{user.toString}},{{items.map}}or a class method like{{user.greet}}did the same. The same lookup is used for translation keys whenignoreJSONStructureis on (the default): a nested key named like an inherited method that is missing in the current language (t('roles.constructor')withroles.constructoronly in the fallback language) returnedfunction Object() { [native code] }instead of falling back, andexists('roles.valueOf')returnedtrue. These keys are now missing, so the fallback language,missingInterpolationHandler,saveMissingand the missing key handler apply as for any other missing key. Getters defined on a class ({{user.fullName}}withget fullName()) still work. Nested lookups also no longer walk into the prototype via__proto__, so{{user.__proto__.constructor}}no longer prints the class source either. Thanks @Pharex38 (#2459).v26.5.8Compare Source
joinArraysnow get the same resolved details as strings. The joined value was extended withlastKeyin the place of the resolved lookup, so withpostProcessPassResolveda post processor got nousedLng,usedNSorexactUsedKey(t('steps', { joinArrays: ' / ' })reportedundefined/undefined:undefined). This affected the subliminal post processor used by the locize InContext editor, which could not map a joined array to its key. The nesting recursion guard did not get the parent key either, so arrays that nest each other (listA: ['a', '$t(listB)'],listB: ['b', '$t(listA)']) threwMaximum call stack size exceeded. They now stop at the guard, as strings do. Ani18nFormatplugin withhandleAsObjectandparsealso no longer throwsCannot read properties of undefined (reading 'usedNS')on joined arrays. Thanks @nk-batman21 (#2458).v26.5.7Compare Source
cacheInBuiltFormats: true, built-in formats now also work when thet()options contain a BigInt or a circular object. The cache key was built withJSON.stringifyover all options, including the interpolation values, which throws on those, so every built-in format in that call returned the raw value:t('num', { val: 12345678901234567890n })with'Total: {{val, number}}'returned'Total: 12345678901234567890'instead of'Total: 12,345,678,901,234,567,890', and passing an object with a back-reference (like an ORM entity) left all numbers, dates and lists of that call unformatted. When the key cannot be built, the value is now formatted without the cache, as withcacheInBuiltFormats: false. This also applies to formatters added withaddCached. Other calls still use the cache as before. Thanks @nk-batman21 (#2457).v26.5.6Compare Source
cloneInstance({ forkResourceStore: true })now copies the resources at every level. It copied them only down to the namespace objects, so nested keys and arrays stayed shared with the original instance:addResource()with a nested key (fork.addResource('en', 'translation', 'greeting.hello', 'Hi')) or a deepaddResourceBundle()on the fork also changed the original instance and every other fork. Flat keys were already isolated. Forking a large store takes a bit longer: with 300k keys in nested groups, about 11 ms instead of 3 ms per fork. Clones withoutforkResourceStorestill share the store as before. Thanks @nk-batman21 (#2456, follow-up to #2270).v26.5.5Compare Source
skipOnVariables: true, a{{placeholder}}inside a value inserted with an unescaped{{- var}}now stays literal, as it already did for{{var}}. The escape pass ran after the unescaped values were written and scanned them again, sot('{{- a}}', { a: '{{b}}', b: 'c' })returned'c'instead of'{{b}}'. With pre-built HTML that carries user text, liket('You may contact {{name}} at {{- emailHTML}}.', { name, emailHTML }), that text could pull another variable of the samet()call into the output. Results withskipOnVariables: false, and values without placeholders, are unchanged. Compatibility note: a{{- var}}value whose placeholders were meant to be filled from the samet()call now keeps them literally;skipOnVariables: falserestores the old behavior. Thanks @nk-batman21 (#2455, reported in #1595).v26.5.4Compare Source
skipOnVariables: true, a{{placeholder}}inside an interpolated value now stays literal also when the same placeholder appears later in the translation. Each value was written withString.replace, which replaces the first copy of the placeholder text, and that could be the copy inside an earlier value:t('{{name}} has {{count}} items', { name: '{{count}}', count: 5 })returned'5 has {{count}} items'instead of'{{count}} has 5 items'. The value is now written at the position of the matched placeholder. Results withskipOnVariables: falseare unchanged. Thanks @nk-batman21 (#2454, reported in #1595).useRawValueToEscape: true, a non-string value in an unescaped{{- var}}placeholder or withescapeValue: falseno longer throwsval.replace is not a function; it is converted to a string like any other value.v26.5.3Compare Source
countalso when the call passes an explicitns.t(($) => $.item)already failed withoutcount, butt(($) => $.item, { ns: 'items' })compiled, although at runtime it looks upiteminstead ofitem_one/item_otherand returns the key. It now fails the same way, also withordinal: true,defaultValue, annsarray, a key prefix andi18n.t. Calls withcount,context,returnObjects: trueand arrays of selectors, as well as return types, are unchanged. Thanks @nyarthan (#2452).i18next/i18next-browser-languageDetector (i18next-browser-languagedetector)
v8.2.3Compare Source
pt-BR.site.com,zh-Hans-CN.site.com,es-419.site.comandsr-Latn.site.comare detected aspt-BR,zh-Hans-CN,es-419andsr-Latn. The pattern only accepted 2 to 5 word characters, without hyphens. Other subdomains likestagingor preview deployment labels (myapp-git-branch-team.vercel.app) are still not taken for a language, and everything detected before is still detected. Thanks @lprnmns 328v8.2.2Compare Source
/es-419/and#/es-419are detected ases-419instead ofes-(which i18next resolved toes). Segments that start with a digit (/2024/) still yield no language, andlookupFromPathIndex/lookupFromHashIndexpoint at the same segments as before. Thanks @nk-batman21 327i18next/react-i18next (react-i18next)
v17.1.9Compare Source
nsarray are now picked up. The hook used the array itself as theuseMemodependency list, and React only compares the entries both lists have in common when its length changes, so going fromuseTranslation(['nsA'])touseTranslation(['nsA', 'nsB'])kept returning['nsA']: React warned that the dependency array changed size,nsBwas never loaded, and withnsMode: 'fallback'keys only innsBrendered as the key. Removing a namespace kept the old list the same way. The namespaces are now compared by content, so a growing list loads the new namespace (suspending until it is loaded, as switching from'nsA'to'nsB'already does) andtuses it. Lists that keep their length behave as before. Thanks @lprnmns (#1945).v17.1.8Compare Source
formatis no longer dropped.Transreadsformatin an interpolation object as the formatter name ({{ value, format }}), so with{{ format }}as the only key nothing was left:<Trans>Export as {{ format }}</Trans>warnedTRANS_INVALID_OBJand used the default stringExport asinstead ofExport as {{format}}. Whenformatis the object's only key it is now treated as the variable.{{ value, format }}works as before. Without ani18nKey, the key derived from the children changes accordingly, fromExport astoExport as {{format}}. i18next-cli serializesTranschildren with react-i18next, so extracting with this version produces the same key. Thanks @Pharex38 (#1944).v17.1.7Compare Source
"Write &#​169; to get &#​169;"renderedWrite © to get ©instead ofWrite &#​169; to get ©, and&#​60;rendered<instead of&#​60;. This also hit interpolated values withescapeValue: true, where a value containing&#​60;is escaped to&#​60;. Escaped named entities like&lt;already stayed<, as browsers andTransdecode them. Unknown named entities and entities above U+10FFFF still stay as written. Thanks @Pharex38 (#1943).v17.1.6Compare Source
countpassed intOptionsis now used.TransspreadtOptionsand then set its owncountprop, so a count only intOptionswas overwritten withundefined:<Trans i18nKey="items" tOptions={{ count: 5 }} />rendered the keyitemsinstead of5 items, and with childrenTranscould pick the wrong plural form. Likecontext,Transnow falls back totOptions.count, handled the same way as thecountprop. Acountprop, a count in the children orvalues.countstill take precedence, andtOptionsis not modified. Thanks @nk-batman21 (#1942).v17.1.5Compare Source
Transnow falls back to the last key when none of them has a translation, ast()does. It used the array itself asdefaultValue, which i18next handles as an object, so<Trans i18nKey={['notifications.crm_item_created', 'crm_item_created']} components={[<strong />]} />renderedkey 'crm_item_created (en)' returned an object instead of string.instead ofcrm_item_created. An array of selectors falls back to the key of the last selector. The first key that has a translation still wins, andchildren,defaultsandtOptions.defaultValueare used as before. WithsaveMissing, these calls now report the missing key, like a singlei18nKeydoes. Thanks @nk-batman21 (#1941).v17.1.4Compare Source
allowObjectInHTMLChildren, thechildrenof HTML elements now use React's own type (DOMAttributes<T>['children']) instead of theReactI18NextChildren | Iterable<ReactI18NextChildren>union. Both accept the same children, so nothing compiles differently. For default installs the globalHTMLAttributesaugmentation now repeats whatever@types/reactdeclares, so changes in React's types flow through instead of meeting a copy, and type errors on element children no longer list an extraIterable<...>. WithallowObjectInHTMLChildren: truenothing changes. First step of #1928.v17.1.3Compare Source
"Hello 👋 <0>friend</0> &#​127881;"rendered U+F44B and U+F389, private-use glyphs that usually show as a box, instead of 👋 and 🎉: the decoder usedString.fromCharCode, which keeps only the low 16 bits of the code point. This shows up with translations that a TMS or CMS exports HTML-encoded. Entities above U+10FFFF, which are no valid code points, now stay as written instead of becoming U+0000. Entities below U+10000, including surrogate pairs written as two entities, decode as before. Thanks @nk-batman21 (#1940).v17.1.2Compare Source
<Trans i18nKey="welcome">Welcome</Trans>with"Welcome <1>friend</1>"renderedWelcome e, anddefaults="Hi <1>there</1>"with the childHirenderedHi i. The fallback for a single object of components ({{ 1: <strong /> }}) looked the tag up on the string and rendered one of its characters. It now applies only when that child is an object, so{{ 1: <strong /> }}renders as before, and the tag falls back to its inner text, as it already did with several children or with a number or an element as the only child. This also stops a single-entry array child holdingnull({[null]}, e.g. from a.mapthat returnednull) from throwingCannot read properties of null. Thanks @Cayan (#1939).v17.1.1Compare Source
Transinterpolatesvalues(andcount, values intOptions, or the whole string when there are no children) before it parses the string. Withinterpolation.escapeValue: false, or with an i18nFormat plugin (i18next-icu, i18next-mf2, i18next-fluent), which inserts values without escaping whateverescapeValuesays, a value like<0 href="https://example.com">x</0>was rendered as component 0 with thathref, overriding the props of the component, and<strong>x</strong>in a value became a real<strong>.Transnow escapes the values for thist()call (with a plugin, the string values invalues) and decodes the entities after parsing, so such a value renders as text, and a"in a value no longer closes an attribute like<Item title="{{name}}" />.{{- var}}stays the explicit way for a translator to insert a value unescaped. As withshouldUnescape, entities written in these translations (for example&) are now decoded instead of shown literally. Output withescapeValue: trueand no plugin, with i18next-icuescapeVariables: true, and with children and novaluesorcountis unchanged.IcuTranswithescapeValue: falseor an i18nFormat plugin: a value like<0>x</0>no longer becomes the first component, and a value containing an entity like&is no longer decoded a second time.Configuration
📅 Schedule: (in timezone Asia/Shanghai)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR was generated by Mend Renovate. View the repository job log.