diff --git a/demo/trunk/node_modules/.yarn-integrity b/demo/trunk/node_modules/.yarn-integrity index f22c54ab..bc508085 100644 --- a/demo/trunk/node_modules/.yarn-integrity +++ b/demo/trunk/node_modules/.yarn-integrity @@ -20,7 +20,7 @@ "grunt@^1.4.0", "i18next-browser-languagedetector@~8.0.0", "i18next-http-backend@~2.6.0", - "i18next@~23.14.0", + "i18next@~23.15.1", "jquery@3.4.1" ], "lockfileEntries": { @@ -173,7 +173,7 @@ "http2-wrapper@^2.2.1": "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-2.2.1.tgz#310968153dcdedb160d8b72114363ef5fce1f64a", "i18next-browser-languagedetector@~8.0.0": "https://registry.yarnpkg.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-8.0.0.tgz#b6fdd9b43af67c47f2c26c9ba27710a1eaf31e2f", "i18next-http-backend@~2.6.0": "https://registry.yarnpkg.com/i18next-http-backend/-/i18next-http-backend-2.6.1.tgz#186c3a1359e10245c9119a13129f9b5bf328c9a7", - "i18next@~23.14.0": "https://registry.yarnpkg.com/i18next/-/i18next-23.14.0.tgz#d415a858390cc849f3db0df539cb2bbfe24a3cdb", + "i18next@~23.15.1": "https://registry.yarnpkg.com/i18next/-/i18next-23.15.1.tgz#c50de337bf12ca5195e697cc0fbe5f32304871d9", "iconv-lite@~0.6.3": "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501", "ignore@^5.2.0": "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324", "immediate@~3.0.5": "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b", diff --git a/demo/trunk/node_modules/i18next/dist/esm/package.json b/demo/trunk/node_modules/i18next/dist/esm/package.json index 98ff6ca5..e996ca8e 100644 --- a/demo/trunk/node_modules/i18next/dist/esm/package.json +++ b/demo/trunk/node_modules/i18next/dist/esm/package.json @@ -1 +1 @@ -{"type":"module","version":"23.14.0"} +{"type":"module","version":"23.15.1"} diff --git a/demo/trunk/node_modules/i18next/package.json b/demo/trunk/node_modules/i18next/package.json index 9d423367..9e68509a 100644 --- a/demo/trunk/node_modules/i18next/package.json +++ b/demo/trunk/node_modules/i18next/package.json @@ -1,6 +1,6 @@ { "name": "i18next", - "version": "23.14.0", + "version": "23.15.1", "description": "i18next internationalization framework", "main": "./dist/cjs/i18next.js", "module": "./dist/esm/i18next.js", diff --git a/demo/trunk/node_modules/i18next/typescript/helpers.d.ts b/demo/trunk/node_modules/i18next/typescript/helpers.d.ts index 98f820dc..0ebaf804 100644 --- a/demo/trunk/node_modules/i18next/typescript/helpers.d.ts +++ b/demo/trunk/node_modules/i18next/typescript/helpers.d.ts @@ -58,3 +58,11 @@ type $StringKeyPathToRecordUnion< export type $StringKeyPathToRecord = $UnionToIntersection< $StringKeyPathToRecordUnion >; + +/** + * We could use NoInfer typescript build-in utility, + * however this project still supports ts < 5.4. + * + * @see https://github.com/millsp/ts-toolbelt/blob/master/sources/Function/NoInfer.ts + */ +export type $NoInfer = [A][A extends any ? 0 : never]; diff --git a/demo/trunk/node_modules/i18next/typescript/options.d.ts b/demo/trunk/node_modules/i18next/typescript/options.d.ts index f1646edd..92a082da 100644 --- a/demo/trunk/node_modules/i18next/typescript/options.d.ts +++ b/demo/trunk/node_modules/i18next/typescript/options.d.ts @@ -106,6 +106,16 @@ export type TypeOptions = $MergeBy< * Suffix for interpolation */ interpolationSuffix: '}}'; + + /** + * Prefix for unescaped interpolation + */ + unescapePrefix: '-'; + + /** + * Suffix for unescaped interpolation + */ + unescapeSuffix: ''; }, CustomTypeOptions >; diff --git a/demo/trunk/node_modules/i18next/typescript/t.d.ts b/demo/trunk/node_modules/i18next/typescript/t.d.ts index 6b02eea3..8242c4a1 100644 --- a/demo/trunk/node_modules/i18next/typescript/t.d.ts +++ b/demo/trunk/node_modules/i18next/typescript/t.d.ts @@ -4,6 +4,7 @@ import type { $Dictionary, $SpecialObject, $StringKeyPathToRecord, + $NoInfer, } from './helpers.js'; import type { TypeOptions, @@ -29,6 +30,8 @@ type _Resources = TypeOptions['resources']; type _JSONFormat = TypeOptions['jsonFormat']; type _InterpolationPrefix = TypeOptions['interpolationPrefix']; type _InterpolationSuffix = TypeOptions['interpolationSuffix']; +type _UnescapePrefix = TypeOptions['unescapePrefix']; +type _UnescapeSuffix = TypeOptions['unescapeSuffix']; type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true; type $ValueIfResourcesDefined = $IsResourcesDefined extends true @@ -53,6 +56,14 @@ type WithOrWithoutPlural = _JSONFormat extends 'v4' | 'v3' type JoinKeys = `${K1 & string}${_KeySeparator}${K2 & string}`; type AppendNamespace = `${Ns & string}${_NsSeparator}${Keys & string}`; +type TrimSpaces = T extends `${infer Char}${infer Rest}` + ? Char extends ' ' + ? TrimSpaces + : TrimSpaces + : T extends '' + ? Acc + : never; + /** **************************************************** * Build all keys and key prefixes based on Resources * ***************************************************** */ @@ -141,10 +152,16 @@ export type ParseKeys< /** ******************************************************* * Parse t function return type and interpolation values * ******************************************************** */ +type ParseActualValue = Ret extends `${_UnescapePrefix}${infer ActualValue}${_UnescapeSuffix}` + ? TrimSpaces + : Ret; + type ParseInterpolationValues = Ret extends `${string}${_InterpolationPrefix}${infer Value}${_InterpolationSuffix}${infer Rest}` ? - | (Value extends `${infer ActualValue},${string}` ? ActualValue : Value) + | (Value extends `${infer ActualValue},${string}` + ? ParseActualValue + : ParseActualValue) | ParseInterpolationValues : never; @@ -244,6 +261,12 @@ export type TFunctionDetailedResult = { usedParams: InterpolationMap & { count?: TOpt['count'] }; }; +type TFunctionProcessReturnValue = Ret extends string | $SpecialObject | null + ? Ret + : [DefaultValue] extends [never] + ? Ret + : DefaultValue; + type TFunctionReturnOptionalDetails = TOpt['returnDetails'] extends true ? TFunctionDetailedResult : Ret; @@ -262,12 +285,13 @@ export interface TFunction, TOpt>, const ActualOptions extends TOpt & InterpolationMap = TOpt & InterpolationMap, + DefaultValue extends string = never, >( ...args: | [key: Key | Key[], options?: ActualOptions] - | [key: string | string[], options: TOpt & $Dictionary & { defaultValue: string }] - | [key: string | string[], defaultValue: string, options?: TOpt & $Dictionary] - ): TFunctionReturnOptionalDetails; + | [key: string | string[], options: TOpt & $Dictionary & { defaultValue: DefaultValue }] + | [key: string | string[], defaultValue: DefaultValue, options?: TOpt & $Dictionary] + ): TFunctionReturnOptionalDetails, DefaultValue>, TOpt>; } export type KeyPrefix = ResourceKeys[$FirstNamespace] | undefined; diff --git a/demo/trunk/node_modules/i18next/typescript/t.v4.d.ts b/demo/trunk/node_modules/i18next/typescript/t.v4.d.ts index ec58cbd1..77a4790e 100644 --- a/demo/trunk/node_modules/i18next/typescript/t.v4.d.ts +++ b/demo/trunk/node_modules/i18next/typescript/t.v4.d.ts @@ -29,6 +29,8 @@ type _Resources = TypeOptions['resources']; type _JSONFormat = TypeOptions['jsonFormat']; type _InterpolationPrefix = TypeOptions['interpolationPrefix']; type _InterpolationSuffix = TypeOptions['interpolationSuffix']; +type _UnescapePrefix = TypeOptions['unescapePrefix']; +type _UnescapeSuffix = TypeOptions['unescapeSuffix']; type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true; type $ValueIfResourcesDefined = $IsResourcesDefined extends true @@ -53,6 +55,14 @@ type WithOrWithoutPlural = _JSONFormat extends 'v4' | 'v3' type JoinKeys = `${K1 & string}${_KeySeparator}${K2 & string}`; type AppendNamespace = `${Ns & string}${_NsSeparator}${Keys & string}`; +type TrimSpaces = T extends `${infer Char}${infer Rest}` + ? Char extends ' ' + ? TrimSpaces + : TrimSpaces + : T extends '' + ? Acc + : never; + /** **************************************************** * Build all keys and key prefixes based on Resources * ***************************************************** */ @@ -140,10 +150,16 @@ export type ParseKeys< /** ******************************************************* * Parse t function return type and interpolation values * ******************************************************** */ +type ParseActualValue = Ret extends `${_UnescapePrefix}${infer ActualValue}${_UnescapeSuffix}` + ? TrimSpaces + : Ret; + type ParseInterpolationValues = Ret extends `${string}${_InterpolationPrefix}${infer Value}${_InterpolationSuffix}${infer Rest}` ? - | (Value extends `${infer ActualValue},${string}` ? ActualValue : Value) + | (Value extends `${infer ActualValue},${string}` + ? ParseActualValue + : ParseActualValue) | ParseInterpolationValues : never; diff --git a/demo/trunk/package.json b/demo/trunk/package.json index 7986eeb1..31a050f6 100644 --- a/demo/trunk/package.json +++ b/demo/trunk/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "dwv": "0.33.1", - "i18next": "~23.14.0", + "i18next": "~23.15.1", "i18next-browser-languagedetector": "~8.0.0", "i18next-http-backend": "~2.6.0", "jquery": "3.4.1" diff --git a/demo/trunk/yarn.lock b/demo/trunk/yarn.lock index 00da1c33..bd774700 100644 --- a/demo/trunk/yarn.lock +++ b/demo/trunk/yarn.lock @@ -994,10 +994,10 @@ i18next-http-backend@~2.6.0: dependencies: cross-fetch "4.0.0" -i18next@~23.14.0: - version "23.14.0" - resolved "https://registry.yarnpkg.com/i18next/-/i18next-23.14.0.tgz#d415a858390cc849f3db0df539cb2bbfe24a3cdb" - integrity sha512-Y5GL4OdA8IU2geRrt2+Uc1iIhsjICdHZzT9tNwQ3TVqdNzgxHToGCKf/TPRP80vTCAP6svg2WbbJL+Gx5MFQVA== +i18next@~23.15.1: + version "23.15.1" + resolved "https://registry.yarnpkg.com/i18next/-/i18next-23.15.1.tgz#c50de337bf12ca5195e697cc0fbe5f32304871d9" + integrity sha512-wB4abZ3uK7EWodYisHl/asf8UYEhrI/vj/8aoSsrj/ZDxj4/UXPOa1KvFt1Fq5hkUHquNqwFlDprmjZ8iySgYA== dependencies: "@babel/runtime" "^7.23.2"