@intlayer/vue-i18n 9.0.0-canary.8 → 9.0.0

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.
@@ -3,21 +3,19 @@ import { parseTranslateArguments, resolveVueMessage } from "./resolveVueMessage.
3
3
  import { internationalization, log } from "@intlayer/config/built";
4
4
  import * as ANSIColors from "@intlayer/config/colors";
5
5
  import { colorize, getAppLogger } from "@intlayer/config/logger";
6
+ import { getIntlayer } from "@intlayer/core/interpreter";
7
+ import { navigatePath } from "@intlayer/core/messageFormat";
6
8
  import { computed, inject } from "vue";
7
9
  import { createIntlayerClient, installIntlayer, useLocale } from "vue-intlayer";
8
10
 
9
11
  //#region src/createI18n.ts
10
12
  const VERSION = "9.13.1";
11
13
  const I18nInjectionKey = Symbol("global-i18n");
12
- const navigatePath = (objectValue, path) => {
13
- if (!path) return objectValue;
14
- let current = objectValue;
15
- for (const part of path.split(".")) {
16
- if (current === null || current === void 0 || typeof current !== "object") return;
17
- current = current[part];
18
- }
19
- return current;
20
- };
14
+ /**
15
+ * Dictionary key used for keys that carry no explicit namespace and are not
16
+ * dot-namespaced (i18next-style flat keys, e.g. `t('greeting')`).
17
+ */
18
+ const DEFAULT_NAMESPACE = "translation";
21
19
  /**
22
20
  * Looks up a raw value for a vue-i18n key against intlayer dictionaries.
23
21
  *
@@ -27,17 +25,39 @@ const navigatePath = (objectValue, path) => {
27
25
  * 3. The first key segment as the dictionary key (`'home.title'` →
28
26
  * dictionary `home`, path `title`)
29
27
  */
