v26.6.0
Added 1
- Added a new strictInterpolationChecks type option (default false) that requires options for translation strings containing {{variables}} when set to true in CustomTypeOptions
Changed 2
- With strictInterpolationChecks enabled, t() calls for strings with interpolation variables without options are type errors, applying to string keys, selectors, selector arrays, getFixedT, and to t(key, defaultValue) when strictKeyChecks is also enabled
- With strictInterpolationChecks enabled, wrappers that pass a generic key type without options no longer compile because the interpolation variables of the string are not known there
Fixed 2
- An array of selectors with a plural member now requires count, matching the behaviour of a single selector since v25.9.0, because i18next skips the plural member at runtime when count is missing behavior changed · inferred, marked in the notes below
- An array of selectors with defaultValue now returns the literal values and the default value as the type ('a' | 'b' | 'x') instead of string
1 change to check, marked in the notes below
From i18next
- feat(types): new
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). - fix(types): an array of selectors with a plural member now requires
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). behavior changed · inferred