@intlayer/svelte-i18n 9.5.10 → 9.5.12

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.
package/README.md CHANGED
@@ -213,7 +213,8 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
213
213
  <li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
214
214
  <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
215
215
  <li><a href="https://intlayer.org/doc/environment/solid-start" rel=''>Solid Start</a></li>
216
- <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li> <li>
216
+ <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
217
+ <li>
217
218
  <a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
218
219
  <ul>
219
220
  <li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
@@ -223,6 +224,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
223
224
  <li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
224
225
  <li><a href="https://intlayer.org/doc/environment/elysia" rel=''>Elysia</a></li>
225
226
  </ul>
227
+
226
228
  </li>
227
229
  </ul>
228
230
  </details>
@@ -1 +1 @@
1
- {"version":3,"file":"createMessageFormatter.mjs","names":[],"sources":["../../src/createMessageFormatter.ts"],"sourcesContent":["import {\n interpolateMessage,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { configDefaultLocale, runtimeOptions } from './configuration';\nimport type { MessageFormatter, MessageObject } from './types';\n\n/** Reads the raw message (string, node or subtree) of an id for a locale. */\nexport type MessageLookup = (id: string, locale: string) => unknown;\n\n/**\n * Whether a looked-up value can be rendered as a message: a string, an\n * interpreted callable, or an intlayer node (compiled runtime ICU) — not a\n * plain subtree.\n */\nconst isRenderableMessage = (message: unknown): boolean =>\n typeof message === 'string' ||\n typeof message === 'function' ||\n Array.isArray(message) ||\n (typeof message === 'object' && message !== null && 'nodeType' in message);\n\n/**\n * Builds the `$_` function for the active locale on top of a lookup.\n *\n * Resolution follows svelte-i18n: the requested locale, then the\n * `fallbackLocale` from `init()`, then `handleMissingMessage`, then the\n * `default` message, then the id itself. Intlayer dictionaries arrive already\n * converted to nodes, so no message parser is involved here.\n *\n * @param activeLocale - The current `$locale` value.\n * @param lookup - Where messages are read from (registry, bound dictionary…).\n */\nexport const createMessageFormatter =\n (\n activeLocale: string | null | undefined,\n lookup: MessageLookup\n ): MessageFormatter =>\n (idOrMessage: string | MessageObject, options?: Omit<MessageObject, 'id'>) => {\n const message: MessageObject =\n typeof idOrMessage === 'string'\n ? { ...options, id: idOrMessage }\n : { ...options, ...idOrMessage };\n\n const { id, values = {}, default: defaultMessage } = message;\n const targetLocale = message.locale ?? activeLocale ?? configDefaultLocale;\n const { fallbackLocale } = runtimeOptions;\n\n const candidateLocales =\n fallbackLocale && fallbackLocale !== targetLocale\n ? [targetLocale, fallbackLocale]\n : [targetLocale];\n\n for (const candidateLocale of candidateLocales) {\n const content = lookup(id, candidateLocale);\n\n if (isRenderableMessage(content)) {\n return resolveMessageNodeToString(\n content,\n values,\n candidateLocale as LocalesValues\n );\n }\n }\n\n const handledMessage = runtimeOptions.handleMissingMessage?.({\n locale: targetLocale,\n id,\n defaultValue: defaultMessage,\n });\n if (typeof handledMessage === 'string') return handledMessage;\n\n return defaultMessage === undefined\n ? id\n : interpolateMessage(\n defaultMessage,\n values,\n targetLocale as LocalesValues\n );\n };\n"],"mappings":";;;;;;;;;AAgBA,MAAM,uBAAuB,YAC3B,OAAO,YAAY,YACnB,OAAO,YAAY,cACnB,MAAM,QAAQ,OAAO,KACpB,OAAO,YAAY,YAAY,YAAY,QAAQ,cAAc;;;;;;;;;;;;AAapE,MAAa,0BAET,cACA,YAED,aAAqC,YAAwC;CAC5E,MAAM,UACJ,OAAO,gBAAgB,WACnB;EAAE,GAAG;EAAS,IAAI;CAAY,IAC9B;EAAE,GAAG;EAAS,GAAG;CAAY;CAEnC,MAAM,EAAE,IAAI,SAAS,CAAC,GAAG,SAAS,mBAAmB;CACrD,MAAM,eAAe,QAAQ,UAAU,gBAAgB;CACvD,MAAM,EAAE,mBAAmB;CAE3B,MAAM,mBACJ,kBAAkB,mBAAmB,eACjC,CAAC,cAAc,cAAc,IAC7B,CAAC,YAAY;CAEnB,KAAK,MAAM,mBAAmB,kBAAkB;EAC9C,MAAM,UAAU,OAAO,IAAI,eAAe;EAE1C,IAAI,oBAAoB,OAAO,GAC7B,OAAO,2BACL,SACA,QACA,eACF;CAEJ;CAEA,MAAM,iBAAiB,eAAe,uBAAuB;EAC3D,QAAQ;EACR;EACA,cAAc;CAChB,CAAC;CACD,IAAI,OAAO,mBAAmB,UAAU,OAAO;CAE/C,OAAO,mBAAmB,SACtB,KACA,mBACE,gBACA,QACA,YACF;AACN"}
1
+ {"version":3,"file":"createMessageFormatter.mjs","names":[],"sources":["../../src/createMessageFormatter.ts"],"sourcesContent":["import {\n interpolateMessage,\n resolveMessageNodeToString,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { configDefaultLocale, runtimeOptions } from './configuration';\nimport type { MessageFormatter, MessageObject } from './types';\n\n/** Reads the raw message (string, node or subtree) of an id for a locale. */\nexport type MessageLookup = (id: string, locale: string) => unknown;\n\n/**\n * Whether a looked-up value can be rendered as a message: a string, an\n * interpreted callable, or an intlayer node (compiled runtime ICU) — not a\n * plain subtree.\n */\nconst isRenderableMessage = (message: unknown): boolean =>\n typeof message === 'string' ||\n typeof message === 'function' ||\n Array.isArray(message) ||\n (typeof message === 'object' && message !== null && 'nodeType' in message);\n\n/**\n * Builds the `$_` function for the active locale on top of a lookup.\n *\n * Resolution follows svelte-i18n: the requested locale, then the\n * `fallbackLocale` from `init()`, then `handleMissingMessage`, then the\n * `default` message, then the id itself. Intlayer dictionaries arrive already\n * converted to nodes, so no message parser is involved here.\n *\n * @param activeLocale - The current `$locale` value.\n * @param lookup - Where messages are read from (registry, bound dictionary…).\n */\nexport const createMessageFormatter =\n (\n activeLocale: string | null | undefined,\n lookup: MessageLookup\n ): MessageFormatter =>\n (\n idOrMessage: string | MessageObject,\n options?: Omit<MessageObject, 'id'>\n ) => {\n const message: MessageObject =\n typeof idOrMessage === 'string'\n ? { ...options, id: idOrMessage }\n : { ...options, ...idOrMessage };\n\n const { id, values = {}, default: defaultMessage } = message;\n const targetLocale = message.locale ?? activeLocale ?? configDefaultLocale;\n const { fallbackLocale } = runtimeOptions;\n\n const candidateLocales =\n fallbackLocale && fallbackLocale !== targetLocale\n ? [targetLocale, fallbackLocale]\n : [targetLocale];\n\n for (const candidateLocale of candidateLocales) {\n const content = lookup(id, candidateLocale);\n\n if (isRenderableMessage(content)) {\n return resolveMessageNodeToString(\n content,\n values,\n candidateLocale as LocalesValues\n );\n }\n }\n\n const handledMessage = runtimeOptions.handleMissingMessage?.({\n locale: targetLocale,\n id,\n defaultValue: defaultMessage,\n });\n if (typeof handledMessage === 'string') return handledMessage;\n\n return defaultMessage === undefined\n ? id\n : interpolateMessage(\n defaultMessage,\n values,\n targetLocale as LocalesValues\n );\n };\n"],"mappings":";;;;;;;;;AAgBA,MAAM,uBAAuB,YAC3B,OAAO,YAAY,YACnB,OAAO,YAAY,cACnB,MAAM,QAAQ,OAAO,KACpB,OAAO,YAAY,YAAY,YAAY,QAAQ,cAAc;;;;;;;;;;;;AAapE,MAAa,0BAET,cACA,YAGA,aACA,YACG;CACH,MAAM,UACJ,OAAO,gBAAgB,WACnB;EAAE,GAAG;EAAS,IAAI;CAAY,IAC9B;EAAE,GAAG;EAAS,GAAG;CAAY;CAEnC,MAAM,EAAE,IAAI,SAAS,CAAC,GAAG,SAAS,mBAAmB;CACrD,MAAM,eAAe,QAAQ,UAAU,gBAAgB;CACvD,MAAM,EAAE,mBAAmB;CAE3B,MAAM,mBACJ,kBAAkB,mBAAmB,eACjC,CAAC,cAAc,cAAc,IAC7B,CAAC,YAAY;CAEnB,KAAK,MAAM,mBAAmB,kBAAkB;EAC9C,MAAM,UAAU,OAAO,IAAI,eAAe;EAE1C,IAAI,oBAAoB,OAAO,GAC7B,OAAO,2BACL,SACA,QACA,eACF;CAEJ;CAEA,MAAM,iBAAiB,eAAe,uBAAuB;EAC3D,QAAQ;EACR;EACA,cAAc;CAChB,CAAC;CACD,IAAI,OAAO,mBAAmB,UAAU,OAAO;CAE/C,OAAO,mBAAmB,SACtB,KACA,mBACE,gBACA,QACA,YACF;AACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/helpers.ts"],"sourcesContent":["import {\n createMessageResolver,\n icuToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { Readable } from 'svelte/store';\nimport { configDefaultLocale, setRuntimeOptions } from './configuration';\nimport { locale } from './locale';\nimport { dictionary, setMessageCompiler } from './runtimeMessages';\nimport type {\n ConfigureOptionsInit,\n InterpolationValues,\n LocaleDictionary,\n MessageObject,\n MessagesLoader,\n} from './types';\n\n/**\n * Configures fallback locale, formats and missing-message handling, then\n * activates `initialLocale` (or keeps intlayer's current locale).\n */\nexport const init = (options: ConfigureOptionsInit): Promise<void> => {\n setRuntimeOptions(options);\n\n if (options.initialLocale) locale.set(options.initialLocale);\n\n return Promise.resolve();\n};\n\n/**\n * Merges runtime messages into a locale. Messages may be raw ICU strings:\n * this is the one entry point that bundles the ICU parser.\n */\nexport const addMessages = (\n targetLocale: string,\n ...partials: LocaleDictionary[]\n): void => {\n setMessageCompiler(icuToIntlayerFormatter);\n\n dictionary.update((messages) => ({\n ...messages,\n [targetLocale]: Object.assign({}, messages[targetLocale], ...partials),\n }));\n};\n\n/** Messages from `register()` still being loaded. */\nconst pendingLoads = new Set<Promise<void>>();\n\n/**\n * Registers a loader for runtime messages. Intlayer dictionaries need no\n * registration — this only serves catalogs kept outside intlayer.\n */\nexport const register = (targetLocale: string, loader: MessagesLoader): void => {\n const pendingLoad = loader()\n .then((messages) => {\n addMessages(\n targetLocale,\n 'default' in messages\n ? (messages.default as LocaleDictionary)\n : messages\n );\n })\n .finally(() => {\n pendingLoads.delete(pendingLoad);\n });\n\n pendingLoads.add(pendingLoad);\n};\n\n/** Resolves once every `register()` loader has settled. */\nexport const waitLocale = async (_locale?: string): Promise<void> => {\n await Promise.allSettled([...pendingLoads]);\n};\n\n/** Identity helper typing a message map. */\nexport const defineMessages = <T extends Record<string, MessageObject>>(\n messages: T\n): T => messages;\n\ntype StoreValue<S> = S extends Readable<infer V> ? V : never;\n\n/**\n * Turns a function store (`$_`, `$date`…) into a plain function usable\n * outside components. `freeze()` stops tracking locale changes.\n */\nexport const unwrapFunctionStore = <\n S extends Readable<(...args: never[]) => unknown>,\n>(\n store: S\n): StoreValue<S> & { freeze: () => void } => {\n let currentFunction: StoreValue<S> | undefined;\n\n const unsubscribe = store.subscribe((value) => {\n currentFunction = value as StoreValue<S>;\n });\n\n const unwrapped = ((...args: Parameters<StoreValue<S>>) =>\n currentFunction?.(...args)) as StoreValue<S> & { freeze: () => void };\n\n unwrapped.freeze = unsubscribe;\n\n return unwrapped;\n};\n\n/**\n * Standalone ICU formatter for a raw message string — bundles the ICU\n * parser, like `addMessages`.\n */\nexport const getMessageFormatter = (\n message: string,\n targetLocale: string = configDefaultLocale\n): { format: (values?: InterpolationValues) => string } => {\n const resolveIcuMessage = createMessageResolver(icuToIntlayerFormatter);\n\n return {\n format: (values) =>\n resolveIcuMessage(message, values ?? {}, targetLocale as LocalesValues),\n };\n};\n\nconst matchLocale = (value: string, pattern: RegExp): string | null => {\n const match = pattern.exec(value);\n return match ? (match[1] ?? match[0]) : null;\n};\n\n/** Reads a locale from `window.location.hostname` with a capture group. */\nexport const getLocaleFromHostname = (hostname: RegExp): string | null =>\n typeof window === 'undefined'\n ? null\n : matchLocale(window.location.hostname, hostname);\n\n/** Reads a locale from `window.location.pathname` with a capture group. */\nexport const getLocaleFromPathname = (pathname: RegExp): string | null =>\n typeof window === 'undefined'\n ? null\n : matchLocale(window.location.pathname, pathname);\n\n/** The browser's preferred locale. */\nexport const getLocaleFromNavigator = (): string | null =>\n typeof navigator === 'undefined'\n ? null\n : (navigator.languages?.[0] ?? navigator.language ?? null);\n\nconst readSearchParam = (search: string, key: string): string | null =>\n new URLSearchParams(search).get(key);\n\n/** Reads the `key` query-string parameter of the current URL. */\nexport const getLocaleFromQueryString = (key: string): string | null =>\n typeof window === 'undefined'\n ? null\n : readSearchParam(window.location.search, key);\n\n/** Reads the `key` parameter of the current URL hash (`#lang=fr`). */\nexport const getLocaleFromHash = (key: string): string | null =>\n typeof window === 'undefined'\n ? null\n : readSearchParam(window.location.hash.slice(1), key);\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,QAAQ,YAAiD;CACpE,kBAAkB,OAAO;CAEzB,IAAI,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa;CAE3D,OAAO,QAAQ,QAAQ;AACzB;;;;;AAMA,MAAa,eACX,cACA,GAAG,aACM;CACT,mBAAmB,sBAAsB;CAEzC,WAAW,QAAQ,cAAc;EAC/B,GAAG;GACF,eAAe,OAAO,OAAO,CAAC,GAAG,SAAS,eAAe,GAAG,QAAQ;CACvE,EAAE;AACJ;;AAGA,MAAM,+BAAe,IAAI,IAAmB;;;;;AAM5C,MAAa,YAAY,cAAsB,WAAiC;CAC9E,MAAM,cAAc,OAAO,CAAC,CACzB,MAAM,aAAa;EAClB,YACE,cACA,aAAa,WACR,SAAS,UACV,QACN;CACF,CAAC,CAAC,CACD,cAAc;EACb,aAAa,OAAO,WAAW;CACjC,CAAC;CAEH,aAAa,IAAI,WAAW;AAC9B;;AAGA,MAAa,aAAa,OAAO,YAAoC;CACnE,MAAM,QAAQ,WAAW,CAAC,GAAG,YAAY,CAAC;AAC5C;;AAGA,MAAa,kBACX,aACM;;;;;AAQR,MAAa,uBAGX,UAC2C;CAC3C,IAAI;CAEJ,MAAM,cAAc,MAAM,WAAW,UAAU;EAC7C,kBAAkB;CACpB,CAAC;CAED,MAAM,cAAc,GAAG,SACrB,kBAAkB,GAAG,IAAI;CAE3B,UAAU,SAAS;CAEnB,OAAO;AACT;;;;;AAMA,MAAa,uBACX,SACA,eAAuB,wBACkC;CACzD,MAAM,oBAAoB,sBAAsB,sBAAsB;CAEtE,OAAO,EACL,SAAS,WACP,kBAAkB,SAAS,UAAU,CAAC,GAAG,YAA6B,EAC1E;AACF;AAEA,MAAM,eAAe,OAAe,YAAmC;CACrE,MAAM,QAAQ,QAAQ,KAAK,KAAK;CAChC,OAAO,QAAS,MAAM,MAAM,MAAM,KAAM;AAC1C;;AAGA,MAAa,yBAAyB,aACpC,OAAO,WAAW,cACd,OACA,YAAY,OAAO,SAAS,UAAU,QAAQ;;AAGpD,MAAa,yBAAyB,aACpC,OAAO,WAAW,cACd,OACA,YAAY,OAAO,SAAS,UAAU,QAAQ;;AAGpD,MAAa,+BACX,OAAO,cAAc,cACjB,OACC,UAAU,YAAY,MAAM,UAAU,YAAY;AAEzD,MAAM,mBAAmB,QAAgB,QACvC,IAAI,gBAAgB,MAAM,CAAC,CAAC,IAAI,GAAG;;AAGrC,MAAa,4BAA4B,QACvC,OAAO,WAAW,cACd,OACA,gBAAgB,OAAO,SAAS,QAAQ,GAAG;;AAGjD,MAAa,qBAAqB,QAChC,OAAO,WAAW,cACd,OACA,gBAAgB,OAAO,SAAS,KAAK,MAAM,CAAC,GAAG,GAAG"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/helpers.ts"],"sourcesContent":["import {\n createMessageResolver,\n icuToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { Readable } from 'svelte/store';\nimport { configDefaultLocale, setRuntimeOptions } from './configuration';\nimport { locale } from './locale';\nimport { dictionary, setMessageCompiler } from './runtimeMessages';\nimport type {\n ConfigureOptionsInit,\n InterpolationValues,\n LocaleDictionary,\n MessageObject,\n MessagesLoader,\n} from './types';\n\n/**\n * Configures fallback locale, formats and missing-message handling, then\n * activates `initialLocale` (or keeps intlayer's current locale).\n */\nexport const init = (options: ConfigureOptionsInit): Promise<void> => {\n setRuntimeOptions(options);\n\n if (options.initialLocale) locale.set(options.initialLocale);\n\n return Promise.resolve();\n};\n\n/**\n * Merges runtime messages into a locale. Messages may be raw ICU strings:\n * this is the one entry point that bundles the ICU parser.\n */\nexport const addMessages = (\n targetLocale: string,\n ...partials: LocaleDictionary[]\n): void => {\n setMessageCompiler(icuToIntlayerFormatter);\n\n dictionary.update((messages) => ({\n ...messages,\n [targetLocale]: Object.assign({}, messages[targetLocale], ...partials),\n }));\n};\n\n/** Messages from `register()` still being loaded. */\nconst pendingLoads = new Set<Promise<void>>();\n\n/**\n * Registers a loader for runtime messages. Intlayer dictionaries need no\n * registration — this only serves catalogs kept outside intlayer.\n */\nexport const register = (\n targetLocale: string,\n loader: MessagesLoader\n): void => {\n const pendingLoad = loader()\n .then((messages) => {\n addMessages(\n targetLocale,\n 'default' in messages\n ? (messages.default as LocaleDictionary)\n : messages\n );\n })\n .finally(() => {\n pendingLoads.delete(pendingLoad);\n });\n\n pendingLoads.add(pendingLoad);\n};\n\n/** Resolves once every `register()` loader has settled. */\nexport const waitLocale = async (_locale?: string): Promise<void> => {\n await Promise.allSettled([...pendingLoads]);\n};\n\n/** Identity helper typing a message map. */\nexport const defineMessages = <T extends Record<string, MessageObject>>(\n messages: T\n): T => messages;\n\ntype StoreValue<S> = S extends Readable<infer V> ? V : never;\n\n/**\n * Turns a function store (`$_`, `$date`…) into a plain function usable\n * outside components. `freeze()` stops tracking locale changes.\n */\nexport const unwrapFunctionStore = <\n S extends Readable<(...args: never[]) => unknown>,\n>(\n store: S\n): StoreValue<S> & { freeze: () => void } => {\n let currentFunction: StoreValue<S> | undefined;\n\n const unsubscribe = store.subscribe((value) => {\n currentFunction = value as StoreValue<S>;\n });\n\n const unwrapped = ((...args: Parameters<StoreValue<S>>) =>\n currentFunction?.(...args)) as StoreValue<S> & { freeze: () => void };\n\n unwrapped.freeze = unsubscribe;\n\n return unwrapped;\n};\n\n/**\n * Standalone ICU formatter for a raw message string — bundles the ICU\n * parser, like `addMessages`.\n */\nexport const getMessageFormatter = (\n message: string,\n targetLocale: string = configDefaultLocale\n): { format: (values?: InterpolationValues) => string } => {\n const resolveIcuMessage = createMessageResolver(icuToIntlayerFormatter);\n\n return {\n format: (values) =>\n resolveIcuMessage(message, values ?? {}, targetLocale as LocalesValues),\n };\n};\n\nconst matchLocale = (value: string, pattern: RegExp): string | null => {\n const match = pattern.exec(value);\n return match ? (match[1] ?? match[0]) : null;\n};\n\n/** Reads a locale from `window.location.hostname` with a capture group. */\nexport const getLocaleFromHostname = (hostname: RegExp): string | null =>\n typeof window === 'undefined'\n ? null\n : matchLocale(window.location.hostname, hostname);\n\n/** Reads a locale from `window.location.pathname` with a capture group. */\nexport const getLocaleFromPathname = (pathname: RegExp): string | null =>\n typeof window === 'undefined'\n ? null\n : matchLocale(window.location.pathname, pathname);\n\n/** The browser's preferred locale. */\nexport const getLocaleFromNavigator = (): string | null =>\n typeof navigator === 'undefined'\n ? null\n : (navigator.languages?.[0] ?? navigator.language ?? null);\n\nconst readSearchParam = (search: string, key: string): string | null =>\n new URLSearchParams(search).get(key);\n\n/** Reads the `key` query-string parameter of the current URL. */\nexport const getLocaleFromQueryString = (key: string): string | null =>\n typeof window === 'undefined'\n ? null\n : readSearchParam(window.location.search, key);\n\n/** Reads the `key` parameter of the current URL hash (`#lang=fr`). */\nexport const getLocaleFromHash = (key: string): string | null =>\n typeof window === 'undefined'\n ? null\n : readSearchParam(window.location.hash.slice(1), key);\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,QAAQ,YAAiD;CACpE,kBAAkB,OAAO;CAEzB,IAAI,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa;CAE3D,OAAO,QAAQ,QAAQ;AACzB;;;;;AAMA,MAAa,eACX,cACA,GAAG,aACM;CACT,mBAAmB,sBAAsB;CAEzC,WAAW,QAAQ,cAAc;EAC/B,GAAG;GACF,eAAe,OAAO,OAAO,CAAC,GAAG,SAAS,eAAe,GAAG,QAAQ;CACvE,EAAE;AACJ;;AAGA,MAAM,+BAAe,IAAI,IAAmB;;;;;AAM5C,MAAa,YACX,cACA,WACS;CACT,MAAM,cAAc,OAAO,CAAC,CACzB,MAAM,aAAa;EAClB,YACE,cACA,aAAa,WACR,SAAS,UACV,QACN;CACF,CAAC,CAAC,CACD,cAAc;EACb,aAAa,OAAO,WAAW;CACjC,CAAC;CAEH,aAAa,IAAI,WAAW;AAC9B;;AAGA,MAAa,aAAa,OAAO,YAAoC;CACnE,MAAM,QAAQ,WAAW,CAAC,GAAG,YAAY,CAAC;AAC5C;;AAGA,MAAa,kBACX,aACM;;;;;AAQR,MAAa,uBAGX,UAC2C;CAC3C,IAAI;CAEJ,MAAM,cAAc,MAAM,WAAW,UAAU;EAC7C,kBAAkB;CACpB,CAAC;CAED,MAAM,cAAc,GAAG,SACrB,kBAAkB,GAAG,IAAI;CAE3B,UAAU,SAAS;CAEnB,OAAO;AACT;;;;;AAMA,MAAa,uBACX,SACA,eAAuB,wBACkC;CACzD,MAAM,oBAAoB,sBAAsB,sBAAsB;CAEtE,OAAO,EACL,SAAS,WACP,kBAAkB,SAAS,UAAU,CAAC,GAAG,YAA6B,EAC1E;AACF;AAEA,MAAM,eAAe,OAAe,YAAmC;CACrE,MAAM,QAAQ,QAAQ,KAAK,KAAK;CAChC,OAAO,QAAS,MAAM,MAAM,MAAM,KAAM;AAC1C;;AAGA,MAAa,yBAAyB,aACpC,OAAO,WAAW,cACd,OACA,YAAY,OAAO,SAAS,UAAU,QAAQ;;AAGpD,MAAa,yBAAyB,aACpC,OAAO,WAAW,cACd,OACA,YAAY,OAAO,SAAS,UAAU,QAAQ;;AAGpD,MAAa,+BACX,OAAO,cAAc,cACjB,OACC,UAAU,YAAY,MAAM,UAAU,YAAY;AAEzD,MAAM,mBAAmB,QAAgB,QACvC,IAAI,gBAAgB,MAAM,CAAC,CAAC,IAAI,GAAG;;AAGrC,MAAa,4BAA4B,QACvC,OAAO,WAAW,cACd,OACA,gBAAgB,OAAO,SAAS,QAAQ,GAAG;;AAGjD,MAAa,qBAAqB,QAChC,OAAO,WAAW,cACd,OACA,gBAAgB,OAAO,SAAS,KAAK,MAAM,CAAC,GAAG,GAAG"}
@@ -1,9 +1,9 @@
1
- import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
2
1
  import { isLoading, locale, locales } from "./locale.mjs";
3
2
  import { dictionary } from "./runtimeMessages.mjs";
4
3
  import { addMessages, defineMessages, getLocaleFromHash, getLocaleFromHostname, getLocaleFromNavigator, getLocaleFromPathname, getLocaleFromQueryString, getMessageFormatter, init, register, unwrapFunctionStore, waitLocale } from "./helpers.mjs";
5
- import { _, date, format, json, number, t, time } from "./stores.mjs";
6
4
  import { useDictionary } from "./useDictionary.mjs";
7
5
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
6
+ import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
7
+ import { _, date, format, json, number, t, time } from "./stores.mjs";
8
8
 
9
9
  export { _, addMessages, date, defineMessages, dictionary, format, getDateFormatter, getLocaleFromHash, getLocaleFromHostname, getLocaleFromNavigator, getLocaleFromPathname, getLocaleFromQueryString, getMessageFormatter, getNumberFormatter, getTimeFormatter, init, isLoading, json, locale, locales, number, register, t, time, unwrapFunctionStore, useDictionary, useDictionaryDynamic, waitLocale };
@@ -1,9 +1,9 @@
1
1
  import { runtimeOptions } from "./configuration.mjs";
2
- import { createMessageFormatter } from "./createMessageFormatter.mjs";
3
- import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
4
2
  import { locale } from "./locale.mjs";
5
3
  import { dictionary, lookupRuntimeMessage } from "./runtimeMessages.mjs";
6
4
  import { lookupRegistryMessage } from "./registryLookup.mjs";
5
+ import { createMessageFormatter } from "./createMessageFormatter.mjs";
6
+ import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
7
7
  import { derived } from "svelte/store";
8
8
 
9
9
  //#region src/stores.ts
@@ -1 +1 @@
1
- {"version":3,"file":"stores.mjs","names":[],"sources":["../../src/stores.ts"],"sourcesContent":["import { derived, type Readable } from 'svelte/store';\nimport { runtimeOptions } from './configuration';\nimport { createMessageFormatter } from './createMessageFormatter';\nimport {\n getDateFormatter,\n getNumberFormatter,\n getTimeFormatter,\n} from './formatters';\nimport { locale } from './locale';\nimport { lookupRegistryMessage } from './registryLookup';\nimport { dictionary, lookupRuntimeMessage } from './runtimeMessages';\nimport type {\n DateFormatter,\n JSONGetter,\n LocalesDictionary,\n MessageFormatter,\n NumberFormatter,\n TimeFormatter,\n} from './types';\n\n/** Runtime messages win over dictionaries, as `addMessages` overrides. */\nconst lookupMessage = (\n messages: LocalesDictionary,\n id: string,\n targetLocale: string\n): unknown =>\n lookupRuntimeMessage(messages, targetLocale, id) ??\n lookupRegistryMessage(id, targetLocale);\n\n/** `$format` / `$_` / `$t` — translates a message id. */\nexport const format: Readable<MessageFormatter> = derived(\n [locale, dictionary],\n ([$locale, $dictionary]) =>\n createMessageFormatter($locale, (id, targetLocale) =>\n lookupMessage($dictionary, id, targetLocale)\n )\n);\n\nexport const _ = format;\nexport const t = format;\n\n/** `$json` — the raw message or subtree of an id. */\nexport const json: Readable<JSONGetter> = derived(\n [locale, dictionary],\n ([$locale, $dictionary]) =>\n <T = unknown>(id: string, targetLocale?: string): T | undefined =>\n lookupMessage(\n $dictionary,\n id,\n targetLocale ?? $locale ?? runtimeOptions.fallbackLocale\n ) as T | undefined\n);\n\n/** `$date` — formats a date with the `date` named formats. */\nexport const date: Readable<DateFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getDateFormatter({ locale: $locale ?? undefined, ...options }).format(\n value\n )\n);\n\n/** `$time` — formats a time with the `time` named formats. */\nexport const time: Readable<TimeFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getTimeFormatter({ locale: $locale ?? undefined, ...options }).format(\n value\n )\n);\n\n/** `$number` — formats a number with the `number` named formats. */\nexport const number: Readable<NumberFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getNumberFormatter({ locale: $locale ?? undefined, ...options }).format(\n value\n )\n);\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,iBACJ,UACA,IACA,iBAEA,qBAAqB,UAAU,cAAc,EAAE,KAC/C,sBAAsB,IAAI,YAAY;;AAGxC,MAAa,SAAqC,QAChD,CAAC,QAAQ,UAAU,IAClB,CAAC,SAAS,iBACT,uBAAuB,UAAU,IAAI,iBACnC,cAAc,aAAa,IAAI,YAAY,CAC7C,CACJ;AAEA,MAAa,IAAI;AACjB,MAAa,IAAI;;AAGjB,MAAa,OAA6B,QACxC,CAAC,QAAQ,UAAU,IAClB,CAAC,SAAS,kBACK,IAAY,iBACxB,cACE,aACA,IACA,gBAAgB,WAAW,eAAe,cAC5C,CACN;;AAGA,MAAa,OAAgC,QAC3C,SACC,aAAa,OAAO,YACnB,iBAAiB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAC7D,KACF,CACJ;;AAGA,MAAa,OAAgC,QAC3C,SACC,aAAa,OAAO,YACnB,iBAAiB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAC7D,KACF,CACJ;;AAGA,MAAa,SAAoC,QAC/C,SACC,aAAa,OAAO,YACnB,mBAAmB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAC/D,KACF,CACJ"}
1
+ {"version":3,"file":"stores.mjs","names":[],"sources":["../../src/stores.ts"],"sourcesContent":["import { derived, type Readable } from 'svelte/store';\nimport { runtimeOptions } from './configuration';\nimport { createMessageFormatter } from './createMessageFormatter';\nimport {\n getDateFormatter,\n getNumberFormatter,\n getTimeFormatter,\n} from './formatters';\nimport { locale } from './locale';\nimport { lookupRegistryMessage } from './registryLookup';\nimport { dictionary, lookupRuntimeMessage } from './runtimeMessages';\nimport type {\n DateFormatter,\n JSONGetter,\n LocalesDictionary,\n MessageFormatter,\n NumberFormatter,\n TimeFormatter,\n} from './types';\n\n/** Runtime messages win over dictionaries, as `addMessages` overrides. */\nconst lookupMessage = (\n messages: LocalesDictionary,\n id: string,\n targetLocale: string\n): unknown =>\n lookupRuntimeMessage(messages, targetLocale, id) ??\n lookupRegistryMessage(id, targetLocale);\n\n/** `$format` / `$_` / `$t` — translates a message id. */\nexport const format: Readable<MessageFormatter> = derived(\n [locale, dictionary],\n ([$locale, $dictionary]) =>\n createMessageFormatter($locale, (id, targetLocale) =>\n lookupMessage($dictionary, id, targetLocale)\n )\n);\n\nexport const _ = format;\nexport const t = format;\n\n/** `$json` — the raw message or subtree of an id. */\nexport const json: Readable<JSONGetter> = derived(\n [locale, dictionary],\n ([$locale, $dictionary]) =>\n <T = unknown>(id: string, targetLocale?: string): T | undefined =>\n lookupMessage(\n $dictionary,\n id,\n targetLocale ?? $locale ?? runtimeOptions.fallbackLocale\n ) as T | undefined\n);\n\n/** `$date` — formats a date with the `date` named formats. */\nexport const date: Readable<DateFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getDateFormatter({ locale: $locale ?? undefined, ...options }).format(value)\n);\n\n/** `$time` — formats a time with the `time` named formats. */\nexport const time: Readable<TimeFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getTimeFormatter({ locale: $locale ?? undefined, ...options }).format(value)\n);\n\n/** `$number` — formats a number with the `number` named formats. */\nexport const number: Readable<NumberFormatter> = derived(\n locale,\n ($locale) => (value, options) =>\n getNumberFormatter({ locale: $locale ?? undefined, ...options }).format(\n value\n )\n);\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,iBACJ,UACA,IACA,iBAEA,qBAAqB,UAAU,cAAc,EAAE,KAC/C,sBAAsB,IAAI,YAAY;;AAGxC,MAAa,SAAqC,QAChD,CAAC,QAAQ,UAAU,IAClB,CAAC,SAAS,iBACT,uBAAuB,UAAU,IAAI,iBACnC,cAAc,aAAa,IAAI,YAAY,CAC7C,CACJ;AAEA,MAAa,IAAI;AACjB,MAAa,IAAI;;AAGjB,MAAa,OAA6B,QACxC,CAAC,QAAQ,UAAU,IAClB,CAAC,SAAS,kBACK,IAAY,iBACxB,cACE,aACA,IACA,gBAAgB,WAAW,eAAe,cAC5C,CACN;;AAGA,MAAa,OAAgC,QAC3C,SACC,aAAa,OAAO,YACnB,iBAAiB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAAO,KAAK,CAC/E;;AAGA,MAAa,OAAgC,QAC3C,SACC,aAAa,OAAO,YACnB,iBAAiB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAAO,KAAK,CAC/E;;AAGA,MAAa,SAAoC,QAC/C,SACC,aAAa,OAAO,YACnB,mBAAmB;CAAE,QAAQ,WAAW;CAAW,GAAG;AAAQ,CAAC,CAAC,CAAC,OAC/D,KACF,CACJ"}
@@ -1,6 +1,6 @@
1
1
  import { configDefaultLocale } from "./configuration.mjs";
2
- import { createMessageFormatter } from "./createMessageFormatter.mjs";
3
2
  import { locale } from "./locale.mjs";
3
+ import { createMessageFormatter } from "./createMessageFormatter.mjs";
4
4
  import { navigatePath } from "@intlayer/core/messageFormat";
5
5
  import { derived } from "svelte/store";
6
6
  import { getDictionary } from "@intlayer/core/interpreter";
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","names":[],"sources":["../../src/helpers.ts"],"mappings":";;;;;;;qBAqBa,OAAI,SAAa,yBAAuB;;;;;qBAYxC,cAAW,yBACF,UACP;;;;;qBAiBF,WAAQ,sBAAwB,QAAU;;qBAkB1C,aAAU,qBAA6B;;qBAKvC,iBAAkB,UAAU,eAAe,gBAAc,UAC1D,MACT;KAEE,WAAW,KAAK,UAAU,eAAe,KAAK;;;;;qBAMtC,sBACX,UAAU,aAAa,4BAA0B,OAE1C,MACN,WAAW;EAAO;;;;;;qBAmBR,sBAAmB,iBACf;EAEZ,SAAS,SAAS;;;qBAeV,wBAAqB,UAAc;;qBAMnC,wBAAqB,UAAc;;qBAMnC;;qBASA,2BAAwB;;qBAMxB,oBAAiB"}
1
+ {"version":3,"file":"helpers.d.ts","names":[],"sources":["../../src/helpers.ts"],"mappings":";;;;;;;qBAqBa,OAAI,SAAa,yBAAuB;;;;;qBAYxC,cAAW,yBACF,UACP;;;;;qBAiBF,WAAQ,sBACC,QACZ;;qBAmBG,aAAU,qBAA6B;;qBAKvC,iBAAkB,UAAU,eAAe,gBAAc,UAC1D,MACT;KAEE,WAAW,KAAK,UAAU,eAAe,KAAK;;;;;qBAMtC,sBACX,UAAU,aAAa,4BAA0B,OAE1C,MACN,WAAW;EAAO;;;;;;qBAmBR,sBAAmB,iBACf;EAEZ,SAAS,SAAS;;;qBAeV,wBAAqB,UAAc;;qBAMnC,wBAAqB,UAAc;;qBAMnC;;qBASA,2BAAwB;;qBAMxB,oBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"stores.d.ts","names":[],"sources":["../../src/stores.ts"],"mappings":";;;;qBA8Ba,QAAQ,SAAS;qBAQjB,GAAC,SAAA;qBACD,GAAC,SAAA;;qBAGD,MAAM,SAAS;;qBAYf,MAAM,SAAS;;qBASf,MAAM,SAAS;;qBASf,QAAQ,SAAS"}
1
+ {"version":3,"file":"stores.d.ts","names":[],"sources":["../../src/stores.ts"],"mappings":";;;;qBA8Ba,QAAQ,SAAS;qBAQjB,GAAC,SAAA;qBACD,GAAC,SAAA;;qBAGD,MAAM,SAAS;;qBAYf,MAAM,SAAS;;qBAOf,MAAM,SAAS;;qBAOf,QAAQ,SAAS"}
@@ -35,7 +35,7 @@ export type MissingKeyHandlerInput = {
35
35
  id: string;
36
36
  defaultValue: string | undefined;
37
37
  };
38
- export type MissingKeyHandlerOutput = string | undefined | void;
38
+ export type MissingKeyHandlerOutput = string | void;
39
39
  export type MissingKeyHandler = (input: MissingKeyHandlerInput) => MissingKeyHandlerOutput;
40
40
  export type ConfigureOptions = {
41
41
  /** The global fallback locale. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;YACY,mBAAmB,gBAC7B,kBAAkB,kBACN;;YAGF;EACV,QAAQ,eAAe,KAAK;EAC5B,MAAM,eAAe,KAAK;EAC1B,MAAM,eAAe,KAAK;;YAGhB,sBACR,2CAKI,OACA;YAMI;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC,oBACV,aAAa,eACb,UAAU,KAAK;YAGL,qBAAqB,KAAK;EACpC;EACA;;YAGU,iBACV,MAAM,eACN,UAAU,qBAAqB,KAAK;YAG1B,iBACV,MAAM,eACN,UAAU,qBAAqB,KAAK;YAG1B,mBACV,eACA,UAAU,qBAAqB,KAAK;;YAI1B,cAAc,aACxB,YACA,oBACG;YAEO,8BAA8B,GAAG,MAC3C,UAAU,qBAAqB,OAC5B;YAEO,uBAAuB,QACjC;EAAqB,SAAS;;YAGpB;EACV;EACA;EACA;;YAGU;YAEA,qBACV,OAAO,2BACJ;YAEO;;EAEV;;EAEA;;EAEA,UAAU,QAAQ;;EAElB;;EAEA;;EAEA,uBAAuB;;EAEvB;;YAGU,uBAAuB,KAAK,sCACtC,QAAQ,KAAK;YAEH;GACT,cACG,4BAEA,eAAe;;YAIT,oBAAoB,eAAe;YAEnC,yCACV,8BAA8B,KAAK,cAAc,KAAK;YAE5C,2CACV,8BACE,KAAK,gBACL,KAAK"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;YACY,mBAAmB,gBAC7B,kBAAkB,kBACN;;YAGF;EACV,QAAQ,eAAe,KAAK;EAC5B,MAAM,eAAe,KAAK;EAC1B,MAAM,eAAe,KAAK;;YAGhB,sBACR,2CAKI,OACA;YAMI;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC,oBACV,aAAa,eACb,UAAU,KAAK;YAGL,qBAAqB,KAAK;EACpC;EACA;;YAGU,iBACV,MAAM,eACN,UAAU,qBAAqB,KAAK;YAG1B,iBACV,MAAM,eACN,UAAU,qBAAqB,KAAK;YAG1B,mBACV,eACA,UAAU,qBAAqB,KAAK;;YAI1B,cAAc,aACxB,YACA,oBACG;YAEO,8BAA8B,GAAG,MAC3C,UAAU,qBAAqB,OAC5B;YAEO,uBAAuB,QACjC;EAAqB,SAAS;;YAGpB;EACV;EACA;EACA;;YAIU;YAEA,qBACV,OAAO,2BACJ;YAEO;;EAEV;;EAEA;;EAEA,UAAU,QAAQ;;EAElB;;EAEA;;EAEA,uBAAuB;;EAEvB;;YAGU,uBAAuB,KAAK,sCACtC,QAAQ,KAAK;YAEH;GACT,cACG,4BAEA,eAAe;;YAIT,oBAAoB,eAAe;YAEnC,yCACV,8BAA8B,KAAK,cAAc,KAAK;YAE5C,2CACV,8BACE,KAAK,gBACL,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/svelte-i18n",
3
- "version": "9.5.10",
3
+ "version": "9.5.12",
4
4
  "private": false,
5
5
  "description": "svelte-i18n API adapter for intlayer — drop-in compatibility layer",
6
6
  "keywords": [
@@ -59,22 +59,23 @@
59
59
  "format:fix": "bun --bun biome format --write .",
60
60
  "lint": "bun --bun biome lint .",
61
61
  "lint:fix": "bun --bun biome lint --write .",
62
- "prepublish": "cp -f ../../../README.md ./README.md",
62
+ "prepublish": "cp -f ../../README.md ./README.md",
63
63
  "publish": "bun publish || true",
64
64
  "publish:canary": "bun publish --access public --tag canary || true",
65
+ "publish:ci": "bun ../../scripts/publish-package.mjs",
65
66
  "publish:latest": "bun publish --access public --tag latest || true",
66
67
  "test": "bun --bun vitest run",
67
68
  "test:watch": "bun --bun vitest",
68
69
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
69
70
  },
70
71
  "dependencies": {
71
- "@intlayer/config": "9.5.10",
72
- "@intlayer/core": "9.5.10",
73
- "@intlayer/dictionaries-entry": "9.5.10",
74
- "@intlayer/engine": "9.5.10",
75
- "@intlayer/types": "9.5.10",
76
- "svelte-intlayer": "9.5.10",
77
- "vite-intlayer": "9.5.10"
72
+ "@intlayer/config": "9.5.12",
73
+ "@intlayer/core": "9.5.12",
74
+ "@intlayer/dictionaries-entry": "9.5.12",
75
+ "@intlayer/engine": "9.5.12",
76
+ "@intlayer/types": "9.5.12",
77
+ "svelte-intlayer": "9.5.12",
78
+ "vite-intlayer": "9.5.12"
78
79
  },
79
80
  "devDependencies": {
80
81
  "@types/node": "^22",