30
- const lookupRaw = (namespace, key) => {
28
+ /** Resolves a single dictionary by key and navigates to the given path. */
29
+ const lookupInDictionary = (locale, dictionaryKey, path) => {
30
+ try {
31
+ const value = navigatePath(getIntlayer(dictionaryKey, locale), path);
32
+ if (value !== void 0 && value !== null) return value;
33
+ } catch {}
34
+ };
35
+ const lookupRaw = (locale, namespace, key) => {
36
+ let targetNamespace = namespace;
37
+ let path = key;
31
38
  if (key.includes(":")) {
32
39
  const separatorIndex = key.indexOf(":");
33
- key.slice(0, separatorIndex);
34
- key.slice(separatorIndex + 1);
40
+ targetNamespace = key.slice(0, separatorIndex);
41
+ path = key.slice(separatorIndex + 1);
42
+ }
43
+ if (targetNamespace) {
44
+ const value = lookupInDictionary(locale, targetNamespace, path);
45
+ if (value !== void 0) return value;
46
+ }
47
+ if (path.includes(".")) {
48
+ const separatorIndex = path.indexOf(".");
49
+ const value = lookupInDictionary(locale, path.slice(0, separatorIndex), path.slice(separatorIndex + 1));
50
+ if (value !== void 0) return value;
51
+ }
52
+ if (!targetNamespace) {
53
+ const value = lookupInDictionary(locale, DEFAULT_NAMESPACE, path);
54
+ if (value !== void 0) return value;
35
55
  }
36
56
  };
37
57
  /** Translates a key with vue-i18n's polymorphic argument list. */
38
58
  const translateKey = (locale, namespace, key, args, fallbackMessages) => {
39
59
  const { values, count, defaultMessage } = parseTranslateArguments(args);
40
- const rawValue = lookupRaw(namespace, key);
60
+ const rawValue = lookupRaw(locale, namespace, key);
41
61
  if (rawValue === void 0) {
42
62
  if (fallbackMessages?.[locale]) {
43
63
  const targetPath = namespace ? `${namespace}.${key}` : key;
@@ -76,8 +96,8 @@ const createI18n = ((options = {}) => {
76
96
  fallbackLocale: options.fallbackLocale ?? internationalization?.defaultLocale,
77
97
  t: globalTranslate,
78
98
  tc: globalTranslate,
79
- te: (key) => lookupRaw(void 0, key) !== void 0,
80
- tm: (key) => lookupRaw(void 0, key) ?? {},
99
+ te: (key) => lookupRaw(currentLocale(), void 0, key) !== void 0,
100
+ tm: (key) => lookupRaw(currentLocale(), void 0, key) ?? {},
81
101
  rt: (message, ...args) => {
82
102
  const { values, count } = parseTranslateArguments(args);
83
103
  return resolveVueMessage(message, values, count, currentLocale());
@@ -150,7 +170,8 @@ const createI18n = ((options = {}) => {
150
170
  /**
151
171
  * Composable providing a typed `t()` function scoped to a dictionary namespace.
152
172
  * Pass `{ namespace: 'myDict' }` to restrict keys to valid dot-notation paths
153
- * within that intlayer dictionary (autocompleted and validated at compile time).
173
+ * within that intlayer dictionary (autocompleted and validated at compile
174
+ * time) and resolve return types from the content at each path.
154
175
  *
155
176
  * Supports vue-i18n's full message syntax: named (`{name}`) and list (`{0}`)
156
177
  * interpolation, pipe choice messages (`'car | cars'` with a count argument),
@@ -159,11 +180,11 @@ const createI18n = ((options = {}) => {
159
180
  * @example
160
181
  * ```ts
161
182
  * const { t } = useI18n({ namespace: 'about' });
162
- * t('counter.label'); // ✓ typed; compile error if key doesn't exist
183
+ * t('counter.label'); // ✓ typed key and return value
163
184
  * t('apples', 5); // pipe plural choice
164
185
  * ```
165
186
  */
166
- const useI18n = (options) => {
187
+ const useI18n = ((options) => {
167
188
  const { locale: currentLocale, setLocale, availableLocales } = useLocale();
168
189
  const fallbackMessages = inject(I18nInjectionKey)?.__optionsMessages;
169
190
  const namespace = options?.namespace;
@@ -175,14 +196,14 @@ const useI18n = (options) => {
175
196
  setLocale(newLocale);
176
197
  }
177
198
  });
178
- const translate = (key, ...args) => translateKey(currentLocale.value, namespace, String(key), args, fallbackMessages);
199
+ const translate = (key, ...args) => translateKey(currentLocale.value, namespace, key, args, fallbackMessages);
179
200
  return {
180
201
  locale: localeRef,
181
202
  availableLocales,
182
203
  t: translate,
183
204
  tc: translate,
184
- te: (key) => lookupRaw(namespace, String(key)) !== void 0,
185
- tm: (key) => lookupRaw(namespace, String(key)) ?? {},
205
+ te: (key) => lookupRaw(currentLocale.value, namespace, key) !== void 0,
206
+ tm: (key) => lookupRaw(currentLocale.value, namespace, key) ?? {},
186
207
  rt: (message, ...args) => {
187
208
  const { values, count } = parseTranslateArguments(args);
188
209
  return resolveVueMessage(message, values, count, currentLocale.value);
@@ -190,7 +211,7 @@ const useI18n = (options) => {
190
211
  d: (value, formatOrOptions) => formatDateValue(value, formatOrOptions, currentLocale.value, datetimeFormats),
191
212
  n: (value, formatOrOptions) => formatNumberValue(value, formatOrOptions, currentLocale.value, numberFormats)
192
213
  };
193
- };
214
+ });
194
215
 
195
216
  //#endregion
196
217
  export { I18nInjectionKey, VERSION, createI18n, useI18n };
@@ -1 +1 @@
1
- {"version":3,"file":"createI18n.mjs","names":[],"sources":["../../src/createI18n.ts"],"sourcesContent":["import { internationalization, log } from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n App,\n DirectiveBinding,\n InjectionKey,\n WritableComputedRef,\n} from 'vue';\nimport { computed, inject } from 'vue';\nimport type { createI18n as _createI18n, I18n } from 'vue-i18n';\nimport { createIntlayerClient, installIntlayer, useLocale } from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\n\nexport const VERSION = '9.13.1';\nexport const I18nInjectionKey: InjectionKey<I18n> = Symbol('global-i18n');\n\nconst navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n let current: unknown = objectValue;\n for (const part of path.split('.')) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Looks up a raw value for a vue-i18n key against intlayer dictionaries.\n *\n * Resolution order:\n * 1. `ns:key` prefix → dictionary `ns`\n * 2. The default namespace dictionary with the full dot-path\n * 3. The first key segment as the dictionary key (`'home.title'` →\n * dictionary `home`, path `title`)\n */\nconst lookupRaw = (namespace: string | undefined, key: string): unknown => {\n let _targetNamespace = namespace;\n let _path = key;\n\n if (key.includes(':')) {\n const separatorIndex = key.indexOf(':');\n _targetNamespace = key.slice(0, separatorIndex);\n _path = key.slice(separatorIndex + 1);\n }\n\n // Without getDictionaries, global translation fallback to intlayer dictionaries\n // is disabled for bundle optimization purposes.\n // We only lookup if the namespace exists globally, but since we don't have getDictionaries\n // we rely strictly on what vue-i18n already has in its messages.\n\n return undefined;\n};\n\n/** Translates a key with vue-i18n's polymorphic argument list. */\nconst translateKey = (\n locale: string,\n namespace: string | undefined,\n key: string,\n args: unknown[],\n fallbackMessages?: Record<string, unknown>\n): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n\n const rawValue = lookupRaw(namespace, key);\n\n if (rawValue === undefined) {\n if (fallbackMessages?.[locale]) {\n // Defer to the user's provided messages if not found in dictionaries\n const targetPath = namespace ? `${namespace}.${key}` : key;\n const fallbackValue = navigatePath(fallbackMessages[locale], targetPath);\n if (fallbackValue !== undefined) {\n return resolveVueMessage(\n fallbackValue,\n values,\n count,\n locale as LocalesValues\n );\n }\n }\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n locale as LocalesValues\n );\n }\n return key;\n }\n\n return resolveVueMessage(rawValue, values, count, locale as LocalesValues);\n};\n\nconst getAvailableLocales = (): string[] =>\n internationalization?.locales?.map(String) ?? [];\n\nconst warnDeprecatedRuntimeMessages = (location: string) => {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize(location, ANSIColors.CYAN)} has no effect with ${colorize('@intlayer/vue-i18n', ANSIColors.MAGENTA)} — translations are managed by the compiled intlayer dictionaries.`\n );\n};\n\n/** Value accepted by the `v-t` directive. */\ntype TranslateDirectiveValue =\n | string\n | { path: string; args?: Record<string, unknown>; choice?: number };\n\nexport const createI18n: typeof _createI18n = ((\n options: Record<string, unknown> = {}\n) => {\n const fallbackMessages = options.messages as\n | Record<string, unknown>\n | undefined;\n\n if (\n options.messages !== undefined &&\n process.env.NODE_ENV === 'development'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('createI18n', ANSIColors.CYAN)}: the ${colorize('`messages`', ANSIColors.CYAN)} option is used as a fallback. For optimal bundle size, remove the locale JSON imports and use ${colorize('useDictionary', ANSIColors.CYAN)} or compile your intlayer dictionaries instead:\\n ${colorize('Before:', ANSIColors.GREY)} createI18n({ messages: { en, fr, … } })\\n ${colorize('After: ', ANSIColors.GREY)} createI18n({})`\n );\n }\n\n const client = createIntlayerClient(options.locale as LocalesValues);\n\n const datetimeFormats = options.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const currentLocale = (): string => String(client.locale.value);\n\n /** Writable ref matching vue-i18n's composition-mode `global.locale`. */\n const localeRef: WritableComputedRef<string> = computed({\n get: () => currentLocale(),\n set: (newLocale: string) => {\n client.setLocale(newLocale as LocalesValues);\n },\n });\n\n const globalTranslate = (key: string, ...args: unknown[]): string =>\n translateKey(currentLocale(), undefined, key, args, fallbackMessages);\n\n const globalDate = (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(value, formatOrOptions, currentLocale(), datetimeFormats);\n\n const globalNumber = (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(value, formatOrOptions, currentLocale(), numberFormats);\n\n const global = {\n locale: localeRef,\n availableLocales: getAvailableLocales(),\n fallbackLocale: (options.fallbackLocale ??\n internationalization?.defaultLocale) as string,\n t: globalTranslate,\n tc: globalTranslate,\n te: (key: string): boolean => lookupRaw(undefined, key) !== undefined,\n tm: (key: string): unknown => lookupRaw(undefined, key) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale() as LocalesValues\n );\n },\n d: globalDate,\n n: globalNumber,\n setLocaleMessage: (_locale: string, _messages: unknown) => {\n warnDeprecatedRuntimeMessages('setLocaleMessage');\n },\n mergeLocaleMessage: (_locale: string, _messages: unknown) => {\n warnDeprecatedRuntimeMessages('mergeLocaleMessage');\n },\n getLocaleMessage: (_locale: string): Record<string, unknown> => {\n warnDeprecatedRuntimeMessages('getLocaleMessage');\n // We do not load global dictionaries anymore for bundle optimization.\n // The user should use useDictionary or rely on manually provided messages.\n return {};\n },\n };\n\n /** Legacy Options-API facade (`this.$i18n`) with a string `locale`. */\n const legacyI18n = {\n get locale(): string {\n return currentLocale();\n },\n set locale(newLocale: string) {\n client.setLocale(newLocale as LocalesValues);\n },\n get availableLocales(): string[] {\n return getAvailableLocales();\n },\n t: globalTranslate,\n tc: globalTranslate,\n te: global.te,\n tm: global.tm,\n rt: global.rt,\n d: globalDate,\n n: globalNumber,\n };\n\n const applyTranslateDirective = (\n element: HTMLElement,\n binding: DirectiveBinding<TranslateDirectiveValue>\n ) => {\n const bindingValue = binding.value;\n if (typeof bindingValue === 'string') {\n element.textContent = globalTranslate(bindingValue);\n } else if (bindingValue && typeof bindingValue === 'object') {\n const directiveArgs: unknown[] = [];\n if (bindingValue.args) directiveArgs.push(bindingValue.args);\n if (typeof bindingValue.choice === 'number')\n directiveArgs.push(bindingValue.choice);\n element.textContent = globalTranslate(\n bindingValue.path,\n ...directiveArgs\n );\n }\n };\n\n const i18nInstance = {\n global,\n mode: options.legacy === true ? 'legacy' : 'composition',\n __optionsMessages: fallbackMessages,\n install(app: App) {\n installIntlayer(app, {\n locale: options.locale as LocalesValues,\n });\n\n // Provide under I18nInjectionKey to satisfy inject(I18nInjectionKey) calls\n app.provide(I18nInjectionKey, i18nInstance as unknown as I18n);\n\n // Legacy API support ($t / $tc / $te / $tm / $rt / $d / $n / $i18n)\n app.config.globalProperties.$t = globalTranslate;\n (app.config.globalProperties as Record<string, unknown>).$tc =\n globalTranslate;\n (app.config.globalProperties as Record<string, unknown>).$te = global.te;\n (app.config.globalProperties as Record<string, unknown>).$tm = global.tm;\n (app.config.globalProperties as Record<string, unknown>).$rt = global.rt;\n (app.config.globalProperties as Record<string, unknown>).$d = globalDate;\n (app.config.globalProperties as Record<string, unknown>).$n =\n globalNumber;\n (app.config.globalProperties as Record<string, unknown>).$i18n =\n legacyI18n;\n\n // `v-t` directive support\n app.directive('t', {\n beforeMount: applyTranslateDirective,\n updated: applyTranslateDirective,\n });\n },\n };\n\n return i18nInstance as unknown as I18n;\n}) as typeof _createI18n;\n\n/**\n * Composable providing a typed `t()` function scoped to a dictionary namespace.\n * Pass `{ namespace: 'myDict' }` to restrict keys to valid dot-notation paths\n * within that intlayer dictionary (autocompleted and validated at compile time).\n *\n * Supports vue-i18n's full message syntax: named (`{name}`) and list (`{0}`)\n * interpolation, pipe choice messages (`'car | cars'` with a count argument),\n * plus `te`/`tm`/`rt` and `Intl`-backed `d()`/`n()` formatters.\n *\n * @example\n * ```ts\n * const { t } = useI18n({ namespace: 'about' });\n * t('counter.label'); // ✓ typed; compile error if key doesn't exist\n * t('apples', 5); // pipe plural choice\n * ```\n */\nexport const useI18n = <N extends DictionaryKeys = DictionaryKeys>(\n options?: Record<string, unknown> & { namespace?: N }\n): {\n locale: WritableComputedRef<string>;\n availableLocales: string[];\n t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;\n tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;\n rt: (message: unknown, ...args: unknown[]) => string;\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ) => string;\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ) => string;\n} => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n const instance = inject(I18nInjectionKey) as\n | Record<string, unknown>\n | undefined;\n const fallbackMessages = instance?.__optionsMessages as\n | Record<string, unknown>\n | undefined;\n\n const namespace = options?.namespace as string | undefined as N | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const translate = <P extends ValidDotPathsFor<N>>(\n key: P,\n ...args: unknown[]\n ): string =>\n translateKey(\n currentLocale.value,\n namespace,\n String(key),\n args,\n fallbackMessages\n );\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: <P extends ValidDotPathsFor<N>>(key: P): boolean =>\n lookupRaw(namespace, String(key)) !== undefined,\n tm: <P extends ValidDotPathsFor<N>>(key: P): unknown =>\n lookupRaw(namespace, String(key)) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n};\n"],"mappings":";;;;;;;;;AA4BA,MAAa,UAAU;AACvB,MAAa,mBAAuC,OAAO,cAAc;AAEzE,MAAM,gBAAgB,aAAsB,SAA0B;AACpE,KAAI,CAAC,KAAM,QAAO;CAClB,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE;AAClC,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;;;;;;;;;AAYT,MAAM,aAAa,WAA+B,QAAyB;AAIzE,KAAI,IAAI,SAAS,IAAI,EAAE;EACrB,MAAM,iBAAiB,IAAI,QAAQ,IAAI;AACvC,EAAmB,IAAI,MAAM,GAAG,eAAe;AAC/C,EAAQ,IAAI,MAAM,iBAAiB,EAAE;;;;AAYzC,MAAM,gBACJ,QACA,WACA,KACA,MACA,qBACW;CACX,MAAM,EAAE,QAAQ,OAAO,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AE;EACzC,KAAK,SAAkB,GAAG,SAA4B;GACpD,MAAM,EAAE,QAAQ,UAAU,wBAAwB,KAAK;AACvD,UAAO,kBACL,SACA,QACA,OACA,cAAc,MACf;;EAEH,IACE,OACA,oBAEA,gBACE,OACA,iBACA,cAAc,OACd,gBACD;EACH,IACE,OACA,oBAEA,kBACE,OACA,iBACA,cAAc,OACd,cACD;EACJ"}
1
+ {"version":3,"file":"createI18n.mjs","names":[],"sources":["../../src/createI18n.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 { navigatePath } from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n App,\n DirectiveBinding,\n InjectionKey,\n WritableComputedRef,\n} from 'vue';\nimport { computed, inject } from 'vue';\nimport type { createI18n as _createI18n, I18n } from 'vue-i18n';\nimport { createIntlayerClient, installIntlayer, useLocale } from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\nimport type { LooseComposer, TypedComposer } from './typedComposer';\n\nexport const VERSION = '9.13.1';\nexport const I18nInjectionKey: InjectionKey<I18n> = Symbol('global-i18n');\n\n/**\n * Dictionary key used for keys that carry no explicit namespace and are not\n * dot-namespaced (i18next-style flat keys, e.g. `t('greeting')`).\n */\nconst DEFAULT_NAMESPACE = 'translation';\n\n/**\n * Looks up a raw value for a vue-i18n key against intlayer dictionaries.\n *\n * Resolution order:\n * 1. `ns:key` prefix → dictionary `ns`\n * 2. The default namespace dictionary with the full dot-path\n * 3. The first key segment as the dictionary key (`'home.title'` →\n * dictionary `home`, path `title`)\n */\n/** Resolves a single dictionary by key and navigates to the given path. */\nconst lookupInDictionary = (\n locale: string,\n dictionaryKey: string,\n path: string\n): unknown => {\n try {\n const dictionary = getIntlayer(\n dictionaryKey as DictionaryKeys,\n locale as LocalesValues\n );\n const value = navigatePath(dictionary, path);\n if (value !== undefined && value !== null) return value;\n } catch {}\n return undefined;\n};\n\nconst lookupRaw = (\n locale: string,\n namespace: string | undefined,\n key: string\n): unknown => {\n let targetNamespace = namespace;\n let path = key;\n\n if (key.includes(':')) {\n const separatorIndex = key.indexOf(':');\n targetNamespace = key.slice(0, separatorIndex);\n path = key.slice(separatorIndex + 1);\n }\n\n // 1. Explicit namespace (from `useI18n({ namespace })` or a `ns:key` prefix)\n if (targetNamespace) {\n const value = lookupInDictionary(locale, targetNamespace, path);\n if (value !== undefined) return value;\n }\n\n // 2. First key segment as the dictionary key (`'home.title'` →\n // dictionary `home`, path `title`). This makes the global `t()` work\n // without a namespace, matching how intlayer splits dictionaries by key.\n if (path.includes('.')) {\n const separatorIndex = path.indexOf('.');\n const value = lookupInDictionary(\n locale,\n path.slice(0, separatorIndex),\n path.slice(separatorIndex + 1)\n );\n if (value !== undefined) return value;\n }\n\n // 3. Default `translation` bucket for flat, namespace-less keys.\n if (!targetNamespace) {\n const value = lookupInDictionary(locale, DEFAULT_NAMESPACE, path);\n if (value !== undefined) return value;\n }\n\n return undefined;\n};\n\n/** Translates a key with vue-i18n's polymorphic argument list. */\nconst translateKey = (\n locale: string,\n namespace: string | undefined,\n key: string,\n args: unknown[],\n fallbackMessages?: Record<string, unknown>\n): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n\n const rawValue = lookupRaw(locale, namespace, key);\n\n if (rawValue === undefined) {\n if (fallbackMessages?.[locale]) {\n // Defer to the user's provided messages if not found in dictionaries\n const targetPath = namespace ? `${namespace}.${key}` : key;\n const fallbackValue = navigatePath(fallbackMessages[locale], targetPath);\n if (fallbackValue !== undefined) {\n return resolveVueMessage(\n fallbackValue,\n values,\n count,\n locale as LocalesValues\n );\n }\n }\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n locale as LocalesValues\n );\n }\n return key;\n }\n\n return resolveVueMessage(rawValue, values, count, locale as LocalesValues);\n};\n\nconst getAvailableLocales = (): string[] =>\n internationalization?.locales?.map(String) ?? [];\n\nconst warnDeprecatedRuntimeMessages = (location: string) => {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize(location, ANSIColors.CYAN)} has no effect with ${colorize('@intlayer/vue-i18n', ANSIColors.MAGENTA)} — translations are managed by the compiled intlayer dictionaries.`\n );\n};\n\n/** Value accepted by the `v-t` directive. */\ntype TranslateDirectiveValue =\n | string\n | { path: string; args?: Record<string, unknown>; choice?: number };\n\nexport const createI18n: typeof _createI18n = ((\n options: Record<string, unknown> = {}\n) => {\n const fallbackMessages = options.messages as\n | Record<string, unknown>\n | undefined;\n\n if (\n options.messages !== undefined &&\n process.env.NODE_ENV === 'development'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('createI18n', ANSIColors.CYAN)}: the ${colorize('`messages`', ANSIColors.CYAN)} option is used as a fallback. For optimal bundle size, remove the locale JSON imports and use ${colorize('useDictionary', ANSIColors.CYAN)} or compile your intlayer dictionaries instead:\\n ${colorize('Before:', ANSIColors.GREY)} createI18n({ messages: { en, fr, … } })\\n ${colorize('After: ', ANSIColors.GREY)} createI18n({})`\n );\n }\n\n const client = createIntlayerClient(options.locale as LocalesValues);\n\n const datetimeFormats = options.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const currentLocale = (): string => String(client.locale.value);\n\n /** Writable ref matching vue-i18n's composition-mode `global.locale`. */\n const localeRef: WritableComputedRef<string> = computed({\n get: () => currentLocale(),\n set: (newLocale: string) => {\n client.setLocale(newLocale as LocalesValues);\n },\n });\n\n const globalTranslate = (key: string, ...args: unknown[]): string =>\n translateKey(currentLocale(), undefined, key, args, fallbackMessages);\n\n const globalDate = (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(value, formatOrOptions, currentLocale(), datetimeFormats);\n\n const globalNumber = (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(value, formatOrOptions, currentLocale(), numberFormats);\n\n const global = {\n locale: localeRef,\n availableLocales: getAvailableLocales(),\n fallbackLocale: (options.fallbackLocale ??\n internationalization?.defaultLocale) as string,\n t: globalTranslate,\n tc: globalTranslate,\n te: (key: string): boolean =>\n lookupRaw(currentLocale(), undefined, key) !== undefined,\n tm: (key: string): unknown =>\n lookupRaw(currentLocale(), undefined, key) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale() as LocalesValues\n );\n },\n d: globalDate,\n n: globalNumber,\n setLocaleMessage: (_locale: string, _messages: unknown) => {\n warnDeprecatedRuntimeMessages('setLocaleMessage');\n },\n mergeLocaleMessage: (_locale: string, _messages: unknown) => {\n warnDeprecatedRuntimeMessages('mergeLocaleMessage');\n },\n getLocaleMessage: (_locale: string): Record<string, unknown> => {\n warnDeprecatedRuntimeMessages('getLocaleMessage');\n // We do not load global dictionaries anymore for bundle optimization.\n // The user should use useDictionary or rely on manually provided messages.\n return {};\n },\n };\n\n /** Legacy Options-API facade (`this.$i18n`) with a string `locale`. */\n const legacyI18n = {\n get locale(): string {\n return currentLocale();\n },\n set locale(newLocale: string) {\n client.setLocale(newLocale as LocalesValues);\n },\n get availableLocales(): string[] {\n return getAvailableLocales();\n },\n t: globalTranslate,\n tc: globalTranslate,\n te: global.te,\n tm: global.tm,\n rt: global.rt,\n d: globalDate,\n n: globalNumber,\n };\n\n const applyTranslateDirective = (\n element: HTMLElement,\n binding: DirectiveBinding<TranslateDirectiveValue>\n ) => {\n const bindingValue = binding.value;\n if (typeof bindingValue === 'string') {\n element.textContent = globalTranslate(bindingValue);\n } else if (bindingValue && typeof bindingValue === 'object') {\n const directiveArgs: unknown[] = [];\n if (bindingValue.args) directiveArgs.push(bindingValue.args);\n if (typeof bindingValue.choice === 'number')\n directiveArgs.push(bindingValue.choice);\n element.textContent = globalTranslate(\n bindingValue.path,\n ...directiveArgs\n );\n }\n };\n\n const i18nInstance = {\n global,\n mode: options.legacy === true ? 'legacy' : 'composition',\n __optionsMessages: fallbackMessages,\n install(app: App) {\n installIntlayer(app, {\n locale: options.locale as LocalesValues,\n });\n\n // Provide under I18nInjectionKey to satisfy inject(I18nInjectionKey) calls\n app.provide(I18nInjectionKey, i18nInstance as unknown as I18n);\n\n // Legacy API support ($t / $tc / $te / $tm / $rt / $d / $n / $i18n)\n app.config.globalProperties.$t = globalTranslate;\n (app.config.globalProperties as Record<string, unknown>).$tc =\n globalTranslate;\n (app.config.globalProperties as Record<string, unknown>).$te = global.te;\n (app.config.globalProperties as Record<string, unknown>).$tm = global.tm;\n (app.config.globalProperties as Record<string, unknown>).$rt = global.rt;\n (app.config.globalProperties as Record<string, unknown>).$d = globalDate;\n (app.config.globalProperties as Record<string, unknown>).$n =\n globalNumber;\n (app.config.globalProperties as Record<string, unknown>).$i18n =\n legacyI18n;\n\n // `v-t` directive support\n app.directive('t', {\n beforeMount: applyTranslateDirective,\n updated: applyTranslateDirective,\n });\n },\n };\n\n return i18nInstance as unknown as I18n;\n}) as typeof _createI18n;\n\n/**\n * Overload set for {@link useI18n}: with a `namespace` option the composer is\n * fully typed against that dictionary (keys and return values); without one\n * the root scope applies — the first segment of each key designates the\n * dictionary (`t('about.title')`).\n */\ntype UseI18n = {\n <N extends DictionaryKeys>(\n options: Record<string, unknown> & { namespace: N }\n ): TypedComposer<N>;\n (\n options?: Record<string, unknown> & { namespace?: undefined }\n ): LooseComposer;\n};\n\n/**\n * Composable providing a typed `t()` function scoped to a dictionary namespace.\n * Pass `{ namespace: 'myDict' }` to restrict keys to valid dot-notation paths\n * within that intlayer dictionary (autocompleted and validated at compile\n * time) and resolve return types from the content at each path.\n *\n * Supports vue-i18n's full message syntax: named (`{name}`) and list (`{0}`)\n * interpolation, pipe choice messages (`'car | cars'` with a count argument),\n * plus `te`/`tm`/`rt` and `Intl`-backed `d()`/`n()` formatters.\n *\n * @example\n * ```ts\n * const { t } = useI18n({ namespace: 'about' });\n * t('counter.label'); // ✓ typed key and return value\n * t('apples', 5); // pipe plural choice\n * ```\n */\nexport const useI18n = ((\n options?: Record<string, unknown> & { namespace?: string }\n) => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n const instance = inject(I18nInjectionKey) as unknown as\n | Record<string, unknown>\n | undefined;\n const fallbackMessages = instance?.__optionsMessages as\n | Record<string, unknown>\n | undefined;\n\n const namespace = options?.namespace as string | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const translate = (key: string, ...args: unknown[]): string =>\n translateKey(currentLocale.value, namespace, key, args, fallbackMessages);\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: (key: string): boolean =>\n lookupRaw(currentLocale.value, namespace, key) !== undefined,\n tm: (key: string): unknown =>\n lookupRaw(currentLocale.value, namespace, key) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n}) as UseI18n;\n"],"mappings":";;;;;;;;;;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ACE,OACA,oBAEA,gBACE,OACA,iBACA,cAAc,OACd,eACF;EACF,IACE,OACA,oBAEA,kBACE,OACA,iBACA,cAAc,OACd,aACF;CACJ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"formats.mjs","names":[],"sources":["../../src/formats.ts"],"sourcesContent":["/**\n * Locale-aware `d()` / `n()` formatting backed by the native `Intl.*` APIs,\n * honoring the `datetimeFormats` / `numberFormats` maps from `createI18n`\n * options (vue-i18n named formats).\n */\n\n/** vue-i18n `datetimeFormats` option shape: locale → format name → options. */\nexport type DateTimeFormatsConfig = Record<\n string,\n Record<string, Intl.DateTimeFormatOptions>\n>;\n\n/** vue-i18n `numberFormats` option shape: locale → format name → options. */\nexport type NumberFormatsConfig = Record<\n string,\n Record<string, Intl.NumberFormatOptions>\n>;\n\nconst resolveNamedOptions = <FormatOptions>(\n formatOrOptions: string | FormatOptions | undefined,\n locale: string,\n namedFormats: Record<string, Record<string, FormatOptions>> | undefined\n): FormatOptions | undefined => {\n if (typeof formatOrOptions === 'string') {\n return (\n namedFormats?.[locale]?.[formatOrOptions] ??\n // Fall back to the base language entry (`'en'` for `'en-GB'`)\n namedFormats?.[locale.split('-')[0] ?? '']?.[formatOrOptions]\n );\n }\n return formatOrOptions;\n};\n\n/** Formats a date value like vue-i18n's `d()`. */\nexport const formatDateValue = (\n value: Date | number | string,\n formatOrOptions: string | Intl.DateTimeFormatOptions | undefined,\n locale: string,\n datetimeFormats?: DateTimeFormatsConfig\n): string => {\n const dateValue = value instanceof Date ? value : new Date(value);\n const options = resolveNamedOptions(formatOrOptions, locale, datetimeFormats);\n\n try {\n return new Intl.DateTimeFormat(locale, options).format(dateValue);\n } catch {\n return String(value);\n }\n};\n\n/** Formats a number value like vue-i18n's `n()`. */\nexport const formatNumberValue = (\n value: number,\n formatOrOptions: string | Intl.NumberFormatOptions | undefined,\n locale: string,\n numberFormats?: NumberFormatsConfig\n): string => {\n const options = resolveNamedOptions(formatOrOptions, locale, numberFormats);\n\n try {\n return new Intl.NumberFormat(locale, options).format(value);\n } catch {\n return String(value);\n }\n};\n"],"mappings":";AAkBA,MAAM,uBACJ,iBACA,QACA,iBAC8B;AAC9B,KAAI,OAAO,oBAAoB,SAC7B,QACE,eAAe,UAAU,oBAEzB,eAAe,OAAO,MAAM,IAAI,CAAC,MAAM,MAAM;AAGjD,QAAO;;;AAIT,MAAa,mBACX,OACA,iBACA,QACA,oBACW;CACX,MAAM,YAAY,iBAAiB,OAAO,QAAQ,IAAI,KAAK,MAAM;CACjE,MAAM,UAAU,oBAAoB,iBAAiB,QAAQ,gBAAgB;AAE7E,KAAI;AACF,SAAO,IAAI,KAAK,eAAe,QAAQ,QAAQ,CAAC,OAAO,UAAU;SAC3D;AACN,SAAO,OAAO,MAAM;;;;AAKxB,MAAa,qBACX,OACA,iBACA,QACA,kBACW;CACX,MAAM,UAAU,oBAAoB,iBAAiB,QAAQ,cAAc;AAE3E,KAAI;AACF,SAAO,IAAI,KAAK,aAAa,QAAQ,QAAQ,CAAC,OAAO,MAAM;SACrD;AACN,SAAO,OAAO,MAAM"}
1
+ {"version":3,"file":"formats.mjs","names":[],"sources":["../../src/formats.ts"],"sourcesContent":["/**\n * Locale-aware `d()` / `n()` formatting backed by the native `Intl.*` APIs,\n * honoring the `datetimeFormats` / `numberFormats` maps from `createI18n`\n * options (vue-i18n named formats).\n */\n\n/** vue-i18n `datetimeFormats` option shape: locale → format name → options. */\nexport type DateTimeFormatsConfig = Record<\n string,\n Record<string, Intl.DateTimeFormatOptions>\n>;\n\n/** vue-i18n `numberFormats` option shape: locale → format name → options. */\nexport type NumberFormatsConfig = Record<\n string,\n Record<string, Intl.NumberFormatOptions>\n>;\n\nconst resolveNamedOptions = <FormatOptions>(\n formatOrOptions: string | FormatOptions | undefined,\n locale: string,\n namedFormats: Record<string, Record<string, FormatOptions>> | undefined\n): FormatOptions | undefined => {\n if (typeof formatOrOptions === 'string') {\n return (\n namedFormats?.[locale]?.[formatOrOptions] ??\n // Fall back to the base language entry (`'en'` for `'en-GB'`)\n namedFormats?.[locale.split('-')[0] ?? '']?.[formatOrOptions]\n );\n }\n return formatOrOptions;\n};\n\n/** Formats a date value like vue-i18n's `d()`. */\nexport const formatDateValue = (\n value: Date | number | string,\n formatOrOptions: string | Intl.DateTimeFormatOptions | undefined,\n locale: string,\n datetimeFormats?: DateTimeFormatsConfig\n): string => {\n const dateValue = value instanceof Date ? value : new Date(value);\n const options = resolveNamedOptions(formatOrOptions, locale, datetimeFormats);\n\n try {\n return new Intl.DateTimeFormat(locale, options).format(dateValue);\n } catch {\n return String(value);\n }\n};\n\n/** Formats a number value like vue-i18n's `n()`. */\nexport const formatNumberValue = (\n value: number,\n formatOrOptions: string | Intl.NumberFormatOptions | undefined,\n locale: string,\n numberFormats?: NumberFormatsConfig\n): string => {\n const options = resolveNamedOptions(formatOrOptions, locale, numberFormats);\n\n try {\n return new Intl.NumberFormat(locale, options).format(value);\n } catch {\n return String(value);\n }\n};\n"],"mappings":";AAkBA,MAAM,uBACJ,iBACA,QACA,iBAC8B;CAC9B,IAAI,OAAO,oBAAoB,UAC7B,OACE,eAAe,OAAO,GAAG,oBAEzB,eAAe,OAAO,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,GAAG;CAGjD,OAAO;AACT;;AAGA,MAAa,mBACX,OACA,iBACA,QACA,oBACW;CACX,MAAM,YAAY,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;CAChE,MAAM,UAAU,oBAAoB,iBAAiB,QAAQ,eAAe;CAE5E,IAAI;EACF,OAAO,IAAI,KAAK,eAAe,QAAQ,OAAO,CAAC,CAAC,OAAO,SAAS;CAClE,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;;AAGA,MAAa,qBACX,OACA,iBACA,QACA,kBACW;CACX,MAAM,UAAU,oBAAoB,iBAAiB,QAAQ,aAAa;CAE1E,IAAI;EACF,OAAO,IAAI,KAAK,aAAa,QAAQ,OAAO,CAAC,CAAC,OAAO,KAAK;CAC5D,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF"}
@@ -1,29 +1,13 @@
1
1
  import * as ANSIColors from "@intlayer/config/colors";
2
2
  import { colorize, getAppLogger } from "@intlayer/config/logger";
3
3
  import { join } from "node:path";
4
- import { runOnce } from "@intlayer/chokidar/utils";
4
+ import { VUE_I18N_CALLERS } from "@intlayer/config/callers";
5
5
  import { getConfiguration } from "@intlayer/config/node";
6
+ import { runOnce } from "@intlayer/engine/utils";
6
7
  import { intlayer } from "vite-intlayer";
7
8
 
8
9
  //#region src/plugin/index.ts
9
10
  /**
10
- * Caller configurations for vue-i18n's `useI18n` composable.
11
- *
12
- * Tells the intlayer field-usage analyser how to extract the dictionary key
13
- * (namespace) from `useI18n({ namespace: 'ns' })` call sites, enabling
14
- * accurate dictionary pruning for projects using `@intlayer/vue-i18n`.
15
- */
16
- const VUE_I18N_COMPAT_CALLERS = [{
17
- callerName: "useI18n",
18
- importSources: ["vue-i18n", "@intlayer/vue-i18n"],
19
- namespace: {
20
- from: "option",
21
- argumentIndex: 0,
22
- property: "namespace"
23
- },
24
- translationFunction: "destructured-t"
25
- }];
26
- /**
27
11
  * A Vite plugin for vue-i18n compat that wraps vite-intlayer
28
12
  * and configures resolve aliases for vue-i18n.
29
13
  */
@@ -35,7 +19,7 @@ const vueI18nVitePlugin = (options) => {
35
19
  }, { cacheTimeoutMs: 1e3 * 60 * 60 });
36
20
  const basePlugins = intlayer({
37
21
  ...options,
38
- compatCallers: [...options?.compatCallers ?? [], ...VUE_I18N_COMPAT_CALLERS]
22
+ compatCallers: [...options?.compatCallers ?? [], ...VUE_I18N_CALLERS]
39
23
  });
40
24
  const compatPlugin = {
41
25
  name: "vite-vue-i18n-compat-plugin",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for vue-i18n's `useI18n` composable.\n *\n * Tells the intlayer field-usage analyser how to extract the dictionary key\n * (namespace) from `useI18n({ namespace: 'ns' })` call sites, enabling\n * accurate dictionary pruning for projects using `@intlayer/vue-i18n`.\n */\nconst VUE_I18N_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: 'useI18n',\n importSources: ['vue-i18n', '@intlayer/vue-i18n'],\n namespace: { from: 'option', argumentIndex: 0, property: 'namespace' },\n translationFunction: 'destructured-t',\n },\n];\n\n/**\n * A Vite plugin for vue-i18n compat that wraps vite-intlayer\n * and configures resolve aliases for vue-i18n.\n */\nexport const vueI18nVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...VUE_I18N_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-vue-i18n-compat-plugin',\n config: () => {\n return {\n resolve: {\n alias: {\n 'vue-i18n': '@intlayer/vue-i18n',\n },\n },\n };\n },\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default vueI18nVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,0BAAgD,CACpD;CACE,YAAY;CACZ,eAAe,CAAC,YAAY,qBAAqB;CACjD,WAAW;EAAE,MAAM;EAAU,eAAe;EAAG,UAAU;EAAa;CACtE,qBAAqB;CACtB,CACF;;;;;AAMD,MAAa,qBACX,YACmB;CACnB,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,YAAY,aAAa,eAAe;AAE9C,SACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,kCACD,QACK;AACJ,YAAU,CACR,SACE,+CACA,WAAW,KACZ,EACD,SACE,iDACA,WAAW,WACZ,CACF,CAAC;IAEJ,EACE,gBAAgB,MAAO,KAAK,IAC7B,CACF;CAED,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,EAAE,EAChC,GAAG,wBACJ;EACF,CAAC;CAEF,MAAM,eAA6B;EACjC,MAAM;EACN,cAAc;AACZ,UAAO,EACL,SAAS,EACP,OAAO,EACL,YAAY,sBACb,EACF,EACF;;EAEJ;AAED,QAAO,CACL,GAAI,MAAM,QAAQ,YAAY,GAAG,cAAc,CAAC,YAAY,EAC5D,aACD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { VUE_I18N_CALLERS } from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { runOnce } from '@intlayer/engine/utils';\nimport type { PluginOption } from 'vite';\nimport { intlayer } from 'vite-intlayer';\n\n/**\n * A Vite plugin for vue-i18n compat that wraps vite-intlayer\n * and configures resolve aliases for vue-i18n.\n */\nexport const vueI18nVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [...(options?.compatCallers ?? []), ...VUE_I18N_CALLERS],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-vue-i18n-compat-plugin',\n config: () => {\n return {\n resolve: {\n alias: {\n 'vue-i18n': '@intlayer/vue-i18n',\n },\n },\n };\n },\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default vueI18nVitePlugin;\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,qBACX,YACmB;CACnB,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,YAAY,aAAa,cAAc;CAE7C,QACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,CACR,SACE,+CACA,WAAW,IACb,GACA,SACE,iDACA,WAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CAAC,GAAI,SAAS,iBAAiB,CAAC,GAAI,GAAG,gBAAgB;CACxE,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,cAAc;GACZ,OAAO,EACL,SAAS,EACP,OAAO,EACL,YAAY,qBACd,EACF,EACF;EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveVueMessage.mjs","names":[],"sources":["../../src/resolveVueMessage.ts"],"sourcesContent":["import {\n interpolateMessage,\n type MessageValues,\n resolveMessageNode,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Splits a vue-i18n choice message (`'no car | one car | {count} cars'`)\n * into its parts, honoring escaped pipes (`\\|`).\n */\nexport const splitChoices = (message: string): string[] =>\n message.split(/(?<!\\\\)\\|/).map((part) => part.replace(/\\\\\\|/g, '|').trim());\n\n/**\n * vue-i18n's default choice rule:\n * - 2 choices: `1 | other` — 0 picks `other`, 1 picks the first part\n * - 3+ choices: `0 | 1 | other`\n */\nexport const getChoiceIndex = (\n choice: number,\n choicesLength: number\n): number => {\n const absoluteChoice = Math.abs(choice);\n\n if (choicesLength === 2) {\n return absoluteChoice ? (absoluteChoice > 1 ? 1 : 0) : 1;\n }\n\n return absoluteChoice ? Math.min(absoluteChoice, 2) : 0;\n};\n\n/** Arguments parsed from vue-i18n's polymorphic `t()` signatures. */\nexport type ParsedTranslateArguments = {\n /** Named (`{name}`) or list (`{0}`) interpolation values. */\n values: MessageValues;\n /** Plural choice count, when a number argument was provided. */\n count?: number;\n /** Default message, when a string argument was provided. */\n defaultMessage?: string;\n};\n\n/**\n * Parses vue-i18n's polymorphic `t()` arguments:\n * `t(key)`, `t(key, count)`, `t(key, defaultMsg)`, `t(key, list)`,\n * `t(key, named)`, `t(key, named, count)`, `t(key, list, count)`, …\n */\nexport const parseTranslateArguments = (\n args: unknown[]\n): ParsedTranslateArguments => {\n const parsed: ParsedTranslateArguments = { values: {} };\n\n for (const arg of args) {\n if (typeof arg === 'number') {\n parsed.count = arg;\n } else if (typeof arg === 'string') {\n parsed.defaultMessage = arg;\n } else if (Array.isArray(arg)) {\n // List interpolation: ['a', 'b'] → { 0: 'a', 1: 'b' }\n parsed.values = { ...arg.map(String) } as unknown as MessageValues;\n } else if (typeof arg === 'object' && arg !== null) {\n const objectArg = arg as MessageValues & { plural?: number };\n parsed.values = objectArg;\n if (typeof objectArg.plural === 'number') {\n parsed.count = objectArg.plural;\n }\n }\n }\n\n return parsed;\n};\n\n/**\n * Resolves a raw dictionary value the vue-i18n way: pipe-separated choice\n * messages (positional rule, not CLDR), named `{name}` and list `{0}`\n * interpolation, and intlayer nodes (`insert`, `plural`, `enu`) produced by\n * dictionaries built with `format: 'vue-i18n'`.\n */\nexport const resolveVueMessage = (\n value: unknown,\n values: MessageValues,\n count: number | undefined,\n locale: LocalesValues\n): string => {\n const interpolationValues: MessageValues = { ...values };\n if (count !== undefined) {\n interpolationValues.count ??= count;\n interpolationValues.n ??= count;\n }\n\n if (typeof value === 'string') {\n let message = value;\n\n if (/(?<!\\\\)\\|/.test(message)) {\n const parts = splitChoices(message);\n message = parts[getChoiceIndex(count ?? 1, parts.length)] ?? message;\n }\n\n return interpolateMessage(message, interpolationValues, locale);\n }\n\n const resolved = resolveMessageNode(value, interpolationValues, locale);\n\n return typeof resolved === 'string' ? resolved : String(resolved ?? '');\n};\n"],"mappings":";;;;;;;AAWA,MAAa,gBAAgB,YAC3B,QAAQ,MAAM,YAAY,CAAC,KAAK,SAAS,KAAK,QAAQ,SAAS,IAAI,CAAC,MAAM,CAAC;;;;;;AAO7E,MAAa,kBACX,QACA,kBACW;CACX,MAAM,iBAAiB,KAAK,IAAI,OAAO;AAEvC,KAAI,kBAAkB,EACpB,QAAO,iBAAkB,iBAAiB,IAAI,IAAI,IAAK;AAGzD,QAAO,iBAAiB,KAAK,IAAI,gBAAgB,EAAE,GAAG;;;;;;;AAkBxD,MAAa,2BACX,SAC6B;CAC7B,MAAM,SAAmC,EAAE,QAAQ,EAAE,EAAE;AAEvD,MAAK,MAAM,OAAO,KAChB,KAAI,OAAO,QAAQ,SACjB,QAAO,QAAQ;UACN,OAAO,QAAQ,SACxB,QAAO,iBAAiB;UACf,MAAM,QAAQ,IAAI,CAE3B,QAAO,SAAS,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;UAC7B,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAClD,MAAM,YAAY;AAClB,SAAO,SAAS;AAChB,MAAI,OAAO,UAAU,WAAW,SAC9B,QAAO,QAAQ,UAAU;;AAK/B,QAAO;;;;;;;;AAST,MAAa,qBACX,OACA,QACA,OACA,WACW;CACX,MAAM,sBAAqC,EAAE,GAAG,QAAQ;AACxD,KAAI,UAAU,QAAW;AACvB,sBAAoB,UAAU;AAC9B,sBAAoB,MAAM;;AAG5B,KAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,UAAU;AAEd,MAAI,YAAY,KAAK,QAAQ,EAAE;GAC7B,MAAM,QAAQ,aAAa,QAAQ;AACnC,aAAU,MAAM,eAAe,SAAS,GAAG,MAAM,OAAO,KAAK;;AAG/D,SAAO,mBAAmB,SAAS,qBAAqB,OAAO;;CAGjE,MAAM,WAAW,mBAAmB,OAAO,qBAAqB,OAAO;AAEvE,QAAO,OAAO,aAAa,WAAW,WAAW,OAAO,YAAY,GAAG"}
1
+ {"version":3,"file":"resolveVueMessage.mjs","names":[],"sources":["../../src/resolveVueMessage.ts"],"sourcesContent":["import {\n interpolateMessage,\n type MessageValues,\n resolveMessageNode,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Splits a vue-i18n choice message (`'no car | one car | {count} cars'`)\n * into its parts, honoring escaped pipes (`\\|`).\n */\nexport const splitChoices = (message: string): string[] =>\n message.split(/(?<!\\\\)\\|/).map((part) => part.replace(/\\\\\\|/g, '|').trim());\n\n/**\n * vue-i18n's default choice rule:\n * - 2 choices: `1 | other` — 0 picks `other`, 1 picks the first part\n * - 3+ choices: `0 | 1 | other`\n */\nexport const getChoiceIndex = (\n choice: number,\n choicesLength: number\n): number => {\n const absoluteChoice = Math.abs(choice);\n\n if (choicesLength === 2) {\n return absoluteChoice ? (absoluteChoice > 1 ? 1 : 0) : 1;\n }\n\n return absoluteChoice ? Math.min(absoluteChoice, 2) : 0;\n};\n\n/** Arguments parsed from vue-i18n's polymorphic `t()` signatures. */\nexport type ParsedTranslateArguments = {\n /** Named (`{name}`) or list (`{0}`) interpolation values. */\n values: MessageValues;\n /** Plural choice count, when a number argument was provided. */\n count?: number;\n /** Default message, when a string argument was provided. */\n defaultMessage?: string;\n};\n\n/**\n * Parses vue-i18n's polymorphic `t()` arguments:\n * `t(key)`, `t(key, count)`, `t(key, defaultMsg)`, `t(key, list)`,\n * `t(key, named)`, `t(key, named, count)`, `t(key, list, count)`, …\n */\nexport const parseTranslateArguments = (\n args: unknown[]\n): ParsedTranslateArguments => {\n const parsed: ParsedTranslateArguments = { values: {} };\n\n for (const arg of args) {\n if (typeof arg === 'number') {\n parsed.count = arg;\n } else if (typeof arg === 'string') {\n parsed.defaultMessage = arg;\n } else if (Array.isArray(arg)) {\n // List interpolation: ['a', 'b'] → { 0: 'a', 1: 'b' }\n parsed.values = { ...arg.map(String) } as unknown as MessageValues;\n } else if (typeof arg === 'object' && arg !== null) {\n const objectArg = arg as MessageValues & { plural?: number };\n parsed.values = objectArg;\n if (typeof objectArg.plural === 'number') {\n parsed.count = objectArg.plural;\n }\n }\n }\n\n return parsed;\n};\n\n/**\n * Resolves a raw dictionary value the vue-i18n way: pipe-separated choice\n * messages (positional rule, not CLDR), named `{name}` and list `{0}`\n * interpolation, and intlayer nodes (`insert`, `plural`, `enu`) produced by\n * dictionaries built with `format: 'vue-i18n'`.\n */\nexport const resolveVueMessage = (\n value: unknown,\n values: MessageValues,\n count: number | undefined,\n locale: LocalesValues\n): string => {\n const interpolationValues: MessageValues = { ...values };\n if (count !== undefined) {\n interpolationValues.count ??= count;\n interpolationValues.n ??= count;\n }\n\n if (typeof value === 'string') {\n let message = value;\n\n if (/(?<!\\\\)\\|/.test(message)) {\n const parts = splitChoices(message);\n message = parts[getChoiceIndex(count ?? 1, parts.length)] ?? message;\n }\n\n return interpolateMessage(message, interpolationValues, locale);\n }\n\n const resolved = resolveMessageNode(value, interpolationValues, locale);\n\n return typeof resolved === 'string' ? resolved : String(resolved ?? '');\n};\n"],"mappings":";;;;;;;AAWA,MAAa,gBAAgB,YAC3B,QAAQ,MAAM,WAAW,CAAC,C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import { formatDateValue, formatNumberValue } from "./formats.mjs";
2
2
  import { parseTranslateArguments, resolveVueMessage } from "./resolveVueMessage.mjs";
3
+ import { navigatePath } from "@intlayer/core/messageFormat";
3
4
  import { computed } from "vue";
4
5
  import { useDictionary as useDictionary$1, useLocale } from "vue-intlayer";
5
6
 
6
7
  //#region src/useDictionary.ts
7
- const navigatePath = (objectValue, path) => {
8
- if (!path) return objectValue;
9
- const parts = path.split(".");
10
- let current = objectValue;
11
- for (const part of parts) {
12
- if (current === null || current === void 0 || typeof current !== "object") return;
13
- current = current[part];
14
- }
15
- return current;
16
- };
17
8
  /**
18
9
  * Dictionary-accepting variant of `useI18n`.
19
10
  *
@@ -21,7 +12,7 @@ const navigatePath = (objectValue, path) => {
21
12
  * at runtime by key, the Babel plugin pre-imports the dictionary JSON at build time
22
13
  * and passes it directly here. This enables tree-shaking of unused locale content.
23
14
  */
24
- const useDictionary = (dictionary, options) => {
15
+ const useDictionary = ((dictionary, options) => {
25
16
  const { locale: currentLocale, setLocale, availableLocales } = useLocale();
26
17
  const namespacePrefix = options?.namespace;
27
18
  const datetimeFormats = options?.datetimeFormats;
@@ -47,14 +38,14 @@ const useDictionary = (dictionary, options) => {
47
38
  }
48
39
  return resolveVueMessage(rawValue, values, count, currentLocale.value);
49
40
  };
50
- const translate = (key, ...args) => translateKey(String(key), args);
41
+ const translate = (key, ...args) => translateKey(key, args);
51
42
  return {
52
43
  locale: localeRef,
53
44
  availableLocales,
54
45
  t: translate,
55
46
  tc: translate,
56
- te: (key) => lookupRaw(String(key)) !== void 0,
57
- tm: (key) => lookupRaw(String(key)) ?? {},
47
+ te: (key) => lookupRaw(key) !== void 0,
48
+ tm: (key) => lookupRaw(key) ?? {},
58
49
  rt: (message, ...args) => {
59
50
  const { values, count } = parseTranslateArguments(args);
60
51
  return resolveVueMessage(message, values, count, currentLocale.value);
@@ -62,7 +53,7 @@ const useDictionary = (dictionary, options) => {
62
53
  d: (value, formatOrOptions) => formatDateValue(value, formatOrOptions, currentLocale.value, datetimeFormats),
63
54
  n: (value, formatOrOptions) => formatNumberValue(value, formatOrOptions, currentLocale.value, numberFormats)
64
55
  };
65
- };
56
+ });
66
57
 
67
58
  //#endregion
68
59
  export { useDictionary };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":["useDictionaryBase"],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { computed, type WritableComputedRef } from 'vue';\nimport { useDictionary as useDictionaryBase, useLocale } from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\n\nconst navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n const parts = path.split('.');\n let current: unknown = objectValue;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Dictionary-accepting variant of `useI18n`.\n *\n * Used internally by the Babel optimization: instead of looking up the dictionary\n * at runtime by key, the Babel plugin pre-imports the dictionary JSON at build time\n * and passes it directly here. This enables tree-shaking of unused locale content.\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const N extends DictionaryKeys = DictionaryKeys,\n>(\n dictionary: T,\n options?: Record<string, unknown> & { namespace?: N }\n): {\n locale: WritableComputedRef<string>;\n availableLocales: string[];\n t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;\n tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;\n rt: (message: unknown, ...args: unknown[]) => string;\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ) => string;\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ) => string;\n} => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n\n const namespacePrefix = options?.namespace as string | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const content = useDictionaryBase(dictionary);\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n const lookupRaw = (key: string): unknown => {\n // navigatePath on the returned proxy will correctly resolve nested properties\n const result = navigatePath(content, resolveKey(key));\n // For leaf nodes, we can access .value to get the real underlying primitive/node\n return (result as any)?.$raw?.value ?? (result as any)?.value ?? result;\n };\n\n const translateKey = (key: string, args: unknown[]): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n const rawValue = lookupRaw(key);\n\n if (rawValue === undefined) {\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n }\n return key;\n }\n\n return resolveVueMessage(\n rawValue,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n };\n\n const translate = <P extends ValidDotPathsFor<N>>(\n key: P,\n ...args: unknown[]\n ): string => translateKey(String(key), args);\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: <P extends ValidDotPathsFor<N>>(key: P): boolean =>\n lookupRaw(String(key)) !== undefined,\n tm: <P extends ValidDotPathsFor<N>>(key: P): unknown =>\n lookupRaw(String(key)) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n};\n"],"mappings":";;;;;;AAmBA,MAAM,gBAAgB,aAAsB,SAA0B;AACpE,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,OAAO;AACxB,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;;;;;;;AAUT,MAAa,iBAIX,YACA,YAiBG;CACH,MAAM,EAAE,QAAQ,eAAe,WAAW,qBAAqB,WAAW;CAE1E,MAAM,kBAAkB,SAAS;CAEjC,MAAM,kBAAkB,SAAS;CAGjC,MAAM,gBAAgB,SAAS;CAI/B,MAAM,UAAUA,gBAAkB,WAAW;CAE7C,MAAM,YAAY,SAAS;EACzB,WAAW,cAAc;EACzB,MAAM,cAAsB;AAC1B,aAAU,UAA2B;;EAExC,CAAC;CAEF,MAAM,cAAc,cAClB,kBAAkB,GAAG,gBAAgB,GAAG,cAAc;CAExD,MAAM,aAAa,QAAyB;EAE1C,MAAM,SAAS,aAAa,SAAS,WAAW,IAAI,CAAC;AAErD,SAAQ,QAAgB,MAAM,SAAU,QAAgB,SAAS;;CAGnE,MAAM,gBAAgB,KAAa,SAA4B;EAC7D,MAAM,EAAE,QAAQ,OAAO,mBAAmB,wBAAwB,KAAK;EACvE,MAAM,WAAW,UAAU,IAAI;AAE/B,MAAI,aAAa,QAAW;AAC1B,OAAI,mBAAmB,OACrB,QAAO,kBACL,gBACA,QACA,OACA,cAAc,MACf;AAEH,UAAO;;AAGT,SAAO,kBACL,UACA,QACA,OACA,cAAc,MACf;;CAGH,MAAM,aACJ,KACA,GAAG,SACQ,aAAa,OAAO,IAAI,EAAE,KAAK;AAE5C,QAAO;EACL,QAAQ;EACU;EAClB,GAAG;EACH,IAAI;EACJ,KAAoC,QAClC,UAAU,OAAO,IAAI,CAAC,KAAK;EAC7B,KAAoC,QAClC,UAAU,OAAO,IAAI,CAAC,IAAI,EAAE;EAC9B,KAAK,SAAkB,GAAG,SAA4B;GACpD,MAAM,EAAE,QAAQ,UAAU,wBAAwB,KAAK;AACvD,UAAO,kBACL,SACA,QACA,OACA,cAAc,MACf;;EAEH,IACE,OACA,oBAEA,gBACE,OACA,iBACA,cAAc,OACd,gBACD;EACH,IACE,OACA,oBAEA,kBACE,OACA,iBACA,cAAc,OACd,cACD;EACJ"}
1
+ {"version":3,"file":"useDictionary.mjs","names":["useDictionaryBase"],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import { navigatePath } from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { computed } from 'vue';\nimport { useDictionary as useDictionaryBase, useLocale } from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\nimport type { ScopedComposer, TypedComposer } from './typedComposer';\n\n/**\n * Overload set for {@link useDictionary}: without a `namespace` option the\n * composer is typed against the dictionary's dot-paths; with one (the\n * key-prefix remainder left by the build rewrite) the keys are relative\n * dot-paths under that scope.\n */\ntype UseDictionary = {\n <T extends Dictionary>(\n dictionary: T,\n options?: Record<string, unknown> & { namespace?: undefined }\n ): TypedComposer<T['key'] & DictionaryKeys>;\n <T extends Dictionary, Prefix extends string>(\n dictionary: T,\n options: Record<string, unknown> & { namespace: Prefix }\n ): ScopedComposer<T['key'] & DictionaryKeys, Prefix>;\n};\n\n/**\n * Dictionary-accepting variant of `useI18n`.\n *\n * Used internally by the Babel optimization: instead of looking up the dictionary\n * at runtime by key, the Babel plugin pre-imports the dictionary JSON at build time\n * and passes it directly here. This enables tree-shaking of unused locale content.\n */\nexport const useDictionary = (<const T extends Dictionary>(\n dictionary: T,\n options?: Record<string, unknown> & { namespace?: string }\n) => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n\n const namespacePrefix = options?.namespace as string | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const content = useDictionaryBase(dictionary);\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n const lookupRaw = (key: string): unknown => {\n // navigatePath on the returned proxy will correctly resolve nested properties\n const result = navigatePath(content, resolveKey(key));\n // For leaf nodes, we can access .value to get the real underlying primitive/node\n return (result as any)?.$raw?.value ?? (result as any)?.value ?? result;\n };\n\n const translateKey = (key: string, args: unknown[]): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n const rawValue = lookupRaw(key);\n\n if (rawValue === undefined) {\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n }\n return key;\n }\n\n return resolveVueMessage(\n rawValue,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n };\n\n const translate = (key: string, ...args: unknown[]): string =>\n translateKey(key, args);\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: (key: string): boolean => lookupRaw(key) !== undefined,\n tm: (key: string): unknown => lookupRaw(key) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n}) as UseDictionary;\n"],"mappings":";;;;;;;;;;;;;;AA4CA,MAAa,kBACX,YACA,YACG;CACH,MAAM,EAAE,QAAQ,eAAe,WAAW,qBAAqB,UAAU;CAEzE,MAAM,kBAAkB,SAAS;CAEjC,MAAM,kBAAkB,SAAS;CAGjC,MAAM,gBAAgB,SAAS;CAI/B,MAAM,UAAUA,gBAAkB,UAAU;CAE5C,MAAM,YAAY,SAAS;EACzB,WAAW,cAAc;EACzB,MAAM,cAAsB;GAC1B,UAAU,SAA0B;EACtC;CACF,CAAC;CAED,MAAM,cAAc,cAClB,kBAAkB,GAAG,gBAAgB,GAAG,cAAc;CAExD,MAAM,aAAa,QAAyB;EAE1C,MAAM,SAAS,aAAa,SAAS,WAAW,GAAG,CAAC;EAEpD,OAAQ,QAAgB,MAAM,SAAU,QAAgB,SAAS;CACnE;CAEA,MAAM,gBAAgB,KAAa,SAA4B;EAC7D,MAAM,EAAE,QAAQ,OAAO,mBAAmB,wBAAwB,IAAI;EACtE,MAAM,WAAW,UAAU,GAAG;EAE9B,IAAI,aAAa,QAAW;GAC1B,IAAI,mBAAmB,QACrB,OAAO,kBACL,gBACA,QACA,OACA,cAAc,KAChB;GAEF,OAAO;EACT;EAEA,OAAO,kBACL,UACA,QACA,OACA,cAAc,KAChB;CACF;CAEA,MAAM,aAAa,KAAa,GAAG,SACjC,aAAa,KAAK,IAAI;CAExB,OAAO;EACL,QAAQ;EACU;EAClB,GAAG;EACH,IAAI;EACJ,KAAK,QAAyB,UAAU,GAAG,MAAM;EACjD,KAAK,QAAyB,UAAU,GAAG,KAAK,CAAC;EACjD,KAAK,SAAkB,GAAG,SAA4B;GACpD,MAAM,EAAE,QAAQ,UAAU,wBAAwB,IAAI;GACtD,OAAO,kBACL,SACA,QACA,OACA,cAAc,KAChB;EACF;EACA,IACE,OACA,oBAEA,gBACE,OACA,iBACA,cAAc,OACd,eACF;EACF,IACE,OACA,oBAEA,kBACE,OACA,iBACA,cAAc,OACd,aACF;CACJ;AACF"}
@@ -1,19 +1,10 @@
1
1
  import { formatDateValue, formatNumberValue } from "./formats.mjs";
2
2
  import { parseTranslateArguments, resolveVueMessage } from "./resolveVueMessage.mjs";
3
+ import { navigatePath } from "@intlayer/core/messageFormat";
3
4
  import { computed } from "vue";
4
5
  import { useDictionaryDynamic as useDictionaryDynamic$1, useLocale } from "vue-intlayer";
5
6
 
6
7
  //#region src/useDictionaryDynamic.ts
7
- const navigatePath = (objectValue, path) => {
8
- if (!path) return objectValue;
9
- const parts = path.split(".");
10
- let current = objectValue;
11
- for (const part of parts) {
12
- if (current === null || current === void 0 || typeof current !== "object") return;
13
- current = current[part];
14
- }
15
- return current;
16
- };
17
8
  /**
18
9
  * Dynamic dictionary-accepting variant of `useI18n`.
19
10
  *
@@ -21,7 +12,7 @@ const navigatePath = (objectValue, path) => {
21
12
  * at runtime by key, the Babel plugin dynamically imports the dictionary JSON
22
13
  * (or .mjs module) based on the locale.
23
14
  */
24
- const useDictionaryDynamic = (dictionaryPromise, key, options) => {
15
+ const useDictionaryDynamic = ((dictionaryPromise, key, options) => {
25
16
  const { locale: currentLocale, setLocale, availableLocales } = useLocale();
26
17
  const namespacePrefix = options?.namespace;
27
18
  const datetimeFormats = options?.datetimeFormats;
@@ -47,14 +38,14 @@ const useDictionaryDynamic = (dictionaryPromise, key, options) => {
47
38
  }
48
39
  return resolveVueMessage(rawValue, values, count, currentLocale.value);
49
40
  };
50
- const translate = (lookupKey, ...args) => translateKey(String(lookupKey), args);
41
+ const translate = (lookupKey, ...args) => translateKey(lookupKey, args);
51
42
  return {
52
43
  locale: localeRef,
53
44
  availableLocales,
54
45
  t: translate,
55
46
  tc: translate,
56
- te: (lookupKey) => lookupRaw(String(lookupKey)) !== void 0,
57
- tm: (lookupKey) => lookupRaw(String(lookupKey)) ?? {},
47
+ te: (lookupKey) => lookupRaw(lookupKey) !== void 0,
48
+ tm: (lookupKey) => lookupRaw(lookupKey) ?? {},
58
49
  rt: (message, ...args) => {
59
50
  const { values, count } = parseTranslateArguments(args);
60
51
  return resolveVueMessage(message, values, count, currentLocale.value);
@@ -62,7 +53,7 @@ const useDictionaryDynamic = (dictionaryPromise, key, options) => {
62
53
  d: (value, formatOrOptions) => formatDateValue(value, formatOrOptions, currentLocale.value, datetimeFormats),
63
54
  n: (value, formatOrOptions) => formatNumberValue(value, formatOrOptions, currentLocale.value, numberFormats)
64
55
  };
65
- };
56
+ });
66
57
 
67
58
  //#endregion
68
59
  export { useDictionaryDynamic };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":["useDictionaryDynamicBase"],"sources":["../../src/useDictionaryDynamic.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { computed, type WritableComputedRef } from 'vue';\nimport {\n useDictionaryDynamic as useDictionaryDynamicBase,\n useLocale,\n} from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\n\nconst navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n const parts = path.split('.');\n let current: unknown = objectValue;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Dynamic dictionary-accepting variant of `useI18n`.\n *\n * Used internally by the Babel optimization: instead of looking up the dictionary\n * at runtime by key, the Babel plugin dynamically imports the dictionary JSON\n * (or .mjs module) based on the locale.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends string,\n const N extends DictionaryKeys = DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options?: Record<string, unknown> & { namespace?: N }\n): {\n locale: WritableComputedRef<string>;\n availableLocales: string[];\n t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;\n te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;\n tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;\n rt: (message: unknown, ...args: unknown[]) => string;\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ) => string;\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ) => string;\n} => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n\n const namespacePrefix = options?.namespace as string | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const content = useDictionaryDynamicBase<T, any>(\n dictionaryPromise,\n key as any\n );\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n const lookupRaw = (lookupKey: string): unknown => {\n // navigatePath on the returned proxy will correctly resolve nested properties\n const result = navigatePath(content, resolveKey(lookupKey));\n // For leaf nodes, we can access .value to get the real underlying primitive/node\n return (result as any)?.$raw?.value ?? (result as any)?.value ?? result;\n };\n\n const translateKey = (lookupKey: string, args: unknown[]): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n const rawValue = lookupRaw(lookupKey);\n\n if (rawValue === undefined) {\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n }\n return lookupKey;\n }\n\n return resolveVueMessage(\n rawValue,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n };\n\n const translate = <P extends ValidDotPathsFor<N>>(\n lookupKey: P,\n ...args: unknown[]\n ): string => translateKey(String(lookupKey), args);\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: <P extends ValidDotPathsFor<N>>(lookupKey: P): boolean =>\n lookupRaw(String(lookupKey)) !== undefined,\n tm: <P extends ValidDotPathsFor<N>>(lookupKey: P): unknown =>\n lookupRaw(String(lookupKey)) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n};\n"],"mappings":";;;;;;AAuBA,MAAM,gBAAgB,aAAsB,SAA0B;AACpE,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,OAAO;AACxB,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;;;;;;;AAUT,MAAa,wBAKX,mBACA,KACA,YAiBG;CACH,MAAM,EAAE,QAAQ,eAAe,WAAW,qBAAqB,WAAW;CAE1E,MAAM,kBAAkB,SAAS;CAEjC,MAAM,kBAAkB,SAAS;CAGjC,MAAM,gBAAgB,SAAS;CAI/B,MAAM,UAAUA,uBACd,mBACA,IACD;CAED,MAAM,YAAY,SAAS;EACzB,WAAW,cAAc;EACzB,MAAM,cAAsB;AAC1B,aAAU,UAA2B;;EAExC,CAAC;CAEF,MAAM,cAAc,cAClB,kBAAkB,GAAG,gBAAgB,GAAG,cAAc;CAExD,MAAM,aAAa,cAA+B;EAEhD,MAAM,SAAS,aAAa,SAAS,WAAW,UAAU,CAAC;AAE3D,SAAQ,QAAgB,MAAM,SAAU,QAAgB,SAAS;;CAGnE,MAAM,gBAAgB,WAAmB,SAA4B;EACnE,MAAM,EAAE,QAAQ,OAAO,mBAAmB,wBAAwB,KAAK;EACvE,MAAM,WAAW,UAAU,UAAU;AAErC,MAAI,aAAa,QAAW;AAC1B,OAAI,mBAAmB,OACrB,QAAO,kBACL,gBACA,QACA,OACA,cAAc,MACf;AAEH,UAAO;;AAGT,SAAO,kBACL,UACA,QACA,OACA,cAAc,MACf;;CAGH,MAAM,aACJ,WACA,GAAG,SACQ,aAAa,OAAO,UAAU,EAAE,KAAK;AAElD,QAAO;EACL,QAAQ;EACU;EAClB,GAAG;EACH,IAAI;EACJ,KAAoC,cAClC,UAAU,OAAO,UAAU,CAAC,KAAK;EACnC,KAAoC,cAClC,UAAU,OAAO,UAAU,CAAC,IAAI,EAAE;EACpC,KAAK,SAAkB,GAAG,SAA4B;GACpD,MAAM,EAAE,QAAQ,UAAU,wBAAwB,KAAK;AACvD,UAAO,kBACL,SACA,QACA,OACA,cAAc,MACf;;EAEH,IACE,OACA,oBAEA,gBACE,OACA,iBACA,cAAc,OACd,gBACD;EACH,IACE,OACA,oBAEA,kBACE,OACA,iBACA,cAAc,OACd,cACD;EACJ"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":["useDictionaryDynamicBase"],"sources":["../../src/useDictionaryDynamic.ts"],"sourcesContent":["import { navigatePath } from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { computed } from 'vue';\nimport {\n useDictionaryDynamic as useDictionaryDynamicBase,\n useLocale,\n} from 'vue-intlayer';\nimport {\n type DateTimeFormatsConfig,\n formatDateValue,\n formatNumberValue,\n type NumberFormatsConfig,\n} from './formats';\nimport {\n parseTranslateArguments,\n resolveVueMessage,\n} from './resolveVueMessage';\nimport type { ScopedComposer, TypedComposer } from './typedComposer';\n\n/**\n * Overload set for {@link useDictionaryDynamic}: without a `namespace` option\n * the composer is typed against the dictionary's dot-paths; with one (the\n * key-prefix remainder left by the build rewrite) the keys are relative\n * dot-paths under that scope.\n */\ntype UseDictionaryDynamic = {\n <T extends Dictionary, K extends DictionaryKeys>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options?: Record<string, unknown> & { namespace?: undefined }\n ): TypedComposer<K>;\n <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options: Record<string, unknown> & { namespace: Prefix }\n ): ScopedComposer<K, Prefix>;\n};\n\n/**\n * Dynamic dictionary-accepting variant of `useI18n`.\n *\n * Used internally by the Babel optimization: instead of looking up the dictionary\n * at runtime by key, the Babel plugin dynamically imports the dictionary JSON\n * (or .mjs module) based on the locale.\n */\nexport const useDictionaryDynamic = (<\n const T extends Dictionary,\n const K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n options?: Record<string, unknown> & { namespace?: string }\n) => {\n const { locale: currentLocale, setLocale, availableLocales } = useLocale();\n\n const namespacePrefix = options?.namespace as string | undefined;\n\n const datetimeFormats = options?.datetimeFormats as\n | DateTimeFormatsConfig\n | undefined;\n const numberFormats = options?.numberFormats as\n | NumberFormatsConfig\n | undefined;\n\n const content = useDictionaryDynamicBase<T, any>(\n dictionaryPromise,\n key as any\n );\n\n const localeRef = computed({\n get: () => currentLocale.value as string,\n set: (newLocale: string) => {\n setLocale(newLocale as LocalesValues);\n },\n });\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n const lookupRaw = (lookupKey: string): unknown => {\n // navigatePath on the returned proxy will correctly resolve nested properties\n const result = navigatePath(content, resolveKey(lookupKey));\n // For leaf nodes, we can access .value to get the real underlying primitive/node\n return (result as any)?.$raw?.value ?? (result as any)?.value ?? result;\n };\n\n const translateKey = (lookupKey: string, args: unknown[]): string => {\n const { values, count, defaultMessage } = parseTranslateArguments(args);\n const rawValue = lookupRaw(lookupKey);\n\n if (rawValue === undefined) {\n if (defaultMessage !== undefined) {\n return resolveVueMessage(\n defaultMessage,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n }\n return lookupKey;\n }\n\n return resolveVueMessage(\n rawValue,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n };\n\n const translate = (lookupKey: string, ...args: unknown[]): string =>\n translateKey(lookupKey, args);\n\n return {\n locale: localeRef,\n availableLocales: availableLocales as string[],\n t: translate,\n tc: translate,\n te: (lookupKey: string): boolean => lookupRaw(lookupKey) !== undefined,\n tm: (lookupKey: string): unknown => lookupRaw(lookupKey) ?? {},\n rt: (message: unknown, ...args: unknown[]): string => {\n const { values, count } = parseTranslateArguments(args);\n return resolveVueMessage(\n message,\n values,\n count,\n currentLocale.value as LocalesValues\n );\n },\n d: (\n value: Date | number | string,\n formatOrOptions?: string | Intl.DateTimeFormatOptions\n ): string =>\n formatDateValue(\n value,\n formatOrOptions,\n currentLocale.value,\n datetimeFormats\n ),\n n: (\n value: number,\n formatOrOptions?: string | Intl.NumberFormatOptions\n ): string =>\n formatNumberValue(\n value,\n formatOrOptions,\n currentLocale.value,\n numberFormats\n ),\n };\n}) as UseDictionaryDynamic;\n"],"mappings":";;;;;;;;;;;;;;AAkDA,MAAa,y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} from "@intlayer/core/transpiler";
1
+ import { LooseComposer, TypedComposer } from "./typedComposer.js";
2
2
  import { DictionaryKeys } from "@intlayer/types/module_augmentation";
3
- import { InjectionKey, WritableComputedRef } from "vue";
3
+ import { InjectionKey } from "vue";
4
4
  import { I18n, createI18n as createI18n$1 } from "vue-i18n";
5
-
6
5
  //#region src/createI18n.d.ts
7
6
  declare const VERSION = "9.13.1";
8
7
  declare const I18nInjectionKey: InjectionKey<I18n>;
9
8
  declare const createI18n: typeof createI18n$1;
9
+ /**
10
+ * Overload set for {@link useI18n}: with a `namespace` option the composer is
11
+ * fully typed against that dictionary (keys and return values); without one
12
+ * the root scope applies — the first segment of each key designates the
13
+ * dictionary (`t('about.title')`).
14
+ */
15
+ type UseI18n = {
16
+ <N extends DictionaryKeys>(options: Record<string, unknown> & {
17
+ namespace: N;
18
+ }): TypedComposer<N>;
19
+ (options?: Record<string, unknown> & {
20
+ namespace?: undefined;
21
+ }): LooseComposer;
22
+ };
10
23
  /**
11
24
  * Composable providing a typed `t()` function scoped to a dictionary namespace.
12
25
  * Pass `{ namespace: 'myDict' }` to restrict keys to valid dot-notation paths
13
- * within that intlayer dictionary (autocompleted and validated at compile time).
26
+ * within that intlayer dictionary (autocompleted and validated at compile
27
+ * time) and resolve return types from the content at each path.
14
28
  *
15
29
  * Supports vue-i18n's full message syntax: named (`{name}`) and list (`{0}`)
16
30
  * interpolation, pipe choice messages (`'car | cars'` with a count argument),
@@ -19,23 +33,11 @@ declare const createI18n: typeof createI18n$1;
19
33
  * @example
20
34
  * ```ts
21
35
  * const { t } = useI18n({ namespace: 'about' });
22
- * t('counter.label'); // ✓ typed; compile error if key doesn't exist
36
+ * t('counter.label'); // ✓ typed key and return value
23
37
  * t('apples', 5); // pipe plural choice
24
38
  * ```
25
39
  */
26
- declare const useI18n: <N extends DictionaryKeys = DictionaryKeys>(options?: Record<string, unknown> & {
27
- namespace?: N;
28
- }) => {
29
- locale: WritableComputedRef<string>;
30
- availableLocales: string[];
31
- t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
32
- tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
33
- te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;
34
- tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;
35
- rt: (message: unknown, ...args: unknown[]) => string;
36
- d: (value: Date | number | string, formatOrOptions?: string | Intl.DateTimeFormatOptions) => string;
37
- n: (value: number, formatOrOptions?: string | Intl.NumberFormatOptions) => string;
38
- };
40
+ declare const useI18n: UseI18n;
39
41
  //#endregion
40
42
  export { I18nInjectionKey, VERSION, createI18n, useI18n };
41
43
  //# sourceMappingURL=createI18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createI18n.d.ts","names":[],"sources":["../../src/createI18n.ts"],"mappings":";;;;;;cA4Ba,OAAA;AAAA,cACA,gBAAA,EAAkB,YAAA,CAAa,IAAA;AAAA,cAoG/B,UAAA,SAAmB,YAAA;;;;;AApGhC;;;;;AAoGA;;;;;AAgLA;;cAAa,OAAA,aAAqB,cAAA,GAAiB,cAAA,EACjD,OAAA,GAAU,MAAA;EAA4B,SAAA,GAAY,CAAA;AAAA;EAElD,MAAA,EAAQ,mBAAA;EACR,gBAAA;EACA,CAAA,aAAc,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC9C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC/C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,GAAK,OAAA,cAAqB,IAAA;EAC1B,CAAA,GACE,KAAA,EAAO,IAAA,oBACP,eAAA,YAA2B,IAAA,CAAK,qBAAA;EAElC,CAAA,GACE,KAAA,UACA,eAAA,YAA2B,IAAA,CAAK,mBAAA;AAAA"}
1
+ {"version":3,"file":"createI18n.d.ts","names":[],"sources":["../../src/createI18n.ts"],"mappings":";;;;;cA8Ba;cACA,kBAAkB,aAAa;cAmI/B,mBAAmB;;;;;;;KAwK3B;GACF,UAAU,gBACT,SAAS;IAA4B,WAAW;MAC/C,cAAc;GAEf,UAAU;IAA4B;MACrC;;;;;;;;;;;;;;;;;;;cAoBQ,SAqEP"}
@@ -1 +1 @@
1
- {"version":3,"file":"formats.d.ts","names":[],"sources":["../../src/formats.ts"],"mappings":";;AAOA;;;;;KAAY,qBAAA,GAAwB,MAAA,SAElC,MAAA,SAAe,IAAA,CAAK,qBAAA;;KAIV,mBAAA,GAAsB,MAAA,SAEhC,MAAA,SAAe,IAAA,CAAK,mBAAA;;cAmBT,eAAA,GACX,KAAA,EAAO,IAAA,oBACP,eAAA,WAA0B,IAAA,CAAK,qBAAA,cAC/B,MAAA,UACA,eAAA,GAAkB,qBAAA;;cAaP,iBAAA,GACX,KAAA,UACA,eAAA,WAA0B,IAAA,CAAK,mBAAA,cAC/B,MAAA,UACA,aAAA,GAAgB,mBAAA"}
1
+ {"version":3,"file":"formats.d.ts","names":[],"sources":["../../src/formats.ts"],"mappings":";;;;;;;KAOY,wBAAwB,eAElC,eAAe,KAAK;;KAIV,sBAAsB,eAEhC,eAAe,KAAK;;cAmBT,kBAAe,OACnB,wBAAsB,0BACH,KAAK,mCAAiC,gBAClD,kBACI;;cAaP,oBAAiB,eACf,0BACa,KAAK,iCAA+B,gBAChD,gBACE"}
@@ -1,5 +1,6 @@
1
+ import { ContentAtPath, LooseComposer, ScopedComposer, ScopedDotPaths, TranslatedValue, TypedComposer } from "./typedComposer.js";
1
2
  import { I18nInjectionKey, VERSION, createI18n, useI18n } from "./createI18n.js";
2
3
  import { useDictionary } from "./useDictionary.js";
3
4
  import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
4
5
  import { Composer, I18n, I18nOptions, UseI18nOptions } from "vue-i18n";
5
- export { type Composer, type I18n, I18nInjectionKey, type I18nOptions, type UseI18nOptions, VERSION, createI18n, useDictionary, useDictionaryDynamic, useI18n };
6
+ export { type Composer, type ContentAtPath, type I18n, I18nInjectionKey, type I18nOptions, type LooseComposer, type ScopedComposer, type ScopedDotPaths, type TranslatedValue, type TypedComposer, type UseI18nOptions, VERSION, createI18n, useDictionary, useDictionaryDynamic, useI18n };
@@ -1,6 +1,5 @@
1
1
  import { PluginOption } from "vite";
2
2
  import { intlayer } from "vite-intlayer";
3
-
4
3
  //#region src/plugin/index.d.ts
5
4
  /**
6
5
  * A Vite plugin for vue-i18n compat that wraps vite-intlayer
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AA4BA;;cAAa,iBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;;cAaa,oBAAiB,UAClB,kBAAkB,iBAC3B"}
@@ -1,6 +1,5 @@
1
1
  import { LocalesValues } from "@intlayer/types/module_augmentation";
2
2
  import { MessageValues } from "@intlayer/core/messageFormat";
3
-
4
3
  //#region src/resolveVueMessage.d.ts
5
4
  /**
6
5
  * Splits a vue-i18n choice message (`'no car | one car | {count} cars'`)
@@ -15,8 +14,11 @@ declare const splitChoices: (message: string) => string[];
15
14
  declare const getChoiceIndex: (choice: number, choicesLength: number) => number;
16
15
  /** Arguments parsed from vue-i18n's polymorphic `t()` signatures. */
17
16
  type ParsedTranslateArguments = {
18
- /** Named (`{name}`) or list (`{0}`) interpolation values. */values: MessageValues; /** Plural choice count, when a number argument was provided. */
19
- count?: number; /** Default message, when a string argument was provided. */
17
+ /** Named (`{name}`) or list (`{0}`) interpolation values. */
18
+ values: MessageValues;
19
+ /** Plural choice count, when a number argument was provided. */
20
+ count?: number;
21
+ /** Default message, when a string argument was provided. */
20
22
  defaultMessage?: string;
21
23
  };
22
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolveVueMessage.d.ts","names":[],"sources":["../../src/resolveVueMessage.ts"],"mappings":";;;;;;AAWA;;cAAa,YAAA,GAAgB,OAAA;;;AAQ7B;;;cAAa,cAAA,GACX,MAAA,UACA,aAAA;;KAYU,wBAAA;EAAwB,6DAElC,MAAA,EAAQ,aAAA,EAAa;EAErB,KAAA,WAFQ;EAIR,cAAA;AAAA;;;AAQF;;;cAAa,uBAAA,GACX,IAAA,gBACC,wBAAA;;AA6BH;;;;;cAAa,iBAAA,GACX,KAAA,WACA,MAAA,EAAQ,aAAA,EACR,KAAA,sBACA,MAAA,EAAQ,aAAA"}
1
+ {"version":3,"file":"resolveVueMessage.d.ts","names":[],"sources":["../../src/resolveVueMessage.ts"],"mappings":";;;;;;;cAWa,eAAY;;;;;;cAQZ,iBAAc,gBACX;;KAaJ;;EAEV,QAAQ;;EAER;;EAEA;;;;;;;cAQW,0BAAuB,oBAEjC;;;;;;;cA6BU,oBAAiB,gBACd,QACN,eAAa,2BACI,QACjB"}
@@ -0,0 +1,64 @@
1
+ import { DictionaryKeys } from "@intlayer/types/module_augmentation";
2
+ import { WritableComputedRef } from "vue";
3
+ import { GetNestingResult } from "@intlayer/core/interpreter";
4
+ import { ValidDotPathsFor } from "@intlayer/core/transpiler";
5
+ //#region src/typedComposer.d.ts
6
+ /**
7
+ * The interpreter-resolved content type at dot-path `P` of dictionary `N` —
8
+ * the same type strength as the base `useIntlayer` hook.
9
+ */
10
+ type ContentAtPath<N extends DictionaryKeys, P> = GetNestingResult<N, P>;
11
+ /**
12
+ * The value returned by `t()` for key `P` of dictionary `N`: string literals
13
+ * declared in the dictionary keep their literal type (matching the strength of
14
+ * `useIntlayer`), every other node resolves to `string` at runtime.
15
+ */
16
+ type TranslatedValue<N extends DictionaryKeys, P> = ContentAtPath<N, P> extends string ? ContentAtPath<N, P> : string;
17
+ /**
18
+ * The dot-paths of dictionary `N` relative to the namespace prefix `Prefix`
19
+ * (`useI18n({ namespace: 'about.counter' })` → paths under `about.counter`).
20
+ */
21
+ type ScopedDotPaths<N extends DictionaryKeys, Prefix extends string> = ValidDotPathsFor<N> extends (infer AllPaths) ? AllPaths extends `${Prefix}.${infer RelativePath}` ? RelativePath : never : never;
22
+ /** Non-translation members shared by every composer shape. */
23
+ type ComposerBase = {
24
+ locale: WritableComputedRef<string>;
25
+ availableLocales: string[];
26
+ rt: (message: unknown, ...args: unknown[]) => string;
27
+ d: (value: Date | number | string, formatOrOptions?: string | Intl.DateTimeFormatOptions) => string;
28
+ n: (value: number, formatOrOptions?: string | Intl.NumberFormatOptions) => string;
29
+ };
30
+ /**
31
+ * Composer returned when the namespace is a bare dictionary key: `t`/`tc`/
32
+ * `te`/`tm` keys are the dictionary's dot-paths and return types are resolved
33
+ * from the content at that path.
34
+ */
35
+ type TypedComposer<N extends DictionaryKeys> = ComposerBase & {
36
+ t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => TranslatedValue<N, P>;
37
+ tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => TranslatedValue<N, P>;
38
+ te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;
39
+ tm: <P extends ValidDotPathsFor<N>>(key: P) => ContentAtPath<N, P>;
40
+ };
41
+ /**
42
+ * Composer returned when a key prefix scopes the dictionary `N`: keys are
43
+ * relative dot-paths under `Prefix`, and return types are resolved against
44
+ * the absolute path in the dictionary.
45
+ */
46
+ type ScopedComposer<N extends DictionaryKeys, Prefix extends string> = ComposerBase & {
47
+ t: <P extends ScopedDotPaths<N, Prefix>>(key: P, ...args: unknown[]) => TranslatedValue<N, `${Prefix}.${P}`>;
48
+ tc: <P extends ScopedDotPaths<N, Prefix>>(key: P, ...args: unknown[]) => TranslatedValue<N, `${Prefix}.${P}`>;
49
+ te: <P extends ScopedDotPaths<N, Prefix>>(key: P) => boolean;
50
+ tm: <P extends ScopedDotPaths<N, Prefix>>(key: P) => ContentAtPath<N, `${Prefix}.${P}`>;
51
+ };
52
+ /**
53
+ * Loosely-typed composer returned for the root scope (no namespace): the
54
+ * first segment of each key designates the dictionary (`t('about.title')`).
55
+ */
56
+ type LooseComposer = ComposerBase & {
57
+ t: (key: string, ...args: unknown[]) => string;
58
+ tc: (key: string, ...args: unknown[]) => string;
59
+ te: (key: string) => boolean;
60
+ tm: (key: string) => unknown;
61
+ };
62
+ //#endregion
63
+ export { ContentAtPath, LooseComposer, ScopedComposer, ScopedDotPaths, TranslatedValue, TypedComposer };
64
+ //# sourceMappingURL=typedComposer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedComposer.d.ts","names":[],"sources":["../../src/typedComposer.ts"],"mappings":";;;;;;;;;KASY,cAAc,UAAU,gBAAgB,KAAK,iBAAiB,GAAG;;;;;;KAOjE,gBAAgB,UAAU,gBAAgB,KACpD,cAAc,GAAG,oBAAoB,cAAc,GAAG;;;;;KAM5C,eAAe,UAAU,gBAAgB,yBACnD,iBAAiB,kBAAiB,YAC9B,oBAAoB,gBAAgB,iBAClC;;KAKH;EACH,QAAQ;EACR;EACA,KAAK,qBAAqB;EAC1B,IACE,OAAO,wBACP,2BAA2B,KAAK;EAElC,IACE,eACA,2BAA2B,KAAK;;;;;;;KASxB,cAAc,UAAU,kBAAkB;EACpD,IAAI,UAAU,iBAAiB,IAC7B,KAAK,MACF,oBACA,gBAAgB,GAAG;EACxB,KAAK,UAAU,iBAAiB,IAC9B,KAAK,MACF,oBACA,gBAAgB,GAAG;EACxB,KAAK,UAAU,iBAAiB,IAAI,KAAK;EACzC,KAAK,UAAU,iBAAiB,IAAI,KAAK,MAAM,cAAc,GAAG;;;;;;;KAQtD,eACV,UAAU,gBACV,yBACE;EACF,IAAI,UAAU,eAAe,GAAG,SAC9B,KAAK,MACF,oBACA,gBAAgB,MAAM,UAAU;EACrC,KAAK,UAAU,eAAe,GAAG,SAC/B,KAAK,MACF,oBACA,gBAAgB,MAAM,UAAU;EACrC,KAAK,UAAU,eAAe,GAAG,SAAS,KAAK;EAC/C,KAAK,UAAU,eAAe,GAAG,SAC/B,KAAK,MACF,cAAc,MAAM,UAAU;;;;;;KAOzB,gBAAgB;EAC1B,IAAI,gBAAgB;EACpB,KAAK,gBAAgB;EACrB,KAAK;EACL,KAAK"}
@@ -1,9 +1,21 @@
1
- import { ValidDotPathsFor } from "@intlayer/core/transpiler";
1
+ import { ScopedComposer, TypedComposer } from "./typedComposer.js";
2
2
  import { DictionaryKeys } from "@intlayer/types/module_augmentation";
3
- import { WritableComputedRef } from "vue";
4
3
  import { Dictionary } from "@intlayer/types/dictionary";
5
-
6
4
  //#region src/useDictionary.d.ts
5
+ /**
6
+ * Overload set for {@link useDictionary}: without a `namespace` option the
7
+ * composer is typed against the dictionary's dot-paths; with one (the
8
+ * key-prefix remainder left by the build rewrite) the keys are relative
9
+ * dot-paths under that scope.
10
+ */
11
+ type UseDictionary = {
12
+ <T extends Dictionary>(dictionary: T, options?: Record<string, unknown> & {
13
+ namespace?: undefined;
14
+ }): TypedComposer<T['key'] & DictionaryKeys>;
15
+ <T extends Dictionary, Prefix extends string>(dictionary: T, options: Record<string, unknown> & {
16
+ namespace: Prefix;
17
+ }): ScopedComposer<T['key'] & DictionaryKeys, Prefix>;
18
+ };
7
19
  /**
8
20
  * Dictionary-accepting variant of `useI18n`.
9
21
  *
@@ -11,19 +23,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
11
23
  * at runtime by key, the Babel plugin pre-imports the dictionary JSON at build time
12
24
  * and passes it directly here. This enables tree-shaking of unused locale content.
13
25
  */
14
- declare const useDictionary: <const T extends Dictionary, const N extends DictionaryKeys = DictionaryKeys>(dictionary: T, options?: Record<string, unknown> & {
15
- namespace?: N;
16
- }) => {
17
- locale: WritableComputedRef<string>;
18
- availableLocales: string[];
19
- t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
20
- tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
21
- te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;
22
- tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;
23
- rt: (message: unknown, ...args: unknown[]) => string;
24
- d: (value: Date | number | string, formatOrOptions?: string | Intl.DateTimeFormatOptions) => string;
25
- n: (value: number, formatOrOptions?: string | Intl.NumberFormatOptions) => string;
26
- };
26
+ declare const useDictionary: UseDictionary;
27
27
  //#endregion
28
28
  export { useDictionary };
29
29
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;AA2CA;;;;;cAAa,aAAA,mBACK,UAAA,kBACA,cAAA,GAAiB,cAAA,EAEjC,UAAA,EAAY,CAAA,EACZ,OAAA,GAAU,MAAA;EAA4B,SAAA,GAAY,CAAA;AAAA;EAElD,MAAA,EAAQ,mBAAA;EACR,gBAAA;EACA,CAAA,aAAc,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC9C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC/C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,GAAK,OAAA,cAAqB,IAAA;EAC1B,CAAA,GACE,KAAA,EAAO,IAAA,oBACP,eAAA,YAA2B,IAAA,CAAK,qBAAA;EAElC,CAAA,GACE,KAAA,UACA,eAAA,YAA2B,IAAA,CAAK,mBAAA;AAAA"}
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;;KA0BK;GACF,UAAU,YACT,YAAY,GACZ,UAAU;IAA4B;MACrC,cAAc,WAAW;GAC3B,UAAU,YAAY,uBACrB,YAAY,GACZ,SAAS;IAA4B,WAAW;MAC/C,eAAe,WAAW,gBAAgB;;;;;;;;;cAUlC,eAkGP"}
@@ -1,9 +1,21 @@
1
- import { ValidDotPathsFor } from "@intlayer/core/transpiler";
1
+ import { ScopedComposer, TypedComposer } from "./typedComposer.js";
2
2
  import { DictionaryKeys, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
3
- import { WritableComputedRef } from "vue";
4
3
  import { Dictionary } from "@intlayer/types/dictionary";
5
-
6
4
  //#region src/useDictionaryDynamic.d.ts
5
+ /**
6
+ * Overload set for {@link useDictionaryDynamic}: without a `namespace` option
7
+ * the composer is typed against the dictionary's dot-paths; with one (the
8
+ * key-prefix remainder left by the build rewrite) the keys are relative
9
+ * dot-paths under that scope.
10
+ */
11
+ type UseDictionaryDynamic = {
12
+ <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, options?: Record<string, unknown> & {
13
+ namespace?: undefined;
14
+ }): TypedComposer<K>;
15
+ <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, options: Record<string, unknown> & {
16
+ namespace: Prefix;
17
+ }): ScopedComposer<K, Prefix>;
18
+ };
7
19
  /**
8
20
  * Dynamic dictionary-accepting variant of `useI18n`.
9
21
  *
@@ -11,19 +23,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
11
23
  * at runtime by key, the Babel plugin dynamically imports the dictionary JSON
12
24
  * (or .mjs module) based on the locale.
13
25
  */
14
- declare const useDictionaryDynamic: <const T extends Dictionary, const K extends string, const N extends DictionaryKeys = DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, options?: Record<string, unknown> & {
15
- namespace?: N;
16
- }) => {
17
- locale: WritableComputedRef<string>;
18
- availableLocales: string[];
19
- t: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
20
- tc: <P extends ValidDotPathsFor<N>>(key: P, ...args: unknown[]) => string;
21
- te: <P extends ValidDotPathsFor<N>>(key: P) => boolean;
22
- tm: <P extends ValidDotPathsFor<N>>(key: P) => unknown;
23
- rt: (message: unknown, ...args: unknown[]) => string;
24
- d: (value: Date | number | string, formatOrOptions?: string | Intl.DateTimeFormatOptions) => string;
25
- n: (value: number, formatOrOptions?: string | Intl.NumberFormatOptions) => string;
26
- };
26
+ declare const useDictionaryDynamic: UseDictionaryDynamic;
27
27
  //#endregion
28
28
  export { useDictionaryDynamic };
29
29
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;AA+CA;;;;;cAAa,oBAAA,mBACK,UAAA,0CAEA,cAAA,GAAiB,cAAA,EAEjC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,OAAA,GAAU,MAAA;EAA4B,SAAA,GAAY,CAAA;AAAA;EAElD,MAAA,EAAQ,mBAAA;EACR,gBAAA;EACA,CAAA,aAAc,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC9C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA,KAAM,IAAA;EAC/C,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,aAAe,gBAAA,CAAiB,CAAA,GAAI,GAAA,EAAK,CAAA;EACzC,EAAA,GAAK,OAAA,cAAqB,IAAA;EAC1B,CAAA,GACE,KAAA,EAAO,IAAA,oBACP,eAAA,YAA2B,IAAA,CAAK,qBAAA;EAElC,CAAA,GACE,KAAA,UACA,eAAA,YAA2B,IAAA,CAAK,mBAAA;AAAA"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;KA8BK;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,UAAU;IAA4B;MACrC,cAAc;GAChB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,SAAS;IAA4B,WAAW;MAC/C,eAAe,GAAG;;;;;;;;;cAUV,sBAyGP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/vue-i18n",
3
- "version": "9.0.0-canary.8",
3
+ "version": "9.0.0",
4
4
  "private": false,
5
5
  "description": "vue-i18n API adapter for intlayer — useI18n, createI18n, and installIntlayer backed by vue-intlayer",
6
6
  "keywords": [
@@ -75,26 +75,26 @@
75
75
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
76
76
  },
77
77
  "dependencies": {
78
- "@intlayer/chokidar": "9.0.0-canary.8",
79
- "@intlayer/config": "9.0.0-canary.8",
80
- "@intlayer/core": "9.0.0-canary.8",
81
- "@intlayer/dictionaries-entry": "9.0.0-canary.8",
82
- "@intlayer/types": "9.0.0-canary.8",
83
- "vite-intlayer": "9.0.0-canary.8",
84
- "vue-intlayer": "9.0.0-canary.8"
78
+ "@intlayer/config": "9.0.0",
79
+ "@intlayer/core": "9.0.0",
80
+ "@intlayer/dictionaries-entry": "9.0.0",
81
+ "@intlayer/engine": "9.0.0",
82
+ "@intlayer/types": "9.0.0",
83
+ "vite-intlayer": "9.0.0",
84
+ "vue-intlayer": "9.0.0"
85
85
  },
86
86
  "devDependencies": {
87
- "@types/node": "25.9.4",
87
+ "@types/node": "26.1.1",
88
88
  "@utils/ts-config": "1.0.4",
89
89
  "@utils/ts-config-types": "1.0.4",
90
90
  "@utils/tsdown-config": "1.0.4",
91
91
  "rimraf": "6.1.3",
92
- "tsdown": "0.21.10",
93
- "typescript": "6.0.3",
94
- "vite": "8.1.0",
95
- "vitest": "4.1.9",
96
- "vue": "3.5.38",
97
- "vue-i18n": "11.4.5"
92
+ "tsdown": "0.22.13",
93
+ "typescript": "7.0.2",
94
+ "vite": "8.1.5",
95
+ "vitest": "4.1.10",
96
+ "vue": "3.5.40",
97
+ "vue-i18n": "11.4.7"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "vite": ">=4.0.0",