@intlayer/i18next 9.9.3-canary.1 → 9.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -70,7 +70,7 @@ const createInstance = (instanceOptions = {}) => {
|
|
|
70
70
|
const resolved = resolveTranslation(getResolveParams(lang, ns, key, options));
|
|
71
71
|
if (resolved !== void 0) return resolved;
|
|
72
72
|
const defaultValue = options?.defaultValue;
|
|
73
|
-
if (typeof defaultValue === "string") return resolveMessageNodeToString(defaultValue, getInterpolationValues(options, getEscapeValue()), lang);
|
|
73
|
+
if (typeof defaultValue === "string") return resolveMessageNodeToString(defaultValue, getInterpolationValues(options, getEscapeValue()), lang, void 0, "double-brace");
|
|
74
74
|
return key;
|
|
75
75
|
};
|
|
76
76
|
const instance = {
|
|
@@ -118,7 +118,7 @@ const createInstance = (instanceOptions = {}) => {
|
|
|
118
118
|
if (result !== void 0) return result;
|
|
119
119
|
}
|
|
120
120
|
const defaultValue = options?.defaultValue;
|
|
121
|
-
if (typeof defaultValue === "string") return resolveMessageNodeToString(defaultValue, getInterpolationValues(options, getEscapeValue()), currentLanguage);
|
|
121
|
+
if (typeof defaultValue === "string") return resolveMessageNodeToString(defaultValue, getInterpolationValues(options, getEscapeValue()), currentLanguage, void 0, "double-brace");
|
|
122
122
|
return defaultValue ?? (Array.isArray(key) ? key[key.length - 1] : key);
|
|
123
123
|
},
|
|
124
124
|
async changeLanguage(language, cb) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInstance.mjs","names":[],"sources":["../../src/createInstance.ts"],"sourcesContent":["import { internationalization, log } from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport { getHTMLTextDir } from '@intlayer/core/localization';\nimport {\n navigatePath,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n createInstance as _createInstance,\n i18n as I18nInterface,\n InitOptions,\n TOptions,\n} from 'i18next';\nimport {\n getInterpolationValues,\n type ResolveTranslationParams,\n resolveTranslation,\n toNamespaceList,\n} from './resolveTranslation';\nimport type { TypedGetFixedT } from './typedTranslation';\n\ntype EventHandler = (...args: unknown[]) => void;\n\n/** i18next's namespace when neither `defaultNS` nor `ns` is configured. */\nconst DEFAULT_NAMESPACE = 'translation';\n\n/**\n * Fills `defaultNS` from `ns` the way i18next's `init()` does: a string `ns`\n * becomes the default, an array gives its first entry unless it lists\n * `translation`.\n */\nconst withDerivedDefaultNamespace = <T extends InitOptions>(options: T): T => {\n if (\n (options.defaultNS !== undefined && options.defaultNS !== null) ||\n !options.ns ||\n (Array.isArray(options.ns) && options.ns.includes(DEFAULT_NAMESPACE))\n ) {\n return options;\n }\n\n return { ...options, defaultNS: toNamespaceList(options.ns)[0] };\n};\n\nconst warnIgnoredResources = (location: string) => {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize(location, ANSIColors.CYAN)}: the ${colorize('`resources`', ANSIColors.CYAN)} option is ignored when using ${colorize('@intlayer/i18next', ANSIColors.MAGENTA)} — translations are served from the compiled intlayer dictionaries instead. Remove the resource imports and the ${colorize('`resources`', ANSIColors.CYAN)} option to reduce your bundle size.`\n );\n};\n\nexport const createInstance: typeof _createInstance = (\n instanceOptions: InitOptions = {}\n): I18nInterface => {\n if ((instanceOptions as Record<string, unknown>).resources !== undefined) {\n warnIgnoredResources('createInstance');\n }\n\n const config = internationalization;\n\n /** `createInstance` options, with every later `init()` merged in. */\n const currentOptions: InitOptions = withDerivedDefaultNamespace({\n ...instanceOptions,\n });\n\n let currentLanguage: string =\n (currentOptions.lng as string) ?? config?.defaultLocale ?? 'en';\n\n const listeners = new Map<string, Set<EventHandler>>();\n let initialized = false;\n\n const emit = (event: string, ...args: unknown[]) => {\n listeners.get(event)?.forEach((h) => {\n h(...args);\n });\n };\n\n /** Configured default namespaces as written, else i18next's `translation`. */\n const getDefaultNamespaces = (): string | readonly string[] => {\n const { defaultNS } = currentOptions;\n if (typeof defaultNS === 'string' && defaultNS !== '') return defaultNS;\n if (Array.isArray(defaultNS) && defaultNS.length > 0) return defaultNS;\n return DEFAULT_NAMESPACE;\n };\n\n /** Whether interpolated values are HTML-escaped (i18next default: on). */\n const getEscapeValue = (): boolean =>\n currentOptions.interpolation?.escapeValue ?? true;\n\n /**\n * `resolveTranslation` params for one lookup, with the instance settings\n * read as written so no option list is copied on the `t()` hot path.\n */\n const getResolveParams = (\n language: string,\n namespace: string | readonly string[],\n key: string,\n options?: TOptions\n ): ResolveTranslationParams => ({\n locale: language as LocalesValues,\n namespace,\n key,\n options,\n keySeparator: (currentOptions.keySeparator as string | false) ?? '.',\n nsSeparator: (currentOptions.nsSeparator as string | false) ?? ':',\n fallbackNamespaces: currentOptions.fallbackNS,\n escapeValue: getEscapeValue(),\n });\n\n /**\n * Resolves a key through the full i18next pipeline (namespace prefix,\n * `ns` option, plural/context suffixes, `$t()` nesting, interpolation).\n * Falls back to the interpolated `defaultValue`, then to the key itself.\n */\n const resolveKey = (\n lang: string,\n ns: string | readonly string[],\n key: string,\n opts?: TOptions | string\n ): string => {\n const options =\n typeof opts === 'string' ? { defaultValue: opts } : (opts as TOptions);\n\n const resolved = resolveTranslation(\n getResolveParams(lang, ns, key, options)\n );\n\n if (resolved !== undefined) return resolved as string;\n\n const defaultValue = (options as Record<string, unknown> | undefined)\n ?.defaultValue;\n if (typeof defaultValue === 'string') {\n // A runtime default gets `{{name}}` / `{{price, number}}` interpolation only;\n // dialect constructs (`$t()`, plural blocks) belong in dictionaries, where\n // the build converts them — parsing them here would ship the parser.\n return resolveMessageNodeToString(\n defaultValue,\n getInterpolationValues(options, getEscapeValue()),\n lang as LocalesValues\n );\n }\n\n return key;\n };\n\n const instance = {\n get language() {\n return currentLanguage;\n },\n get languages() {\n return (config?.locales?.map(String) ?? [\n currentLanguage,\n ]) as readonly string[];\n },\n get resolvedLanguage() {\n return currentLanguage;\n },\n get isInitialized() {\n return initialized;\n },\n isInitializing: false,\n initializedStoreOnce: false,\n initializedLanguageOnce: false,\n get options() {\n return currentOptions;\n },\n modules: {} as I18nInterface['modules'],\n services: {} as I18nInterface['services'],\n store: {} as I18nInterface['store'],\n format: ((value: unknown) => String(value)) as I18nInterface['format'],\n\n async init(optionsOrCb?: unknown, cb?: unknown) {\n const opts =\n typeof optionsOrCb === 'function'\n ? {}\n : ((optionsOrCb ?? {}) as Record<string, unknown>);\n if (opts.resources !== undefined) {\n warnIgnoredResources('i18next.init');\n }\n // i18next merges `init()` options over the `createInstance()` ones\n Object.assign(currentOptions, withDerivedDefaultNamespace(opts));\n if (opts.lng) currentLanguage = opts.lng as string;\n initialized = true;\n emit('initialized', opts);\n const t = instance.t.bind(instance);\n const callback = typeof optionsOrCb === 'function' ? optionsOrCb : cb;\n (callback as ((err: unknown, t: unknown) => void) | undefined)?.(null, t);\n return t as unknown as Promise<I18nInterface['t']>;\n },\n\n t(\n key: unknown,\n optionsOrDefaultValue?: unknown,\n extraOpts?: unknown\n ): unknown {\n const options =\n typeof optionsOrDefaultValue === 'string'\n ? {\n defaultValue: optionsOrDefaultValue,\n ...((extraOpts ?? {}) as Record<string, unknown>),\n }\n : (optionsOrDefaultValue as TOptions | undefined);\n const keys: string[] = Array.isArray(key)\n ? (key as string[])\n : [String(key)];\n for (const candidateKey of keys) {\n const result = resolveTranslation(\n getResolveParams(\n currentLanguage,\n getDefaultNamespaces(),\n candidateKey,\n options\n )\n );\n if (result !== undefined) return result;\n }\n\n const defaultValue = (options as Record<string, unknown> | undefined)\n ?.defaultValue;\n if (typeof defaultValue === 'string') {\n // A runtime default gets `{{name}}` / `{{price, number}}` interpolation only;\n // dialect constructs (`$t()`, plural blocks) belong in dictionaries, where\n // the build converts them — parsing them here would ship the parser.\n return resolveMessageNodeToString(\n defaultValue,\n getInterpolationValues(options, getEscapeValue()),\n currentLanguage as LocalesValues\n );\n }\n\n return defaultValue ?? (Array.isArray(key) ? key[key.length - 1] : key);\n },\n\n async changeLanguage(language?: string, cb?: unknown) {\n const prev = currentLanguage;\n\n if (language) currentLanguage = language;\n\n emit('languageChanged', currentLanguage, prev);\n const t = instance.t.bind(instance);\n\n (cb as ((err: unknown, t: unknown) => void) | undefined)?.(null, t);\n\n return t as unknown as Promise<I18nInterface['t']>;\n },\n\n exists(key: string, options?: unknown): boolean {\n return (\n resolveTranslation(\n getResolveParams(\n currentLanguage,\n getDefaultNamespaces(),\n key,\n options as TOptions\n )\n ) !== undefined\n );\n },\n\n /**\n * Returns a `t()` function bound to a fixed locale and namespace.\n * When `ns` matches a registered intlayer dictionary key, the returned\n * function's `key` parameter is typed to only accept valid dot-notation\n * paths for that dictionary, and its return type is resolved from the\n * content at that path. With a `keyPrefix`, keys are relative dot-paths\n * under the prefix.\n *\n * @example\n * ```ts\n * const tAbout = i18n.getFixedT(null, 'about');\n * tAbout('counter.label'); // ✓ typed key and return value\n * ```\n */\n getFixedT: ((\n language: string | readonly string[] | null,\n ns?: string | readonly string[] | null,\n keyPrefix?: string\n ) => {\n const fixedLng = Array.isArray(language)\n ? ((language[0] as string) ?? currentLanguage)\n : ((language as string) ?? currentLanguage);\n\n return (key: string, opts?: TOptions): string => {\n const fullKey = keyPrefix ? `${keyPrefix}.${key}` : key;\n return resolveKey(\n fixedLng,\n ns ?? getDefaultNamespaces(),\n fullKey,\n opts\n );\n };\n }) as TypedGetFixedT,\n\n use(module: unknown) {\n (module as { init?: (i18n: I18nInterface) => void })?.init?.(\n instance as unknown as I18nInterface\n );\n return instance as unknown as I18nInterface;\n },\n\n on(event: string, handler: EventHandler) {\n if (!listeners.has(event)) listeners.set(event, new Set());\n listeners.get(event)!.add(handler);\n return instance as unknown as I18nInterface;\n },\n\n once(event: string, handler: EventHandler) {\n const wrapper: EventHandler = (...args) => {\n handler(...args);\n instance.off(event, wrapper);\n };\n instance.on(event, wrapper);\n return instance as unknown as I18nInterface;\n },\n\n off(event: string, handler?: EventHandler) {\n if (!handler) listeners.delete(event);\n else listeners.get(event)?.delete(handler);\n },\n\n emit(eventName: string, ...args: unknown[]) {\n emit(eventName, ...args);\n },\n\n createInstance(opts?: InitOptions, _cb?: unknown) {\n return createInstance({ ...instanceOptions, ...opts });\n },\n\n cloneInstance(opts?: Record<string, unknown>, _cb?: unknown) {\n return createInstance({ ...currentOptions, ...opts });\n },\n\n dir(language?: string): 'ltr' | 'rtl' {\n const direction = getHTMLTextDir(\n (language ?? currentLanguage) as LocalesValues\n );\n return direction === 'rtl' ? 'rtl' : 'ltr';\n },\n\n setDefaultNamespace(ns: string | readonly string[]) {\n currentOptions.defaultNS = ns;\n },\n\n hasLoadedNamespace(ns: string | readonly string[]): boolean {\n try {\n getIntlayer(\n (Array.isArray(ns) ? ns[0] : ns) as DictionaryKeys,\n currentLanguage as LocalesValues\n );\n return true;\n } catch {\n return false;\n }\n },\n\n async loadNamespaces(_ns: unknown) {},\n async loadLanguages(_lngs: unknown) {},\n loadResources(_cb?: unknown) {},\n async reloadResources() {},\n\n getDataByLanguage(_lng: string) {\n return undefined;\n },\n\n getResource(lng: string, ns: string, key: string): unknown {\n try {\n return navigatePath(\n getIntlayer(ns as DictionaryKeys, lng as LocalesValues),\n key\n );\n } catch {\n return undefined;\n }\n },\n\n addResource: () => instance as unknown as I18nInterface,\n addResources: () => instance as unknown as I18nInterface,\n addResourceBundle: () => instance as unknown as I18nInterface,\n hasResourceBundle: () => false,\n getResourceBundle: () => undefined,\n removeResourceBundle: () => instance as unknown as I18nInterface,\n\n toJSON() {\n return {\n options: currentOptions,\n store: {} as I18nInterface['store'],\n language: currentLanguage,\n languages: (config?.locales?.map(String) ?? [\n currentLanguage,\n ]) as readonly string[],\n resolvedLanguage: currentLanguage,\n };\n },\n };\n\n return instance as unknown as I18nInterface;\n};\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,oBAAoB;;;;;;AAO1B,MAAM,+BAAsD,YAAk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version":3,"file":"createInstance.mjs","names":[],"sources":["../../src/createInstance.ts"],"sourcesContent":["import { internationalization, log } from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport { getHTMLTextDir } from '@intlayer/core/localization';\nimport {\n navigatePath,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n createInstance as _createInstance,\n i18n as I18nInterface,\n InitOptions,\n TOptions,\n} from 'i18next';\nimport {\n getInterpolationValues,\n type ResolveTranslationParams,\n resolveTranslation,\n toNamespaceList,\n} from './resolveTranslation';\nimport type { TypedGetFixedT } from './typedTranslation';\n\ntype EventHandler = (...args: unknown[]) => void;\n\n/** i18next's namespace when neither `defaultNS` nor `ns` is configured. */\nconst DEFAULT_NAMESPACE = 'translation';\n\n/**\n * Fills `defaultNS` from `ns` the way i18next's `init()` does: a string `ns`\n * becomes the default, an array gives its first entry unless it lists\n * `translation`.\n */\nconst withDerivedDefaultNamespace = <T extends InitOptions>(options: T): T => {\n if (\n (options.defaultNS !== undefined && options.defaultNS !== null) ||\n !options.ns ||\n (Array.isArray(options.ns) && options.ns.includes(DEFAULT_NAMESPACE))\n ) {\n return options;\n }\n\n return { ...options, defaultNS: toNamespaceList(options.ns)[0] };\n};\n\nconst warnIgnoredResources = (location: string) => {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize(location, ANSIColors.CYAN)}: the ${colorize('`resources`', ANSIColors.CYAN)} option is ignored when using ${colorize('@intlayer/i18next', ANSIColors.MAGENTA)} — translations are served from the compiled intlayer dictionaries instead. Remove the resource imports and the ${colorize('`resources`', ANSIColors.CYAN)} option to reduce your bundle size.`\n );\n};\n\nexport const createInstance: typeof _createInstance = (\n instanceOptions: InitOptions = {}\n): I18nInterface => {\n if ((instanceOptions as Record<string, unknown>).resources !== undefined) {\n warnIgnoredResources('createInstance');\n }\n\n const config = internationalization;\n\n /** `createInstance` options, with every later `init()` merged in. */\n const currentOptions: InitOptions = withDerivedDefaultNamespace({\n ...instanceOptions,\n });\n\n let currentLanguage: string =\n (currentOptions.lng as string) ?? config?.defaultLocale ?? 'en';\n\n const listeners = new Map<string, Set<EventHandler>>();\n let initialized = false;\n\n const emit = (event: string, ...args: unknown[]) => {\n listeners.get(event)?.forEach((h) => {\n h(...args);\n });\n };\n\n /** Configured default namespaces as written, else i18next's `translation`. */\n const getDefaultNamespaces = (): string | readonly string[] => {\n const { defaultNS } = currentOptions;\n if (typeof defaultNS === 'string' && defaultNS !== '') return defaultNS;\n if (Array.isArray(defaultNS) && defaultNS.length > 0) return defaultNS;\n return DEFAULT_NAMESPACE;\n };\n\n /** Whether interpolated values are HTML-escaped (i18next default: on). */\n const getEscapeValue = (): boolean =>\n currentOptions.interpolation?.escapeValue ?? true;\n\n /**\n * `resolveTranslation` params for one lookup, with the instance settings\n * read as written so no option list is copied on the `t()` hot path.\n */\n const getResolveParams = (\n language: string,\n namespace: string | readonly string[],\n key: string,\n options?: TOptions\n ): ResolveTranslationParams => ({\n locale: language as LocalesValues,\n namespace,\n key,\n options,\n keySeparator: (currentOptions.keySeparator as string | false) ?? '.',\n nsSeparator: (currentOptions.nsSeparator as string | false) ?? ':',\n fallbackNamespaces: currentOptions.fallbackNS,\n escapeValue: getEscapeValue(),\n });\n\n /**\n * Resolves a key through the full i18next pipeline (namespace prefix,\n * `ns` option, plural/context suffixes, `$t()` nesting, interpolation).\n * Falls back to the interpolated `defaultValue`, then to the key itself.\n */\n const resolveKey = (\n lang: string,\n ns: string | readonly string[],\n key: string,\n opts?: TOptions | string\n ): string => {\n const options =\n typeof opts === 'string' ? { defaultValue: opts } : (opts as TOptions);\n\n const resolved = resolveTranslation(\n getResolveParams(lang, ns, key, options)\n );\n\n if (resolved !== undefined) return resolved as string;\n\n const defaultValue = (options as Record<string, unknown> | undefined)\n ?.defaultValue;\n if (typeof defaultValue === 'string') {\n // A runtime default gets `{{name}}` / `{{price, number}}` interpolation only;\n // dialect constructs (`$t()`, plural blocks) belong in dictionaries, where\n // the build converts them — parsing them here would ship the parser.\n return resolveMessageNodeToString(\n defaultValue,\n getInterpolationValues(options, getEscapeValue()),\n lang as LocalesValues,\n undefined,\n 'double-brace'\n );\n }\n\n return key;\n };\n\n const instance = {\n get language() {\n return currentLanguage;\n },\n get languages() {\n return (config?.locales?.map(String) ?? [\n currentLanguage,\n ]) as readonly string[];\n },\n get resolvedLanguage() {\n return currentLanguage;\n },\n get isInitialized() {\n return initialized;\n },\n isInitializing: false,\n initializedStoreOnce: false,\n initializedLanguageOnce: false,\n get options() {\n return currentOptions;\n },\n modules: {} as I18nInterface['modules'],\n services: {} as I18nInterface['services'],\n store: {} as I18nInterface['store'],\n format: ((value: unknown) => String(value)) as I18nInterface['format'],\n\n async init(optionsOrCb?: unknown, cb?: unknown) {\n const opts =\n typeof optionsOrCb === 'function'\n ? {}\n : ((optionsOrCb ?? {}) as Record<string, unknown>);\n if (opts.resources !== undefined) {\n warnIgnoredResources('i18next.init');\n }\n // i18next merges `init()` options over the `createInstance()` ones\n Object.assign(currentOptions, withDerivedDefaultNamespace(opts));\n if (opts.lng) currentLanguage = opts.lng as string;\n initialized = true;\n emit('initialized', opts);\n const t = instance.t.bind(instance);\n const callback = typeof optionsOrCb === 'function' ? optionsOrCb : cb;\n (callback as ((err: unknown, t: unknown) => void) | undefined)?.(null, t);\n return t as unknown as Promise<I18nInterface['t']>;\n },\n\n t(\n key: unknown,\n optionsOrDefaultValue?: unknown,\n extraOpts?: unknown\n ): unknown {\n const options =\n typeof optionsOrDefaultValue === 'string'\n ? {\n defaultValue: optionsOrDefaultValue,\n ...((extraOpts ?? {}) as Record<string, unknown>),\n }\n : (optionsOrDefaultValue as TOptions | undefined);\n const keys: string[] = Array.isArray(key)\n ? (key as string[])\n : [String(key)];\n for (const candidateKey of keys) {\n const result = resolveTranslation(\n getResolveParams(\n currentLanguage,\n getDefaultNamespaces(),\n candidateKey,\n options\n )\n );\n if (result !== undefined) return result;\n }\n\n const defaultValue = (options as Record<string, unknown> | undefined)\n ?.defaultValue;\n if (typeof defaultValue === 'string') {\n // A runtime default gets `{{name}}` / `{{price, number}}` interpolation only;\n // dialect constructs (`$t()`, plural blocks) belong in dictionaries, where\n // the build converts them — parsing them here would ship the parser.\n return resolveMessageNodeToString(\n defaultValue,\n getInterpolationValues(options, getEscapeValue()),\n currentLanguage as LocalesValues,\n undefined,\n 'double-brace'\n );\n }\n\n return defaultValue ?? (Array.isArray(key) ? key[key.length - 1] : key);\n },\n\n async changeLanguage(language?: string, cb?: unknown) {\n const prev = currentLanguage;\n\n if (language) currentLanguage = language;\n\n emit('languageChanged', currentLanguage, prev);\n const t = instance.t.bind(instance);\n\n (cb as ((err: unknown, t: unknown) => void) | undefined)?.(null, t);\n\n return t as unknown as Promise<I18nInterface['t']>;\n },\n\n exists(key: string, options?: unknown): boolean {\n return (\n resolveTranslation(\n getResolveParams(\n currentLanguage,\n getDefaultNamespaces(),\n key,\n options as TOptions\n )\n ) !== undefined\n );\n },\n\n /**\n * Returns a `t()` function bound to a fixed locale and namespace.\n * When `ns` matches a registered intlayer dictionary key, the returned\n * function's `key` parameter is typed to only accept valid dot-notation\n * paths for that dictionary, and its return type is resolved from the\n * content at that path. With a `keyPrefix`, keys are relative dot-paths\n * under the prefix.\n *\n * @example\n * ```ts\n * const tAbout = i18n.getFixedT(null, 'about');\n * tAbout('counter.label'); // ✓ typed key and return value\n * ```\n */\n getFixedT: ((\n language: string | readonly string[] | null,\n ns?: string | readonly string[] | null,\n keyPrefix?: string\n ) => {\n const fixedLng = Array.isArray(language)\n ? ((language[0] as string) ?? currentLanguage)\n : ((language as string) ?? currentLanguage);\n\n return (key: string, opts?: TOptions): string => {\n const fullKey = keyPrefix ? `${keyPrefix}.${key}` : key;\n return resolveKey(\n fixedLng,\n ns ?? getDefaultNamespaces(),\n fullKey,\n opts\n );\n };\n }) as TypedGetFixedT,\n\n use(module: unknown) {\n (module as { init?: (i18n: I18nInterface) => void })?.init?.(\n instance as unknown as I18nInterface\n );\n return instance as unknown as I18nInterface;\n },\n\n on(event: string, handler: EventHandler) {\n if (!listeners.has(event)) listeners.set(event, new Set());\n listeners.get(event)!.add(handler);\n return instance as unknown as I18nInterface;\n },\n\n once(event: string, handler: EventHandler) {\n const wrapper: EventHandler = (...args) => {\n handler(...args);\n instance.off(event, wrapper);\n };\n instance.on(event, wrapper);\n return instance as unknown as I18nInterface;\n },\n\n off(event: string, handler?: EventHandler) {\n if (!handler) listeners.delete(event);\n else listeners.get(event)?.delete(handler);\n },\n\n emit(eventName: string, ...args: unknown[]) {\n emit(eventName, ...args);\n },\n\n createInstance(opts?: InitOptions, _cb?: unknown) {\n return createInstance({ ...instanceOptions, ...opts });\n },\n\n cloneInstance(opts?: Record<string, unknown>, _cb?: unknown) {\n return createInstance({ ...currentOptions, ...opts });\n },\n\n dir(language?: string): 'ltr' | 'rtl' {\n const direction = getHTMLTextDir(\n (language ?? currentLanguage) as LocalesValues\n );\n return direction === 'rtl' ? 'rtl' : 'ltr';\n },\n\n setDefaultNamespace(ns: string | readonly string[]) {\n currentOptions.defaultNS = ns;\n },\n\n hasLoadedNamespace(ns: string | readonly string[]): boolean {\n try {\n getIntlayer(\n (Array.isArray(ns) ? ns[0] : ns) as DictionaryKeys,\n currentLanguage as LocalesValues\n );\n return true;\n } catch {\n return false;\n }\n },\n\n async loadNamespaces(_ns: unknown) {},\n async loadLanguages(_lngs: unknown) {},\n loadResources(_cb?: unknown) {},\n async reloadResources() {},\n\n getDataByLanguage(_lng: string) {\n return undefined;\n },\n\n getResource(lng: string, ns: string, key: string): unknown {\n try {\n return navigatePath(\n getIntlayer(ns as DictionaryKeys, lng as LocalesValues),\n key\n );\n } catch {\n return undefined;\n }\n },\n\n addResource: () => instance as unknown as I18nInterface,\n addResources: () => instance as unknown as I18nInterface,\n addResourceBundle: () => instance as unknown as I18nInterface,\n hasResourceBundle: () => false,\n getResourceBundle: () => undefined,\n removeResourceBundle: () => instance as unknown as I18nInterface,\n\n toJSON() {\n return {\n options: currentOptions,\n store: {} as I18nInterface['store'],\n language: currentLanguage,\n languages: (config?.locales?.map(String) ?? [\n currentLanguage,\n ]) as readonly string[],\n resolvedLanguage: currentLanguage,\n };\n },\n };\n\n return instance as unknown as I18nInterface;\n};\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,oBAAoB;;;;;;AAO1B,MAAM,+BAAsD,YAAkB;CAC5E,IACG,QAAQ,cAAc,UAAa,QAAQ,cAAc,QAC1D,CAAC,QAAQ,MACR,MAAM,QAAQ,QAAQ,EAAE,KAAK,QAAQ,GAAG,SAAS,iBAAiB,GAEnE,OAAO;CAGT,OAAO;EAAE,GAAG;EAAS,WAAW,gBAAgB,QAAQ,EAAE,CAAC,CAAC;CAAG;AACjE;AAEA,MAAM,wBAAwB,aAAqB;CAEjD,AADkB,aAAa,EAAE,IAAI,CAC7B,CAAC,CACP,GAAG,SAAS,UAAU,WAAW,IAAI,EAAE,QAAQ,SAAS,eAAe,WAAW,IAAI,EAAE,gCAAgC,SAAS,qBAAqB,WAAW,OAAO,EAAE,kHAAkH,SAAS,eAAe,WAAW,IAAI,EAAE,oCACvU;AACF;AAEA,MAAa,kBACX,kBAA+B,CAAC,MACd;CAClB,IAAK,gBAA4C,cAAc,QAC7D,qBAAqB,gBAAgB;CAGvC,MAAM,SAAS;;CAGf,MAAM,iBAA8B,4BAA4B,EAC9D,GAAG,gBACL,CAAC;CAED,IAAI,kBACD,eAAe,OAAkB,QAAQ,iBAAiB;CAE7D,MAAM,4BAAY,IAAI,IAA+B;CACrD,IAAI,cAAc;CAElB,MAAM,QAAQ,OAAe,GAAG,SAAoB;EAClD,UAAU,IAAI,KAAK,CAAC,EAAE,SAAS,MAAM;GACnC,EAAE,GAAG,IAAI;EACX,CAAC;CACH;;CAGA,MAAM,6BAAyD;EAC7D,MAAM,EAAE,cAAc;EACtB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IAAI;IACF,OAAO,aACL,YAAY,IAAsB,GAAoB,GACtD,GACF;GACF,QAAQ;IACN;GACF;EACF;EAEA,mBAAmB;EACnB,oBAAoB;EACpB,yBAAyB;EACzB,yBAAyB;EACzB,yBAAyB;EACzB,4BAA4B;EAE5B,SAAS;GACP,OAAO;IACL,SAAS;IACT,OAAO,CAAC;IACR,UAAU;IACV,WAAY,QAAQ,SAAS,IAAI,MAAM,KAAK,CAC1C,eACF;IACA,kBAAkB;GACpB;EACF;CACF;CAEA,OAAO;AACT"}
|
|
@@ -217,7 +217,7 @@ const resolveTranslation = ({ locale, namespace, key, options, keySeparator = ".
|
|
|
217
217
|
if (resolvedNamespace === void 0) return void 0;
|
|
218
218
|
if (options?.returnObjects && typeof resolvedValue === "object" && resolvedValue !== null) return resolvedValue;
|
|
219
219
|
const values = getInterpolationValues(options, escapeValue);
|
|
220
|
-
let resolved = resolveMessageNodeToString(resolvedValue, values, resolvedLocale);
|
|
220
|
+
let resolved = resolveMessageNodeToString(resolvedValue, values, resolvedLocale, void 0, "double-brace");
|
|
221
221
|
if (depth < MAX_NESTING_DEPTH && resolved.includes("$t(")) resolved = resolved.replace(/\$t\(\s*([^),]+?)\s*(?:,[^)]*)?\)/g, (match, nestedKey) => {
|
|
222
222
|
const nestedValue = resolveTranslation({
|
|
223
223
|
locale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveTranslation.mjs","names":[],"sources":["../../src/resolveTranslation.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport {\n type MessageValues,\n navigatePath,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { TOptions } from 'i18next';\n\n/**\n * Shared i18next-dialect translation resolution.\n *\n * Implements the i18next lookup pipeline on top of intlayer dictionaries:\n * namespace prefix (`ns:key`), `ns` option override, fallback namespaces\n * (`fallbackNS`), plural suffixes (`key_one`, `key_other`, …) via\n * `Intl.PluralRules`, context suffixes (`key_male`), `$t()` nesting,\n * `defaultValue` and `{{var}}` interpolation with optional value escaping.\n *\n * Used by `@intlayer/i18next` (instance `t`) and `@intlayer/react-i18next`\n * (`useTranslation`, `<Trans>`).\n */\n\n/** Option keys that are control flags, never interpolation values. */\nconst CONTROL_OPTION_KEYS = new Set([\n 'defaultValue',\n 'ns',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'returnObjects',\n 'returnDetails',\n 'keySeparator',\n 'nsSeparator',\n 'ordinal',\n 'postProcess',\n 'postProcessPassResolved',\n 'interpolation',\n 'replace',\n 'joinArrays',\n 'nsMode',\n 'keyPrefix',\n]);\n\n/** Maximum `$t()` nesting recursion depth. */\nconst MAX_NESTING_DEPTH = 5;\n\n/** Characters i18next replaces in interpolated values when `escapeValue` is on. */\nconst HTML_ESCAPE_ENTITIES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n/**\n * Prefix of i18next's unescaped placeholder. The build normalizes\n * `{{- name}}` to `{{-name}}`, so every value is also exposed, never escaped,\n * under `-name`.\n */\nconst UNESCAPED_VALUE_PREFIX = '-';\n\n/**\n * Escapes a value the way i18next's `escapeValue` does — strings, including\n * those nested in arrays and plain objects (`{{user.name}}`).\n */\nconst escapeInterpolationValue = (value: unknown): unknown => {\n if (typeof value === 'string') {\n return value.replace(\n /[&<>\"']/g,\n (character) => HTML_ESCAPE_ENTITIES[character] ?? character\n );\n }\n\n if (Array.isArray(value)) return value.map(escapeInterpolationValue);\n\n if (\n value !== null &&\n typeof value === 'object' &&\n Object.getPrototypeOf(value) === Object.prototype\n ) {\n return Object.fromEntries(\n Object.entries(value).map(([entryKey, entryValue]) => [\n entryKey,\n escapeInterpolationValue(entryValue),\n ])\n );\n }\n\n return value;\n};\n\n/**\n * Normalizes an i18next namespace option (`ns`, `defaultNS`, `fallbackNS`),\n * which can be a string, an array or `false`, into a list.\n */\nexport const toNamespaceList = (namespaces: unknown): string[] => {\n if (!namespaces) return [];\n\n return (Array.isArray(namespaces) ? namespaces : [namespaces]) as string[];\n};\n\n/** An i18next namespace option as written: a string, a list or `false`. */\nexport type NamespaceOption = string | readonly string[] | false | undefined;\n\n/** Number of namespaces in a namespace option, without copying it. */\nconst getNamespaceCount = (namespaces: NamespaceOption): number => {\n if (!namespaces) return 0;\n\n return typeof namespaces === 'string' ? 1 : namespaces.length;\n};\n\n/** Namespace at `index` of a non-empty namespace option. */\nconst getNamespaceAt = (\n namespaces: string | readonly string[],\n index: number\n): string =>\n typeof namespaces === 'string' ? namespaces : (namespaces[index] as string);\n\n/** Whether a namespace option lists `namespace`. */\nconst hasNamespace = (\n namespaces: NamespaceOption,\n namespace: string\n): boolean => {\n if (!namespaces) return false;\n\n return typeof namespaces === 'string'\n ? namespaces === namespace\n : namespaces.includes(namespace);\n};\n\n/**\n * Canonical key of the single dictionary produced when a JSON source pattern\n * has no `{{key}}` segment (one file holds the whole namespace, e.g.\n * `./src/i18n/{{locale}}.json`). Used as the fallback namespace so i18next's\n * default `translation` namespace resolves against the whole-file dictionary.\n */\nconst ROOT_DICTIONARY_KEY = 'index';\n\n/**\n * Reads a dictionary from the runtime registry, returning `undefined` when the\n * namespace is not a registered dictionary.\n *\n * `getIntlayer` never throws for a missing key — in development it returns a\n * path-stringifying fallback proxy — so a plain `getIntlayer` call cannot tell\n * \"missing namespace\" apart from \"resolved content\". The registry membership\n * check makes the distinction explicit before resolving.\n */\nconst getDictionaryOrUndefined = (\n namespace: DictionaryKeys,\n locale: LocalesValues\n): unknown => {\n if (!(namespace in getDictionaries())) return undefined;\n\n return getIntlayer(namespace, locale);\n};\n\n/**\n * Dictionary searched for one namespace, `undefined` when unregistered.\n *\n * `primaryDictionaryContent` is the pre-resolved content of the first default\n * namespace, when the call may use it.\n */\nconst getNamespaceDictionary = (\n candidateNamespace: string,\n defaultNamespaces: string | readonly string[],\n locale: LocalesValues,\n primaryDictionaryContent: unknown\n): unknown => {\n if (\n primaryDictionaryContent !== undefined &&\n candidateNamespace === getNamespaceAt(defaultNamespaces, 0)\n ) {\n return primaryDictionaryContent;\n }\n\n const dictionary = getDictionaryOrUndefined(\n candidateNamespace as DictionaryKeys,\n locale\n );\n\n // i18next's default namespace is `translation`, but a single-file JSON\n // source (no `{{key}}` segment) is loaded as the root `index` dictionary.\n // When a *default* namespace is not itself a registered dictionary, fall\n // back to `index` so `t('login.heroSubtitle')` resolves against the\n // whole-file dictionary. Other namespaces (`ns:` prefix, `ns` option,\n // fallback namespaces) never do, so a genuinely missing one is skipped.\n if (\n dictionary === undefined &&\n candidateNamespace !== ROOT_DICTIONARY_KEY &&\n hasNamespace(defaultNamespaces, candidateNamespace)\n ) {\n return getDictionaryOrUndefined(\n ROOT_DICTIONARY_KEY as DictionaryKeys,\n locale\n );\n }\n\n return dictionary;\n};\n\n/** Value of the first key candidate found in `dictionary`. */\nconst findKeyCandidate = (\n dictionary: unknown,\n keyCandidates: readonly string[],\n keySeparator: string | false\n): unknown => {\n for (const candidateKey of keyCandidates) {\n const value = navigatePath(dictionary, candidateKey, keySeparator);\n if (value !== null && value !== undefined) return value;\n }\n\n return undefined;\n};\n\n/**\n * Builds the ordered list of key candidates following i18next's resolution\n * order: context + plural → context → plural → exact key.\n */\nconst buildKeyCandidates = (\n path: string,\n locale: string,\n count: number | undefined,\n context: string | undefined,\n ordinal: boolean\n): string[] => {\n const candidates: string[] = [];\n\n const pluralCategory =\n count === undefined\n ? undefined\n : new Intl.PluralRules(locale, {\n type: ordinal ? 'ordinal' : 'cardinal',\n }).select(count);\n\n if (context) {\n if (pluralCategory) {\n if (ordinal) {\n candidates.push(`${path}_${context}_ordinal_${pluralCategory}`);\n }\n candidates.push(`${path}_${context}_${pluralCategory}`);\n if (count !== 1) candidates.push(`${path}_${context}_plural`);\n }\n candidates.push(`${path}_${context}`);\n }\n\n if (pluralCategory) {\n if (ordinal) candidates.push(`${path}_ordinal_${pluralCategory}`);\n candidates.push(`${path}_${pluralCategory}`);\n // Legacy i18next v3 JSON suffix\n if (count !== 1) candidates.push(`${path}_plural`);\n }\n\n candidates.push(path);\n\n return candidates;\n};\n\n/** Whether an interpolation value is absent (`null` or `undefined`). */\nconst isMissingValue = (value: unknown): boolean =>\n value === undefined || value === null;\n\n/**\n * Sets one interpolation value, escaped when asked, and its raw `-name` alias\n * read by `{{- name}}` placeholders.\n */\nconst setInterpolationValue = (\n values: MessageValues,\n valueName: string,\n value: unknown,\n shouldEscape: boolean\n): void => {\n values[valueName] = shouldEscape ? escapeInterpolationValue(value) : value;\n values[`${UNESCAPED_VALUE_PREFIX}${valueName}`] = value;\n};\n\n/**\n * Extracts interpolation values from i18next `t()` options.\n *\n * With `escapeValue` (overridden per call by `interpolation.escapeValue`),\n * values are HTML-escaped like i18next does; each value stays reachable\n * unescaped as `-name` for `{{- name}}` placeholders.\n */\nexport const getInterpolationValues = (\n options?: TOptions,\n escapeValue = false\n): MessageValues => {\n if (!options || typeof options !== 'object') return {};\n\n const shouldEscape = options.interpolation?.escapeValue ?? escapeValue;\n const values: MessageValues = {};\n const replace = (options as { replace?: MessageValues }).replace;\n\n if (replace) {\n for (const valueName of Object.keys(replace)) {\n setInterpolationValue(\n values,\n valueName,\n replace[valueName],\n shouldEscape\n );\n }\n\n // `count` and `context` are always interpolatable, even with `replace`\n if (options.count !== undefined && isMissingValue(values.count)) {\n setInterpolationValue(values, 'count', options.count, shouldEscape);\n }\n if (options.context !== undefined && isMissingValue(values.context)) {\n setInterpolationValue(values, 'context', options.context, shouldEscape);\n }\n return values;\n }\n\n for (const optionKey of Object.keys(options)) {\n if (!CONTROL_OPTION_KEYS.has(optionKey)) {\n setInterpolationValue(\n values,\n optionKey,\n (options as Record<string, unknown>)[optionKey],\n shouldEscape\n );\n }\n }\n return values;\n};\n\nexport type ResolveTranslationParams = {\n /** Locale to resolve against. */\n locale: LocalesValues;\n /**\n * Default namespace (dictionary key) when the key has no `ns:` prefix. A\n * list (i18next `defaultNS` array) is tried in order.\n */\n namespace: string | readonly string[];\n /**\n * Namespaces tried, in order, after the requested ones: i18next's\n * `fallbackNS` as written (a string, a list or `false`). Like i18next, they\n * also apply to `ns:` prefixes and the `ns` option.\n */\n fallbackNamespaces?: NamespaceOption;\n /**\n * HTML-escapes interpolated values (i18next `interpolation.escapeValue`).\n * Defaults to `false`; a per-call `interpolation.escapeValue` wins.\n */\n escapeValue?: boolean;\n /** The translation key, possibly `ns:path.to.key`. */\n key: string;\n /** i18next `t()` options (interpolation values, count, context, …). */\n options?: TOptions;\n /** Custom key separator (`init({ keySeparator })`). */\n keySeparator?: string | false;\n /** Custom namespace separator (`init({ nsSeparator })`). */\n nsSeparator?: string | false;\n /** Internal `$t()` nesting recursion depth. */\n depth?: number;\n /**\n * Pre-resolved content of the (first) `namespace` dictionary for `locale`.\n *\n * Supplied by the build-optimized `useDictionary` / `getDictionary`\n * variants, where the dictionary is imported at build time instead of read\n * from the runtime registry. Only used when the call resolves to the\n * default `namespace` without a locale override — cross-namespace\n * (`other:key`, `{ ns }`, fallback namespaces) and `{ lng }` lookups still\n * go through `getIntlayer`.\n */\n dictionaryContent?: unknown;\n};\n\n/**\n * Resolves a single translation key the i18next way against intlayer\n * dictionaries.\n *\n * Returns the resolved value: a string in the common case, or an\n * object/array when `returnObjects: true`. Returns `undefined` when the key\n * cannot be resolved (caller decides between `defaultValue`, fallback keys\n * and key echo).\n */\nexport const resolveTranslation = ({\n locale,\n namespace,\n key,\n options,\n keySeparator = '.',\n nsSeparator = ':',\n fallbackNamespaces,\n escapeValue = false,\n depth = 0,\n dictionaryContent,\n}: ResolveTranslationParams): unknown => {\n // Namespace resolution: `ns:` prefix > `ns` option > default namespaces.\n // The fallback namespaces are searched after them in every case, as\n // i18next does. Options are read as written, so no list is copied.\n let requestedNamespaces: string | readonly string[] = namespace;\n let path = key;\n\n if (nsSeparator !== false && key.includes(nsSeparator)) {\n const separatorIndex = key.indexOf(nsSeparator);\n requestedNamespaces = key.slice(0, separatorIndex);\n path = key.slice(separatorIndex + nsSeparator.length);\n } else if (options?.ns) {\n requestedNamespaces = options.ns as string | readonly string[];\n }\n\n const count = typeof options?.count === 'number' ? options.count : undefined;\n const context =\n options?.context !== undefined ? String(options.context) : undefined;\n const ordinal = options?.ordinal === true;\n\n const resolvedLocale = ((options?.lng as string) ?? locale) as LocalesValues;\n const primaryDictionaryContent =\n options?.lng === undefined ? dictionaryContent : undefined;\n\n const requestedNamespaceCount = getNamespaceCount(requestedNamespaces);\n const namespaceCount =\n requestedNamespaceCount + getNamespaceCount(fallbackNamespaces);\n\n let keyCandidates: string[] | undefined;\n let resolvedValue: unknown;\n let resolvedNamespace: string | undefined;\n\n for (\n let namespaceIndex = 0;\n namespaceIndex < namespaceCount && resolvedNamespace === undefined;\n namespaceIndex++\n ) {\n const isFallbackNamespace = namespaceIndex >= requestedNamespaceCount;\n const candidateNamespace = isFallbackNamespace\n ? getNamespaceAt(\n fallbackNamespaces as string | readonly string[],\n namespaceIndex - requestedNamespaceCount\n )\n : getNamespaceAt(requestedNamespaces, namespaceIndex);\n\n // A fallback namespace that was already requested has been searched\n if (\n isFallbackNamespace &&\n hasNamespace(requestedNamespaces, candidateNamespace)\n ) {\n continue;\n }\n\n const dictionary = getNamespaceDictionary(\n candidateNamespace,\n namespace,\n resolvedLocale,\n primaryDictionaryContent\n );\n if (dictionary === undefined) continue;\n\n keyCandidates ??= buildKeyCandidates(\n path,\n resolvedLocale as string,\n count,\n context,\n ordinal\n );\n\n const value = findKeyCandidate(dictionary, keyCandidates, keySeparator);\n if (value !== undefined) {\n resolvedValue = value;\n resolvedNamespace = candidateNamespace;\n }\n }\n\n if (resolvedNamespace === undefined) return undefined;\n\n // `returnObjects: true` — return the raw subtree\n if (\n options?.returnObjects &&\n typeof resolvedValue === 'object' &&\n resolvedValue !== null\n ) {\n return resolvedValue;\n }\n\n const values = getInterpolationValues(options, escapeValue);\n\n // Dictionary content was converted to intlayer nodes at build time, so no\n // i18next parser is needed here — which keeps it out of the app bundle.\n let resolved = resolveMessageNodeToString(\n resolvedValue,\n values,\n resolvedLocale\n );\n\n // `$t(key)` nesting\n if (depth < MAX_NESTING_DEPTH && resolved.includes('$t(')) {\n resolved = resolved.replace(\n /\\$t\\(\\s*([^),]+?)\\s*(?:,[^)]*)?\\)/g,\n (match, nestedKey: string) => {\n const nestedValue = resolveTranslation({\n locale,\n namespace: resolvedNamespace,\n key: nestedKey.trim(),\n options,\n keySeparator,\n nsSeparator,\n fallbackNamespaces,\n escapeValue,\n depth: depth + 1,\n dictionaryContent:\n resolvedNamespace === getNamespaceAt(namespace, 0)\n ? dictionaryContent\n : undefined,\n });\n return typeof nestedValue === 'string' ? nestedValue : match;\n }\n );\n }\n\n return resolved;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,MAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,oBAAoB;;AAG1B,MAAM,uBAA+C;CACnD,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;AACP;;;;;;AAOA,MAAM,yBAAyB;;;;;AAM/B,MAAM,4BAA4B,UAA4B;CAC5D,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,QACX,aACC,cAAc,qBAAqB,cAAc,SACpD;CAGF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,wBAAwB;CAEnE,IACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,eAAe,KAAK,MAAM,OAAO,WAExC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,gBAAgB,CACpD,UACA,yBAAyB,UAAU,CACrC,CAAC,CACH;CAGF,OAAO;AACT;;;;;AAMA,MAAa,mBAAmB,eAAkC;CAChE,IAAI,CAAC,YAAY,OAAO,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ACT,OAAO,kBAAkB,YACzB,kBAAkB,MAElB,OAAO;CAGT,MAAM,SAAS,uBAAuB,SAAS,WAAW;CAI1D,IAAI,WAAW,2BACb,eACA,QACA,cACF;CAGA,IAAI,QAAQ,qBAAqB,SAAS,SAAS,KAAK,GACtD,WAAW,SAAS,QAClB,uCACC,OAAO,cAAsB;EAC5B,MAAM,cAAc,mBAAmB;GACrC;GACA,WAAW;GACX,KAAK,UAAU,KAAK;GACpB;GACA;GACA;GACA;GACA;GACA,OAAO,QAAQ;GACf,mBACE,sBAAsB,eAAe,WAAW,CAAC,IAC7C,oBACA;EACR,CAAC;EACD,OAAO,OAAO,gBAAgB,WAAW,cAAc;CACzD,CACF;CAGF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"resolveTranslation.mjs","names":[],"sources":["../../src/resolveTranslation.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport {\n type MessageValues,\n navigatePath,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { TOptions } from 'i18next';\n\n/**\n * Shared i18next-dialect translation resolution.\n *\n * Implements the i18next lookup pipeline on top of intlayer dictionaries:\n * namespace prefix (`ns:key`), `ns` option override, fallback namespaces\n * (`fallbackNS`), plural suffixes (`key_one`, `key_other`, …) via\n * `Intl.PluralRules`, context suffixes (`key_male`), `$t()` nesting,\n * `defaultValue` and `{{var}}` interpolation with optional value escaping.\n *\n * Used by `@intlayer/i18next` (instance `t`) and `@intlayer/react-i18next`\n * (`useTranslation`, `<Trans>`).\n */\n\n/** Option keys that are control flags, never interpolation values. */\nconst CONTROL_OPTION_KEYS = new Set([\n 'defaultValue',\n 'ns',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'returnObjects',\n 'returnDetails',\n 'keySeparator',\n 'nsSeparator',\n 'ordinal',\n 'postProcess',\n 'postProcessPassResolved',\n 'interpolation',\n 'replace',\n 'joinArrays',\n 'nsMode',\n 'keyPrefix',\n]);\n\n/** Maximum `$t()` nesting recursion depth. */\nconst MAX_NESTING_DEPTH = 5;\n\n/** Characters i18next replaces in interpolated values when `escapeValue` is on. */\nconst HTML_ESCAPE_ENTITIES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n/**\n * Prefix of i18next's unescaped placeholder. The build normalizes\n * `{{- name}}` to `{{-name}}`, so every value is also exposed, never escaped,\n * under `-name`.\n */\nconst UNESCAPED_VALUE_PREFIX = '-';\n\n/**\n * Escapes a value the way i18next's `escapeValue` does — strings, including\n * those nested in arrays and plain objects (`{{user.name}}`).\n */\nconst escapeInterpolationValue = (value: unknown): unknown => {\n if (typeof value === 'string') {\n return value.replace(\n /[&<>\"']/g,\n (character) => HTML_ESCAPE_ENTITIES[character] ?? character\n );\n }\n\n if (Array.isArray(value)) return value.map(escapeInterpolationValue);\n\n if (\n value !== null &&\n typeof value === 'object' &&\n Object.getPrototypeOf(value) === Object.prototype\n ) {\n return Object.fromEntries(\n Object.entries(value).map(([entryKey, entryValue]) => [\n entryKey,\n escapeInterpolationValue(entryValue),\n ])\n );\n }\n\n return value;\n};\n\n/**\n * Normalizes an i18next namespace option (`ns`, `defaultNS`, `fallbackNS`),\n * which can be a string, an array or `false`, into a list.\n */\nexport const toNamespaceList = (namespaces: unknown): string[] => {\n if (!namespaces) return [];\n\n return (Array.isArray(namespaces) ? namespaces : [namespaces]) as string[];\n};\n\n/** An i18next namespace option as written: a string, a list or `false`. */\nexport type NamespaceOption = string | readonly string[] | false | undefined;\n\n/** Number of namespaces in a namespace option, without copying it. */\nconst getNamespaceCount = (namespaces: NamespaceOption): number => {\n if (!namespaces) return 0;\n\n return typeof namespaces === 'string' ? 1 : namespaces.length;\n};\n\n/** Namespace at `index` of a non-empty namespace option. */\nconst getNamespaceAt = (\n namespaces: string | readonly string[],\n index: number\n): string =>\n typeof namespaces === 'string' ? namespaces : (namespaces[index] as string);\n\n/** Whether a namespace option lists `namespace`. */\nconst hasNamespace = (\n namespaces: NamespaceOption,\n namespace: string\n): boolean => {\n if (!namespaces) return false;\n\n return typeof namespaces === 'string'\n ? namespaces === namespace\n : namespaces.includes(namespace);\n};\n\n/**\n * Canonical key of the single dictionary produced when a JSON source pattern\n * has no `{{key}}` segment (one file holds the whole namespace, e.g.\n * `./src/i18n/{{locale}}.json`). Used as the fallback namespace so i18next's\n * default `translation` namespace resolves against the whole-file dictionary.\n */\nconst ROOT_DICTIONARY_KEY = 'index';\n\n/**\n * Reads a dictionary from the runtime registry, returning `undefined` when the\n * namespace is not a registered dictionary.\n *\n * `getIntlayer` never throws for a missing key — in development it returns a\n * path-stringifying fallback proxy — so a plain `getIntlayer` call cannot tell\n * \"missing namespace\" apart from \"resolved content\". The registry membership\n * check makes the distinction explicit before resolving.\n */\nconst getDictionaryOrUndefined = (\n namespace: DictionaryKeys,\n locale: LocalesValues\n): unknown => {\n if (!(namespace in getDictionaries())) return undefined;\n\n return getIntlayer(namespace, locale);\n};\n\n/**\n * Dictionary searched for one namespace, `undefined` when unregistered.\n *\n * `primaryDictionaryContent` is the pre-resolved content of the first default\n * namespace, when the call may use it.\n */\nconst getNamespaceDictionary = (\n candidateNamespace: string,\n defaultNamespaces: string | readonly string[],\n locale: LocalesValues,\n primaryDictionaryContent: unknown\n): unknown => {\n if (\n primaryDictionaryContent !== undefined &&\n candidateNamespace === getNamespaceAt(defaultNamespaces, 0)\n ) {\n return primaryDictionaryContent;\n }\n\n const dictionary = getDictionaryOrUndefined(\n candidateNamespace as DictionaryKeys,\n locale\n );\n\n // i18next's default namespace is `translation`, but a single-file JSON\n // source (no `{{key}}` segment) is loaded as the root `index` dictionary.\n // When a *default* namespace is not itself a registered dictionary, fall\n // back to `index` so `t('login.heroSubtitle')` resolves against the\n // whole-file dictionary. Other namespaces (`ns:` prefix, `ns` option,\n // fallback namespaces) never do, so a genuinely missing one is skipped.\n if (\n dictionary === undefined &&\n candidateNamespace !== ROOT_DICTIONARY_KEY &&\n hasNamespace(defaultNamespaces, candidateNamespace)\n ) {\n return getDictionaryOrUndefined(\n ROOT_DICTIONARY_KEY as DictionaryKeys,\n locale\n );\n }\n\n return dictionary;\n};\n\n/** Value of the first key candidate found in `dictionary`. */\nconst findKeyCandidate = (\n dictionary: unknown,\n keyCandidates: readonly string[],\n keySeparator: string | false\n): unknown => {\n for (const candidateKey of keyCandidates) {\n const value = navigatePath(dictionary, candidateKey, keySeparator);\n if (value !== null && value !== undefined) return value;\n }\n\n return undefined;\n};\n\n/**\n * Builds the ordered list of key candidates following i18next's resolution\n * order: context + plural → context → plural → exact key.\n */\nconst buildKeyCandidates = (\n path: string,\n locale: string,\n count: number | undefined,\n context: string | undefined,\n ordinal: boolean\n): string[] => {\n const candidates: string[] = [];\n\n const pluralCategory =\n count === undefined\n ? undefined\n : new Intl.PluralRules(locale, {\n type: ordinal ? 'ordinal' : 'cardinal',\n }).select(count);\n\n if (context) {\n if (pluralCategory) {\n if (ordinal) {\n candidates.push(`${path}_${context}_ordinal_${pluralCategory}`);\n }\n candidates.push(`${path}_${context}_${pluralCategory}`);\n if (count !== 1) candidates.push(`${path}_${context}_plural`);\n }\n candidates.push(`${path}_${context}`);\n }\n\n if (pluralCategory) {\n if (ordinal) candidates.push(`${path}_ordinal_${pluralCategory}`);\n candidates.push(`${path}_${pluralCategory}`);\n // Legacy i18next v3 JSON suffix\n if (count !== 1) candidates.push(`${path}_plural`);\n }\n\n candidates.push(path);\n\n return candidates;\n};\n\n/** Whether an interpolation value is absent (`null` or `undefined`). */\nconst isMissingValue = (value: unknown): boolean =>\n value === undefined || value === null;\n\n/**\n * Sets one interpolation value, escaped when asked, and its raw `-name` alias\n * read by `{{- name}}` placeholders.\n */\nconst setInterpolationValue = (\n values: MessageValues,\n valueName: string,\n value: unknown,\n shouldEscape: boolean\n): void => {\n values[valueName] = shouldEscape ? escapeInterpolationValue(value) : value;\n values[`${UNESCAPED_VALUE_PREFIX}${valueName}`] = value;\n};\n\n/**\n * Extracts interpolation values from i18next `t()` options.\n *\n * With `escapeValue` (overridden per call by `interpolation.escapeValue`),\n * values are HTML-escaped like i18next does; each value stays reachable\n * unescaped as `-name` for `{{- name}}` placeholders.\n */\nexport const getInterpolationValues = (\n options?: TOptions,\n escapeValue = false\n): MessageValues => {\n if (!options || typeof options !== 'object') return {};\n\n const shouldEscape = options.interpolation?.escapeValue ?? escapeValue;\n const values: MessageValues = {};\n const replace = (options as { replace?: MessageValues }).replace;\n\n if (replace) {\n for (const valueName of Object.keys(replace)) {\n setInterpolationValue(\n values,\n valueName,\n replace[valueName],\n shouldEscape\n );\n }\n\n // `count` and `context` are always interpolatable, even with `replace`\n if (options.count !== undefined && isMissingValue(values.count)) {\n setInterpolationValue(values, 'count', options.count, shouldEscape);\n }\n if (options.context !== undefined && isMissingValue(values.context)) {\n setInterpolationValue(values, 'context', options.context, shouldEscape);\n }\n return values;\n }\n\n for (const optionKey of Object.keys(options)) {\n if (!CONTROL_OPTION_KEYS.has(optionKey)) {\n setInterpolationValue(\n values,\n optionKey,\n (options as Record<string, unknown>)[optionKey],\n shouldEscape\n );\n }\n }\n return values;\n};\n\nexport type ResolveTranslationParams = {\n /** Locale to resolve against. */\n locale: LocalesValues;\n /**\n * Default namespace (dictionary key) when the key has no `ns:` prefix. A\n * list (i18next `defaultNS` array) is tried in order.\n */\n namespace: string | readonly string[];\n /**\n * Namespaces tried, in order, after the requested ones: i18next's\n * `fallbackNS` as written (a string, a list or `false`). Like i18next, they\n * also apply to `ns:` prefixes and the `ns` option.\n */\n fallbackNamespaces?: NamespaceOption;\n /**\n * HTML-escapes interpolated values (i18next `interpolation.escapeValue`).\n * Defaults to `false`; a per-call `interpolation.escapeValue` wins.\n */\n escapeValue?: boolean;\n /** The translation key, possibly `ns:path.to.key`. */\n key: string;\n /** i18next `t()` options (interpolation values, count, context, …). */\n options?: TOptions;\n /** Custom key separator (`init({ keySeparator })`). */\n keySeparator?: string | false;\n /** Custom namespace separator (`init({ nsSeparator })`). */\n nsSeparator?: string | false;\n /** Internal `$t()` nesting recursion depth. */\n depth?: number;\n /**\n * Pre-resolved content of the (first) `namespace` dictionary for `locale`.\n *\n * Supplied by the build-optimized `useDictionary` / `getDictionary`\n * variants, where the dictionary is imported at build time instead of read\n * from the runtime registry. Only used when the call resolves to the\n * default `namespace` without a locale override — cross-namespace\n * (`other:key`, `{ ns }`, fallback namespaces) and `{ lng }` lookups still\n * go through `getIntlayer`.\n */\n dictionaryContent?: unknown;\n};\n\n/**\n * Resolves a single translation key the i18next way against intlayer\n * dictionaries.\n *\n * Returns the resolved value: a string in the common case, or an\n * object/array when `returnObjects: true`. Returns `undefined` when the key\n * cannot be resolved (caller decides between `defaultValue`, fallback keys\n * and key echo).\n */\nexport const resolveTranslation = ({\n locale,\n namespace,\n key,\n options,\n keySeparator = '.',\n nsSeparator = ':',\n fallbackNamespaces,\n escapeValue = false,\n depth = 0,\n dictionaryContent,\n}: ResolveTranslationParams): unknown => {\n // Namespace resolution: `ns:` prefix > `ns` option > default namespaces.\n // The fallback namespaces are searched after them in every case, as\n // i18next does. Options are read as written, so no list is copied.\n let requestedNamespaces: string | readonly string[] = namespace;\n let path = key;\n\n if (nsSeparator !== false && key.includes(nsSeparator)) {\n const separatorIndex = key.indexOf(nsSeparator);\n requestedNamespaces = key.slice(0, separatorIndex);\n path = key.slice(separatorIndex + nsSeparator.length);\n } else if (options?.ns) {\n requestedNamespaces = options.ns as string | readonly string[];\n }\n\n const count = typeof options?.count === 'number' ? options.count : undefined;\n const context =\n options?.context !== undefined ? String(options.context) : undefined;\n const ordinal = options?.ordinal === true;\n\n const resolvedLocale = ((options?.lng as string) ?? locale) as LocalesValues;\n const primaryDictionaryContent =\n options?.lng === undefined ? dictionaryContent : undefined;\n\n const requestedNamespaceCount = getNamespaceCount(requestedNamespaces);\n const namespaceCount =\n requestedNamespaceCount + getNamespaceCount(fallbackNamespaces);\n\n let keyCandidates: string[] | undefined;\n let resolvedValue: unknown;\n let resolvedNamespace: string | undefined;\n\n for (\n let namespaceIndex = 0;\n namespaceIndex < namespaceCount && resolvedNamespace === undefined;\n namespaceIndex++\n ) {\n const isFallbackNamespace = namespaceIndex >= requestedNamespaceCount;\n const candidateNamespace = isFallbackNamespace\n ? getNamespaceAt(\n fallbackNamespaces as string | readonly string[],\n namespaceIndex - requestedNamespaceCount\n )\n : getNamespaceAt(requestedNamespaces, namespaceIndex);\n\n // A fallback namespace that was already requested has been searched\n if (\n isFallbackNamespace &&\n hasNamespace(requestedNamespaces, candidateNamespace)\n ) {\n continue;\n }\n\n const dictionary = getNamespaceDictionary(\n candidateNamespace,\n namespace,\n resolvedLocale,\n primaryDictionaryContent\n );\n if (dictionary === undefined) continue;\n\n keyCandidates ??= buildKeyCandidates(\n path,\n resolvedLocale as string,\n count,\n context,\n ordinal\n );\n\n const value = findKeyCandidate(dictionary, keyCandidates, keySeparator);\n if (value !== undefined) {\n resolvedValue = value;\n resolvedNamespace = candidateNamespace;\n }\n }\n\n if (resolvedNamespace === undefined) return undefined;\n\n // `returnObjects: true` — return the raw subtree\n if (\n options?.returnObjects &&\n typeof resolvedValue === 'object' &&\n resolvedValue !== null\n ) {\n return resolvedValue;\n }\n\n const values = getInterpolationValues(options, escapeValue);\n\n // Dictionary content was converted to intlayer nodes at build time, so no\n // i18next parser is needed here — which keeps it out of the app bundle.\n let resolved = resolveMessageNodeToString(\n resolvedValue,\n values,\n resolvedLocale,\n undefined,\n 'double-brace'\n );\n\n // `$t(key)` nesting\n if (depth < MAX_NESTING_DEPTH && resolved.includes('$t(')) {\n resolved = resolved.replace(\n /\\$t\\(\\s*([^),]+?)\\s*(?:,[^)]*)?\\)/g,\n (match, nestedKey: string) => {\n const nestedValue = resolveTranslation({\n locale,\n namespace: resolvedNamespace,\n key: nestedKey.trim(),\n options,\n keySeparator,\n nsSeparator,\n fallbackNamespaces,\n escapeValue,\n depth: depth + 1,\n dictionaryContent:\n resolvedNamespace === getNamespaceAt(namespace, 0)\n ? dictionaryContent\n : undefined,\n });\n return typeof nestedValue === 'string' ? nestedValue : match;\n }\n );\n }\n\n return resolved;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,MAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,oBAAoB;;AAG1B,MAAM,uBAA+C;CACnD,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;AACP;;;;;;AAOA,MAAM,yBAAyB;;;;;AAM/B,MAAM,4BAA4B,UAA4B;CAC5D,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,QACX,aACC,cAAc,qBAAqB,cAAc,SACpD;CAGF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,wBAAwB;CAEnE,IACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,eAAe,KAAK,MAAM,OAAO,WAExC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,gBAAgB,CACpD,UACA,yBAAyB,UAAU,CACrC,CAAC,CACH;CAGF,OAAO;AACT;;;;;AAMA,MAAa,mBAAmB,eAAkC;CAChE,IAAI,CAAC,YAAY,OAAO,CAAC;CAEzB,OAAQ,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAC9D;;AAMA,MAAM,qBAAqB,eAAwC;CACjE,IAAI,CAAC,YAAY,OAAO;CAExB,OAAO,OAAO,eAAe,WAAW,IAAI,WAAW;AACzD;;AAGA,MAAM,kBACJ,YACA,UAEA,OAAO,eAAe,WAAW,aAAc,WAAW;;AAG5D,MAAM,gBACJ,YACA,cACY;CACZ,IAAI,CAAC,YAAY,OAAO;CAExB,OAAO,OAAO,eAAe,WACzB,eAAe,YACf,WAAW,SAAS,SAAS;AACnC;;;;;;;AA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C,oBACA;EACR,CAAC;EACD,OAAO,OAAO,gBAAgB,WAAW,cAAc;CACzD,CACF;CAGF,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/i18next",
|
|
3
|
-
"version": "9.9.3
|
|
3
|
+
"version": "9.9.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "i18next API adapter for intlayer — drop-in compatibility layer that exposes the i18next interface while using @intlayer/core under the hood",
|
|
6
6
|
"keywords": [
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@intlayer/config": "9.9.3
|
|
79
|
-
"@intlayer/core": "9.9.3
|
|
80
|
-
"@intlayer/dictionaries-entry": "9.9.3
|
|
81
|
-
"@intlayer/engine": "9.9.3
|
|
82
|
-
"@intlayer/types": "9.9.3
|
|
83
|
-
"vite-intlayer": "9.9.3
|
|
78
|
+
"@intlayer/config": "9.9.3",
|
|
79
|
+
"@intlayer/core": "9.9.3",
|
|
80
|
+
"@intlayer/dictionaries-entry": "9.9.3",
|
|
81
|
+
"@intlayer/engine": "9.9.3",
|
|
82
|
+
"@intlayer/types": "9.9.3",
|
|
83
|
+
"vite-intlayer": "9.9.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@types/node": "^26",
|