Sourced from i18next's releases.
v26.4.7
- perf:
cloneInstance()no longer inheritspreload.loadResources()adds everypreloadlanguage to each load, and clones copiedpreloadfrom the parent, so a clone'sinit()and everychangeLanguage()walked all preloaded languages × all namespaces throughqueueLoad()/hasResourceBundle(), although the parent had already loaded them into the shared store. With i18next-http-middleware (one clone +changeLanguage()per request), 25 preloaded languages and 20 namespaces, that was most of the per-request CPU: the reproduction from the issue went from ~90 µs to ~10 µs per request, the same as with a single language. A clone now only loads what it uses itself: itschangeLanguage()no longer waits for parent preload languages that are still loading (the parent's owninit()still does), andclone.loadNamespaces()loads the new namespace for the clone's language and fallbacks instead of every preloaded language.clone.loadLanguages()works as before, the parent instance is unchanged, and passingpreloadtocloneInstance()keeps the old behavior. Thanks@theMostCuriousHomunculusfor the detailed report (#2451).v26.4.6
- fix: a fallback language whose formatted code is already in the hierarchy is no longer added a second time.
toResolveHierarchy()checked the rawfallbackLngvalue against the list, but the list holds formatted codes, so any fallback written differently from its formatted form slipped through:lng: 'de-CH'withfallbackLng: 'de-ch'gavelanguages['de-CH', 'de', 'de-CH'], and the same happened withfallbackLng: 'EN'+cleanCode,lowerCaseLng, and Intl aliases (iw-IL→he-IL). Missing keys were looked up in the same language twice. Only exact duplicates are removed; the order is unchanged. Thanks@lprnmns(#2450).v26.4.5
- fix:
hasLoadedNamespace(ns, { lng })no longer staysfalseforever when the passed inlngis loaded under another code, or not at all. It checked the load state of the rawlng, butloadLanguages()stores a language under its resolved code (de-ch→de-CH,de-CH→dewithload: 'languageOnly') and skips alngoutsidesupportedLngsentirely (only the fallback gets loaded), so that state never got set. react-i18next'suseTranslation(ns, { lng })then never became ready: withuseSuspenseit kept throwing an already resolved promise and React retried forever (100% CPU, SSR never finished), without it the load effect re-rendered in a loop. It now checks the code the language is actually loaded under, and for alngoutsidesupportedLngsonly waits for the fallback, which is also whatt()resolves to. Calls withoutlngand theprecheck(react-i18next'sbindI18n: 'languageChanging') are unchanged (react-i18next#1934).
Sourced from i18next's changelog.
26.4.7
- perf:
cloneInstance()no longer inheritspreload.loadResources()adds everypreloadlanguage to each load, and clones copiedpreloadfrom the parent, so a clone'sinit()and everychangeLanguage()walked all preloaded languages × all namespaces throughqueueLoad()/hasResourceBundle(), although the parent had already loaded them into the shared store. With i18next-http-middleware (one clone +changeLanguage()per request), 25 preloaded languages and 20 namespaces, that was most of the per-request CPU: the reproduction from the issue went from ~90 µs to ~10 µs per request, the same as with a single language. A clone now only loads what it uses itself: itschangeLanguage()no longer waits for parent preload languages that are still loading (the parent's owninit()still does), andclone.loadNamespaces()loads the new namespace for the clone's language and fallbacks instead of every preloaded language.clone.loadLanguages()works as before, the parent instance is unchanged, and passingpreloadtocloneInstance()keeps the old behavior. Thanks@theMostCuriousHomunculusfor the detailed report (#2451).26.4.6
- fix: a fallback language whose formatted code is already in the hierarchy is no longer added a second time.
toResolveHierarchy()checked the rawfallbackLngvalue against the list, but the list holds formatted codes, so any fallback written differently from its formatted form slipped through:lng: 'de-CH'withfallbackLng: 'de-ch'gavelanguages['de-CH', 'de', 'de-CH'], and the same happened withfallbackLng: 'EN'+cleanCode,lowerCaseLng, and Intl aliases (iw-IL→he-IL). Missing keys were looked up in the same language twice. Only exact duplicates are removed; the order is unchanged. Thanks@lprnmns(#2450).26.4.5
- fix:
hasLoadedNamespace(ns, { lng })no longer staysfalseforever when the passed inlngis loaded under another code, or not at all. It checked the load state of the rawlng, butloadLanguages()stores a language under its resolved code (de-ch→de-CH,de-CH→dewithload: 'languageOnly') and skips alngoutsidesupportedLngsentirely (only the fallback gets loaded), so that state never got set. react-i18next'suseTranslation(ns, { lng })then never became ready: withuseSuspenseit kept throwing an already resolved promise and React retried forever (100% CPU, SSR never finished), without it the load effect re-rendered in a loop. It now checks the code the language is actually loaded under, and for alngoutsidesupportedLngsonly waits for the fallback, which is also whatt()resolves to. Calls withoutlngand theprecheck(react-i18next'sbindI18n: 'languageChanging') are unchanged (react-i18next#1934).
5546d21
26.4.7f27c937
build50ecc22
perf: clones no longer inherit preload, so changeLanguage on a clone
doesn't ...bc951ab
26.4.645d0aba
changelog + build for 26.4.60458efc
fix: don't repeat a fallback language that differs only in casing (#2450)ce7b9cf
26.4.54d4c607
build8f8651e
fix: hasLoadedNamespace with a passed in lng checks the code it is
actually l...15d0b9d
changelog: link GHSA-5jr9-983r-c8x4 in v26.4.4