@intlayer/svelte-i18n 9.5.10
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 +329 -0
- package/dist/esm/configuration.mjs +98 -0
- package/dist/esm/configuration.mjs.map +1 -0
- package/dist/esm/createMessageFormatter.mjs +49 -0
- package/dist/esm/createMessageFormatter.mjs.map +1 -0
- package/dist/esm/formatters.mjs +53 -0
- package/dist/esm/formatters.mjs.map +1 -0
- package/dist/esm/helpers.mjs +86 -0
- package/dist/esm/helpers.mjs.map +1 -0
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/locale.mjs +35 -0
- package/dist/esm/locale.mjs.map +1 -0
- package/dist/esm/plugin/index.mjs +35 -0
- package/dist/esm/plugin/index.mjs.map +1 -0
- package/dist/esm/registryLookup.mjs +57 -0
- package/dist/esm/registryLookup.mjs.map +1 -0
- package/dist/esm/runtimeMessages.mjs +42 -0
- package/dist/esm/runtimeMessages.mjs.map +1 -0
- package/dist/esm/stores.mjs +36 -0
- package/dist/esm/stores.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/useDictionary.mjs +46 -0
- package/dist/esm/useDictionary.mjs.map +1 -0
- package/dist/esm/useDictionaryDynamic.mjs +50 -0
- package/dist/esm/useDictionaryDynamic.mjs.map +1 -0
- package/dist/types/configuration.d.ts +18 -0
- package/dist/types/configuration.d.ts.map +1 -0
- package/dist/types/createMessageFormatter.d.ts +18 -0
- package/dist/types/createMessageFormatter.d.ts.map +1 -0
- package/dist/types/formatters.d.ts +10 -0
- package/dist/types/formatters.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +49 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/locale.d.ts +21 -0
- package/dist/types/locale.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +11 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/registryLookup.d.ts +14 -0
- package/dist/types/registryLookup.d.ts.map +1 -0
- package/dist/types/runtimeMessages.d.ts +18 -0
- package/dist/types/runtimeMessages.d.ts.map +1 -0
- package/dist/types/stores.d.ts +17 -0
- package/dist/types/stores.d.ts.map +1 -0
- package/dist/types/types.d.ts +64 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/useDictionary.d.ts +39 -0
- package/dist/types/useDictionary.d.ts.map +1 -0
- package/dist/types/useDictionaryDynamic.d.ts +16 -0
- package/dist/types/useDictionaryDynamic.d.ts.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { configDefaultLocale, setRuntimeOptions } from "./configuration.mjs";
|
|
2
|
+
import { locale } from "./locale.mjs";
|
|
3
|
+
import { dictionary, setMessageCompiler } from "./runtimeMessages.mjs";
|
|
4
|
+
import { createMessageResolver, icuToIntlayerFormatter } from "@intlayer/core/messageFormat";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Configures fallback locale, formats and missing-message handling, then
|
|
9
|
+
* activates `initialLocale` (or keeps intlayer's current locale).
|
|
10
|
+
*/
|
|
11
|
+
const init = (options) => {
|
|
12
|
+
setRuntimeOptions(options);
|
|
13
|
+
if (options.initialLocale) locale.set(options.initialLocale);
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Merges runtime messages into a locale. Messages may be raw ICU strings:
|
|
18
|
+
* this is the one entry point that bundles the ICU parser.
|
|
19
|
+
*/
|
|
20
|
+
const addMessages = (targetLocale, ...partials) => {
|
|
21
|
+
setMessageCompiler(icuToIntlayerFormatter);
|
|
22
|
+
dictionary.update((messages) => ({
|
|
23
|
+
...messages,
|
|
24
|
+
[targetLocale]: Object.assign({}, messages[targetLocale], ...partials)
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
/** Messages from `register()` still being loaded. */
|
|
28
|
+
const pendingLoads = /* @__PURE__ */ new Set();
|
|
29
|
+
/**
|
|
30
|
+
* Registers a loader for runtime messages. Intlayer dictionaries need no
|
|
31
|
+
* registration — this only serves catalogs kept outside intlayer.
|
|
32
|
+
*/
|
|
33
|
+
const register = (targetLocale, loader) => {
|
|
34
|
+
const pendingLoad = loader().then((messages) => {
|
|
35
|
+
addMessages(targetLocale, "default" in messages ? messages.default : messages);
|
|
36
|
+
}).finally(() => {
|
|
37
|
+
pendingLoads.delete(pendingLoad);
|
|
38
|
+
});
|
|
39
|
+
pendingLoads.add(pendingLoad);
|
|
40
|
+
};
|
|
41
|
+
/** Resolves once every `register()` loader has settled. */
|
|
42
|
+
const waitLocale = async (_locale) => {
|
|
43
|
+
await Promise.allSettled([...pendingLoads]);
|
|
44
|
+
};
|
|
45
|
+
/** Identity helper typing a message map. */
|
|
46
|
+
const defineMessages = (messages) => messages;
|
|
47
|
+
/**
|
|
48
|
+
* Turns a function store (`$_`, `$date`…) into a plain function usable
|
|
49
|
+
* outside components. `freeze()` stops tracking locale changes.
|
|
50
|
+
*/
|
|
51
|
+
const unwrapFunctionStore = (store) => {
|
|
52
|
+
let currentFunction;
|
|
53
|
+
const unsubscribe = store.subscribe((value) => {
|
|
54
|
+
currentFunction = value;
|
|
55
|
+
});
|
|
56
|
+
const unwrapped = ((...args) => currentFunction?.(...args));
|
|
57
|
+
unwrapped.freeze = unsubscribe;
|
|
58
|
+
return unwrapped;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Standalone ICU formatter for a raw message string — bundles the ICU
|
|
62
|
+
* parser, like `addMessages`.
|
|
63
|
+
*/
|
|
64
|
+
const getMessageFormatter = (message, targetLocale = configDefaultLocale) => {
|
|
65
|
+
const resolveIcuMessage = createMessageResolver(icuToIntlayerFormatter);
|
|
66
|
+
return { format: (values) => resolveIcuMessage(message, values ?? {}, targetLocale) };
|
|
67
|
+
};
|
|
68
|
+
const matchLocale = (value, pattern) => {
|
|
69
|
+
const match = pattern.exec(value);
|
|
70
|
+
return match ? match[1] ?? match[0] : null;
|
|
71
|
+
};
|
|
72
|
+
/** Reads a locale from `window.location.hostname` with a capture group. */
|
|
73
|
+
const getLocaleFromHostname = (hostname) => typeof window === "undefined" ? null : matchLocale(window.location.hostname, hostname);
|
|
74
|
+
/** Reads a locale from `window.location.pathname` with a capture group. */
|
|
75
|
+
const getLocaleFromPathname = (pathname) => typeof window === "undefined" ? null : matchLocale(window.location.pathname, pathname);
|
|
76
|
+
/** The browser's preferred locale. */
|
|
77
|
+
const getLocaleFromNavigator = () => typeof navigator === "undefined" ? null : navigator.languages?.[0] ?? navigator.language ?? null;
|
|
78
|
+
const readSearchParam = (search, key) => new URLSearchParams(search).get(key);
|
|
79
|
+
/** Reads the `key` query-string parameter of the current URL. */
|
|
80
|
+
const getLocaleFromQueryString = (key) => typeof window === "undefined" ? null : readSearchParam(window.location.search, key);
|
|
81
|
+
/** Reads the `key` parameter of the current URL hash (`#lang=fr`). */
|
|
82
|
+
const getLocaleFromHash = (key) => typeof window === "undefined" ? null : readSearchParam(window.location.hash.slice(1), key);
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { addMessages, defineMessages, getLocaleFromHash, getLocaleFromHostname, getLocaleFromNavigator, getLocaleFromPathname, getLocaleFromQueryString, getMessageFormatter, init, register, unwrapFunctionStore, waitLocale };
|
|
86
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
|
|
2
|
+
import { isLoading, locale, locales } from "./locale.mjs";
|
|
3
|
+
import { dictionary } from "./runtimeMessages.mjs";
|
|
4
|
+
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
|
+
import { useDictionary } from "./useDictionary.mjs";
|
|
7
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
8
|
+
|
|
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 };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { configLocales } from "./configuration.mjs";
|
|
2
|
+
import { derived, readable, writable } from "svelte/store";
|
|
3
|
+
import { intlayerStore } from "svelte-intlayer";
|
|
4
|
+
|
|
5
|
+
//#region src/locale.ts
|
|
6
|
+
const currentLocale = derived(intlayerStore, ($store) => $store.locale);
|
|
7
|
+
let currentLocaleValue;
|
|
8
|
+
currentLocale.subscribe((value) => {
|
|
9
|
+
currentLocaleValue = value;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* `$locale` — backed by svelte-intlayer's store, so svelte-i18n call sites,
|
|
13
|
+
* `useIntlayer` and `useLocale().setLocale` share one active locale.
|
|
14
|
+
*/
|
|
15
|
+
const locale = {
|
|
16
|
+
subscribe: currentLocale.subscribe,
|
|
17
|
+
set: (newLocale) => {
|
|
18
|
+
if (newLocale) intlayerStore.setLocale(newLocale);
|
|
19
|
+
},
|
|
20
|
+
update: (updater) => {
|
|
21
|
+
const newLocale = updater(currentLocaleValue);
|
|
22
|
+
if (newLocale) intlayerStore.setLocale(newLocale);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/** `$locales` — the locales declared in the intlayer configuration. */
|
|
26
|
+
const locales = readable(configLocales);
|
|
27
|
+
/**
|
|
28
|
+
* `$isLoading` — always `false`: intlayer dictionaries are part of the bundle
|
|
29
|
+
* (or preloaded per locale), so there is no pending catalog to wait for.
|
|
30
|
+
*/
|
|
31
|
+
const isLoading = writable(false);
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { isLoading, locale, locales };
|
|
35
|
+
//# sourceMappingURL=locale.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.mjs","names":[],"sources":["../../src/locale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { derived, type Readable, readable, writable } from 'svelte/store';\nimport { intlayerStore } from 'svelte-intlayer';\nimport { configLocales } from './configuration';\n\n/** A svelte-i18n `locale` store: writable, nullable. */\nexport type LocaleStore = Readable<string | null | undefined> & {\n set: (locale: string | null | undefined) => void;\n update: (\n updater: (locale: string | null | undefined) => string | null | undefined\n ) => void;\n};\n\nconst currentLocale = derived(\n intlayerStore,\n ($store) => $store.locale as string\n);\n\nlet currentLocaleValue: string | null | undefined;\ncurrentLocale.subscribe((value) => {\n currentLocaleValue = value;\n});\n\n/**\n * `$locale` — backed by svelte-intlayer's store, so svelte-i18n call sites,\n * `useIntlayer` and `useLocale().setLocale` share one active locale.\n */\nexport const locale: LocaleStore = {\n subscribe: currentLocale.subscribe,\n set: (newLocale) => {\n // svelte-i18n allows clearing the locale; intlayer always has one.\n if (newLocale) intlayerStore.setLocale(newLocale as LocalesValues);\n },\n update: (updater) => {\n const newLocale = updater(currentLocaleValue);\n if (newLocale) intlayerStore.setLocale(newLocale as LocalesValues);\n },\n};\n\n/** `$locales` — the locales declared in the intlayer configuration. */\nexport const locales: Readable<string[]> = readable(configLocales);\n\n/**\n * `$isLoading` — always `false`: intlayer dictionaries are part of the bundle\n * (or preloaded per locale), so there is no pending catalog to wait for.\n */\nexport const isLoading = writable(false);\n"],"mappings":";;;;;AAaA,MAAM,gBAAgB,QACpB,gBACC,WAAW,OAAO,MACrB;AAEA,IAAI;AACJ,cAAc,WAAW,UAAU;CACjC,qBAAqB;AACvB,CAAC;;;;;AAMD,MAAa,SAAsB;CACjC,WAAW,cAAc;CACzB,MAAM,cAAc;EAElB,IAAI,WAAW,cAAc,UAAU,SAA0B;CACnE;CACA,SAAS,YAAY;EACnB,MAAM,YAAY,QAAQ,kBAAkB;EAC5C,IAAI,WAAW,cAAc,UAAU,SAA0B;CACnE;AACF;;AAGA,MAAa,UAA8B,SAAS,aAAa;;;;;AAMjE,MAAa,YAAY,SAAS,KAAK"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { SVELTE_I18N_CALLERS } from "@intlayer/config/callers";
|
|
3
|
+
import * as ANSIColors from "@intlayer/config/colors";
|
|
4
|
+
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
5
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
+
import { runOnce } from "@intlayer/engine/utils";
|
|
7
|
+
import { intlayer } from "vite-intlayer";
|
|
8
|
+
|
|
9
|
+
//#region src/plugin/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* A Vite plugin for svelte-i18n compat that wraps vite-intlayer
|
|
12
|
+
* and configures resolve aliases for svelte-i18n.
|
|
13
|
+
*/
|
|
14
|
+
const svelteI18nVitePlugin = (options) => {
|
|
15
|
+
const intlayerConfig = getConfiguration();
|
|
16
|
+
const appLogger = getAppLogger(intlayerConfig);
|
|
17
|
+
runOnce(join(intlayerConfig.system.baseDir, ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
|
|
18
|
+
appLogger([colorize("Please report any issues you met on GitHub:", ANSIColors.GREY), colorize("https://github.com/aymericzip/intlayer/issues", ANSIColors.GREY_LIGHT)]);
|
|
19
|
+
}, { cacheTimeoutMs: 36e5 });
|
|
20
|
+
const basePlugins = intlayer({
|
|
21
|
+
...options,
|
|
22
|
+
compatCallers: [...options?.compatCallers ?? [], ...SVELTE_I18N_CALLERS]
|
|
23
|
+
});
|
|
24
|
+
const compatPlugin = {
|
|
25
|
+
name: "vite-svelte-i18n-compat-plugin",
|
|
26
|
+
config: () => {
|
|
27
|
+
return { resolve: { alias: { "svelte-i18n": "@intlayer/svelte-i18n" } } };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return [...Array.isArray(basePlugins) ? basePlugins : [basePlugins], compatPlugin];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { svelteI18nVitePlugin as default, svelteI18nVitePlugin };
|
|
35
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { SVELTE_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 svelte-i18n compat that wraps vite-intlayer\n * and configures resolve aliases for svelte-i18n.\n */\nexport const svelteI18nVitePlugin = (\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 ?? []), ...SVELTE_I18N_CALLERS],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-svelte-i18n-compat-plugin',\n config: () => {\n return {\n resolve: {\n alias: {\n 'svelte-i18n': '@intlayer/svelte-i18n',\n },\n },\n };\n },\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default svelteI18nVitePlugin;\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,wBACX,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,KAClB,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CAAC,GAAI,SAAS,iBAAiB,CAAC,GAAI,GAAG,mBAAmB;CAC3E,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,cAAc;GACZ,OAAO,EACL,SAAS,EACP,OAAO,EACL,eAAe,wBACjB,EACF,EACF;EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { navigatePath } from "@intlayer/core/messageFormat";
|
|
2
|
+
import { getIntlayer } from "@intlayer/core/interpreter";
|
|
3
|
+
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
4
|
+
|
|
5
|
+
//#region src/registryLookup.ts
|
|
6
|
+
/**
|
|
7
|
+
* Registry-backed message resolution for svelte-i18n ids.
|
|
8
|
+
*
|
|
9
|
+
* This is the only module touching `@intlayer/dictionaries-entry`, which
|
|
10
|
+
* statically imports every dictionary: the dictionary-bound helpers
|
|
11
|
+
* (`useDictionary`) must not reach it, or each would drag the whole catalog
|
|
12
|
+
* into its chunk.
|
|
13
|
+
*/
|
|
14
|
+
/** Keys of every dictionary available at runtime; empty outside a bundle. */
|
|
15
|
+
const getDictionaryKeys = () => {
|
|
16
|
+
try {
|
|
17
|
+
return new Set(Object.keys(getDictionaries()));
|
|
18
|
+
} catch {
|
|
19
|
+
return /* @__PURE__ */ new Set();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const readDictionary = (key, locale) => {
|
|
23
|
+
try {
|
|
24
|
+
return getIntlayer(key, locale);
|
|
25
|
+
} catch {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Looks up a svelte-i18n id across the intlayer dictionaries:
|
|
31
|
+
*
|
|
32
|
+
* 1. `'home.title'` → dictionary `home`, field `title` (one dictionary per
|
|
33
|
+
* top-level group — the layout the build optimizations target);
|
|
34
|
+
* 2. `'home'` → the whole `home` dictionary (`$json('home')`);
|
|
35
|
+
* 3. the full id in every dictionary — a single migrated catalog.
|
|
36
|
+
*
|
|
37
|
+
* @returns The interpreted node (string, object or callable), or `undefined`.
|
|
38
|
+
*/
|
|
39
|
+
const lookupRegistryMessage = (id, locale) => {
|
|
40
|
+
const dictionaryKeys = getDictionaryKeys();
|
|
41
|
+
const dotPosition = id.indexOf(".");
|
|
42
|
+
if (dotPosition > 0) {
|
|
43
|
+
const dictionaryKey = id.slice(0, dotPosition);
|
|
44
|
+
if (dictionaryKeys.has(dictionaryKey)) {
|
|
45
|
+
const message = navigatePath(readDictionary(dictionaryKey, locale), id.slice(dotPosition + 1));
|
|
46
|
+
if (message !== void 0) return message;
|
|
47
|
+
}
|
|
48
|
+
} else if (dictionaryKeys.has(id)) return readDictionary(id, locale);
|
|
49
|
+
for (const dictionaryKey of dictionaryKeys) {
|
|
50
|
+
const message = navigatePath(readDictionary(dictionaryKey, locale), id);
|
|
51
|
+
if (message !== void 0) return message;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { lookupRegistryMessage };
|
|
57
|
+
//# sourceMappingURL=registryLookup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryLookup.mjs","names":[],"sources":["../../src/registryLookup.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport { navigatePath } from '@intlayer/core/messageFormat';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\n\n/**\n * Registry-backed message resolution for svelte-i18n ids.\n *\n * This is the only module touching `@intlayer/dictionaries-entry`, which\n * statically imports every dictionary: the dictionary-bound helpers\n * (`useDictionary`) must not reach it, or each would drag the whole catalog\n * into its chunk.\n */\n\n/** Keys of every dictionary available at runtime; empty outside a bundle. */\nconst getDictionaryKeys = (): Set<string> => {\n try {\n return new Set(Object.keys(getDictionaries()));\n } catch {\n return new Set();\n }\n};\n\nconst readDictionary = (key: string, locale: string): unknown => {\n try {\n return getIntlayer(key as DictionaryKeys, locale as LocalesValues);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Looks up a svelte-i18n id across the intlayer dictionaries:\n *\n * 1. `'home.title'` → dictionary `home`, field `title` (one dictionary per\n * top-level group — the layout the build optimizations target);\n * 2. `'home'` → the whole `home` dictionary (`$json('home')`);\n * 3. the full id in every dictionary — a single migrated catalog.\n *\n * @returns The interpreted node (string, object or callable), or `undefined`.\n */\nexport const lookupRegistryMessage = (id: string, locale: string): unknown => {\n const dictionaryKeys = getDictionaryKeys();\n const dotPosition = id.indexOf('.');\n\n if (dotPosition > 0) {\n const dictionaryKey = id.slice(0, dotPosition);\n\n if (dictionaryKeys.has(dictionaryKey)) {\n const message = navigatePath(\n readDictionary(dictionaryKey, locale),\n id.slice(dotPosition + 1)\n );\n if (message !== undefined) return message;\n }\n } else if (dictionaryKeys.has(id)) {\n return readDictionary(id, locale);\n }\n\n for (const dictionaryKey of dictionaryKeys) {\n const message = navigatePath(readDictionary(dictionaryKey, locale), id);\n if (message !== undefined) return message;\n }\n\n return undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,0BAAuC;CAC3C,IAAI;EACF,OAAO,IAAI,IAAI,OAAO,KAAK,gBAAgB,CAAC,CAAC;CAC/C,QAAQ;EACN,uBAAO,IAAI,IAAI;CACjB;AACF;AAEA,MAAM,kBAAkB,KAAa,WAA4B;CAC/D,IAAI;EACF,OAAO,YAAY,KAAuB,MAAuB;CACnE,QAAQ;EACN;CACF;AACF;;;;;;;;;;;AAYA,MAAa,yBAAyB,IAAY,WAA4B;CAC5E,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,cAAc,GAAG,QAAQ,GAAG;CAElC,IAAI,cAAc,GAAG;EACnB,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW;EAE7C,IAAI,eAAe,IAAI,aAAa,GAAG;GACrC,MAAM,UAAU,aACd,eAAe,eAAe,MAAM,GACpC,GAAG,MAAM,cAAc,CAAC,CAC1B;GACA,IAAI,YAAY,QAAW,OAAO;EACpC;CACF,OAAO,IAAI,eAAe,IAAI,EAAE,GAC9B,OAAO,eAAe,IAAI,MAAM;CAGlC,KAAK,MAAM,iBAAiB,gBAAgB;EAC1C,MAAM,UAAU,aAAa,eAAe,eAAe,MAAM,GAAG,EAAE;EACtE,IAAI,YAAY,QAAW,OAAO;CACpC;AAGF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { navigatePath } from "@intlayer/core/messageFormat";
|
|
2
|
+
import { writable } from "svelte/store";
|
|
3
|
+
|
|
4
|
+
//#region src/runtimeMessages.ts
|
|
5
|
+
/**
|
|
6
|
+
* `$dictionary` — messages registered at runtime through `addMessages()` /
|
|
7
|
+
* `register()`. Intlayer dictionaries never go through this store.
|
|
8
|
+
*/
|
|
9
|
+
const dictionary = writable({});
|
|
10
|
+
/**
|
|
11
|
+
* ICU compiler for runtime messages, installed by `addMessages()`.
|
|
12
|
+
*
|
|
13
|
+
* Only runtime messages can hold raw ICU (`{count, plural, …}`): intlayer
|
|
14
|
+
* dictionaries are converted at build time. Keeping the parser behind this
|
|
15
|
+
* hook lets bundlers drop it from apps that never register runtime messages.
|
|
16
|
+
*/
|
|
17
|
+
let messageCompiler;
|
|
18
|
+
/** Compiled node per raw ICU string. */
|
|
19
|
+
const compiledMessages = /* @__PURE__ */ new Map();
|
|
20
|
+
const setMessageCompiler = (compiler) => {
|
|
21
|
+
messageCompiler = compiler;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Reads a runtime message, compiling raw ICU strings when the compiler is
|
|
25
|
+
* installed. Returns `undefined` when the id is not registered.
|
|
26
|
+
*/
|
|
27
|
+
const lookupRuntimeMessage = (messages, targetLocale, id) => {
|
|
28
|
+
const localeMessages = messages[targetLocale];
|
|
29
|
+
if (!localeMessages) return void 0;
|
|
30
|
+
const message = navigatePath(localeMessages, id);
|
|
31
|
+
if (typeof message !== "string" || !messageCompiler) return message;
|
|
32
|
+
let compiled = compiledMessages.get(message);
|
|
33
|
+
if (compiled === void 0) {
|
|
34
|
+
compiled = messageCompiler(message);
|
|
35
|
+
compiledMessages.set(message, compiled);
|
|
36
|
+
}
|
|
37
|
+
return compiled;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { dictionary, lookupRuntimeMessage, setMessageCompiler };
|
|
42
|
+
//# sourceMappingURL=runtimeMessages.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeMessages.mjs","names":[],"sources":["../../src/runtimeMessages.ts"],"sourcesContent":["import { navigatePath } from '@intlayer/core/messageFormat';\nimport { type Writable, writable } from 'svelte/store';\nimport type { LocalesDictionary } from './types';\n\n/**\n * `$dictionary` — messages registered at runtime through `addMessages()` /\n * `register()`. Intlayer dictionaries never go through this store.\n */\nexport const dictionary: Writable<LocalesDictionary> = writable({});\n\n/** Turns a raw ICU string into an intlayer node tree. */\ntype MessageCompiler = (message: string) => unknown;\n\n/**\n * ICU compiler for runtime messages, installed by `addMessages()`.\n *\n * Only runtime messages can hold raw ICU (`{count, plural, …}`): intlayer\n * dictionaries are converted at build time. Keeping the parser behind this\n * hook lets bundlers drop it from apps that never register runtime messages.\n */\nlet messageCompiler: MessageCompiler | undefined;\n\n/** Compiled node per raw ICU string. */\nconst compiledMessages = new Map<string, unknown>();\n\nexport const setMessageCompiler = (compiler: MessageCompiler): void => {\n messageCompiler = compiler;\n};\n\n/**\n * Reads a runtime message, compiling raw ICU strings when the compiler is\n * installed. Returns `undefined` when the id is not registered.\n */\nexport const lookupRuntimeMessage = (\n messages: LocalesDictionary,\n targetLocale: string,\n id: string\n): unknown => {\n const localeMessages = messages[targetLocale];\n if (!localeMessages) return undefined;\n\n const message = navigatePath(localeMessages, id);\n if (typeof message !== 'string' || !messageCompiler) return message;\n\n let compiled = compiledMessages.get(message);\n if (compiled === undefined) {\n compiled = messageCompiler(message);\n compiledMessages.set(message, compiled);\n }\n return compiled;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,aAA0C,SAAS,CAAC,CAAC;;;;;;;;AAYlE,IAAI;;AAGJ,MAAM,mCAAmB,IAAI,IAAqB;AAElD,MAAa,sBAAsB,aAAoC;CACrE,kBAAkB;AACpB;;;;;AAMA,MAAa,wBACX,UACA,cACA,OACY;CACZ,MAAM,iBAAiB,SAAS;CAChC,IAAI,CAAC,gBAAgB,OAAO;CAE5B,MAAM,UAAU,aAAa,gBAAgB,EAAE;CAC/C,IAAI,OAAO,YAAY,YAAY,CAAC,iBAAiB,OAAO;CAE5D,IAAI,WAAW,iBAAiB,IAAI,OAAO;CAC3C,IAAI,aAAa,QAAW;EAC1B,WAAW,gBAAgB,OAAO;EAClC,iBAAiB,IAAI,SAAS,QAAQ;CACxC;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { runtimeOptions } from "./configuration.mjs";
|
|
2
|
+
import { createMessageFormatter } from "./createMessageFormatter.mjs";
|
|
3
|
+
import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.mjs";
|
|
4
|
+
import { locale } from "./locale.mjs";
|
|
5
|
+
import { dictionary, lookupRuntimeMessage } from "./runtimeMessages.mjs";
|
|
6
|
+
import { lookupRegistryMessage } from "./registryLookup.mjs";
|
|
7
|
+
import { derived } from "svelte/store";
|
|
8
|
+
|
|
9
|
+
//#region src/stores.ts
|
|
10
|
+
/** Runtime messages win over dictionaries, as `addMessages` overrides. */
|
|
11
|
+
const lookupMessage = (messages, id, targetLocale) => lookupRuntimeMessage(messages, targetLocale, id) ?? lookupRegistryMessage(id, targetLocale);
|
|
12
|
+
/** `$format` / `$_` / `$t` — translates a message id. */
|
|
13
|
+
const format = derived([locale, dictionary], ([$locale, $dictionary]) => createMessageFormatter($locale, (id, targetLocale) => lookupMessage($dictionary, id, targetLocale)));
|
|
14
|
+
const _ = format;
|
|
15
|
+
const t = format;
|
|
16
|
+
/** `$json` — the raw message or subtree of an id. */
|
|
17
|
+
const json = derived([locale, dictionary], ([$locale, $dictionary]) => (id, targetLocale) => lookupMessage($dictionary, id, targetLocale ?? $locale ?? runtimeOptions.fallbackLocale));
|
|
18
|
+
/** `$date` — formats a date with the `date` named formats. */
|
|
19
|
+
const date = derived(locale, ($locale) => (value, options) => getDateFormatter({
|
|
20
|
+
locale: $locale ?? void 0,
|
|
21
|
+
...options
|
|
22
|
+
}).format(value));
|
|
23
|
+
/** `$time` — formats a time with the `time` named formats. */
|
|
24
|
+
const time = derived(locale, ($locale) => (value, options) => getTimeFormatter({
|
|
25
|
+
locale: $locale ?? void 0,
|
|
26
|
+
...options
|
|
27
|
+
}).format(value));
|
|
28
|
+
/** `$number` — formats a number with the `number` named formats. */
|
|
29
|
+
const number = derived(locale, ($locale) => (value, options) => getNumberFormatter({
|
|
30
|
+
locale: $locale ?? void 0,
|
|
31
|
+
...options
|
|
32
|
+
}).format(value));
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { _, date, format, json, number, t, time };
|
|
36
|
+
//# sourceMappingURL=stores.mjs.map
|
|
@@ -0,0 +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"}
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { configDefaultLocale } from "./configuration.mjs";
|
|
2
|
+
import { createMessageFormatter } from "./createMessageFormatter.mjs";
|
|
3
|
+
import { locale } from "./locale.mjs";
|
|
4
|
+
import { navigatePath } from "@intlayer/core/messageFormat";
|
|
5
|
+
import { derived } from "svelte/store";
|
|
6
|
+
import { getDictionary } from "@intlayer/core/interpreter";
|
|
7
|
+
|
|
8
|
+
//#region src/useDictionary.ts
|
|
9
|
+
/** Joins an optional key prefix and a relative id. */
|
|
10
|
+
const toPrefixedId = (id, keyPrefix) => keyPrefix ? `${keyPrefix}.${id}` : id;
|
|
11
|
+
/**
|
|
12
|
+
* Builds the `_` / `t` / `format` / `json` stores over content resolved per
|
|
13
|
+
* locale. Shared by {@link useDictionary} and `useDictionaryDynamic`.
|
|
14
|
+
*/
|
|
15
|
+
const createDictionaryStores = (contentStore, keyPrefix) => {
|
|
16
|
+
const format = derived(contentStore, ({ locale: activeLocale, readContent }) => createMessageFormatter(activeLocale, (id, targetLocale) => navigatePath(readContent(targetLocale), toPrefixedId(id, keyPrefix))));
|
|
17
|
+
return {
|
|
18
|
+
_: format,
|
|
19
|
+
t: format,
|
|
20
|
+
format,
|
|
21
|
+
json: derived(contentStore, ({ locale: activeLocale, readContent }) => (id, targetLocale) => navigatePath(readContent(targetLocale ?? activeLocale ?? configDefaultLocale), toPrefixedId(id, keyPrefix)))
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* svelte-i18n stores bound to one imported dictionary.
|
|
26
|
+
*
|
|
27
|
+
* Ids are relative to the dictionary (`$t('title')`), optionally under a key
|
|
28
|
+
* prefix. Unlike the global `$_`, only this dictionary reaches the bundle.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```svelte
|
|
32
|
+
* <script>
|
|
33
|
+
* import home from '../.intlayer/dictionary/home.json';
|
|
34
|
+
* const { t } = useDictionary(home);
|
|
35
|
+
* <\/script>
|
|
36
|
+
* <h1>{$t('title')}</h1>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
const useDictionary = (dictionary, keyPrefix) => createDictionaryStores(derived(locale, ($locale) => ({
|
|
40
|
+
locale: $locale,
|
|
41
|
+
readContent: (targetLocale) => getDictionary(dictionary, targetLocale)
|
|
42
|
+
})), keyPrefix);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createDictionaryStores, toPrefixedId, useDictionary };
|
|
46
|
+
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import { getDictionary } from '@intlayer/core/interpreter';\nimport { navigatePath } from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { derived, type Readable } from 'svelte/store';\nimport { configDefaultLocale } from './configuration';\nimport { createMessageFormatter } from './createMessageFormatter';\nimport { locale } from './locale';\nimport type { JSONGetter, MessageFormatter } from './types';\n\n/** Message stores bound to one dictionary. */\nexport type DictionaryMessageStores = {\n _: Readable<MessageFormatter>;\n t: Readable<MessageFormatter>;\n format: Readable<MessageFormatter>;\n json: Readable<JSONGetter>;\n};\n\n/** Joins an optional key prefix and a relative id. */\nexport const toPrefixedId = (id: string, keyPrefix?: string): string =>\n keyPrefix ? `${keyPrefix}.${id}` : id;\n\n/**\n * Builds the `_` / `t` / `format` / `json` stores over content resolved per\n * locale. Shared by {@link useDictionary} and `useDictionaryDynamic`.\n */\nexport const createDictionaryStores = (\n contentStore: Readable<{\n locale: string | null | undefined;\n readContent: (targetLocale: string) => unknown;\n }>,\n keyPrefix?: string\n): DictionaryMessageStores => {\n const format: Readable<MessageFormatter> = derived(\n contentStore,\n ({ locale: activeLocale, readContent }) =>\n createMessageFormatter(activeLocale, (id, targetLocale) =>\n navigatePath(readContent(targetLocale), toPrefixedId(id, keyPrefix))\n )\n );\n\n const json: Readable<JSONGetter> = derived(\n contentStore,\n ({ locale: activeLocale, readContent }) =>\n <T = unknown>(id: string, targetLocale?: string): T | undefined =>\n navigatePath(\n readContent(targetLocale ?? activeLocale ?? configDefaultLocale),\n toPrefixedId(id, keyPrefix)\n ) as T | undefined\n );\n\n return { _: format, t: format, format, json };\n};\n\n/**\n * svelte-i18n stores bound to one imported dictionary.\n *\n * Ids are relative to the dictionary (`$t('title')`), optionally under a key\n * prefix. Unlike the global `$_`, only this dictionary reaches the bundle.\n *\n * @example\n * ```svelte\n * <script>\n * import home from '../.intlayer/dictionary/home.json';\n * const { t } = useDictionary(home);\n * </script>\n * <h1>{$t('title')}</h1>\n * ```\n */\nexport const useDictionary = <const T extends Dictionary>(\n dictionary: T,\n keyPrefix?: string\n): DictionaryMessageStores =>\n createDictionaryStores(\n derived(locale, ($locale) => ({\n locale: $locale,\n readContent: (targetLocale: string) =>\n getDictionary(dictionary, targetLocale as LocalesValues),\n })),\n keyPrefix\n );\n"],"mappings":";;;;;;;;;AAmBA,MAAa,gBAAgB,IAAY,cACvC,YAAY,GAAG,UAAU,GAAG,OAAO;;;;;AAMrC,MAAa,0BACX,cAIA,cAC4B;CAC5B,MAAM,SAAqC,QACzC,eACC,EAAE,QAAQ,cAAc,kBACvB,uBAAuB,eAAe,IAAI,iBACxC,aAAa,YAAY,YAAY,GAAG,aAAa,IAAI,SAAS,CAAC,CACrE,CACJ;CAYA,OAAO;EAAE,GAAG;EAAQ,GAAG;EAAQ;EAAQ,MAVJ,QACjC,eACC,EAAE,QAAQ,cAAc,mBACT,IAAY,iBACxB,aACE,YAAY,gBAAgB,gBAAgB,mBAAmB,GAC/D,aAAa,IAAI,SAAS,CAC5B,CAGoC;CAAE;AAC9C;;;;;;;;;;;;;;;;AAiBA,MAAa,iBACX,YACA,cAEA,uBACE,QAAQ,SAAS,aAAa;CAC5B,QAAQ;CACR,cAAc,iBACZ,cAAc,YAAY,YAA6B;AAC3D,EAAE,GACF,SACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { configDefaultLocale } from "./configuration.mjs";
|
|
2
|
+
import { locale } from "./locale.mjs";
|
|
3
|
+
import { createDictionaryStores } from "./useDictionary.mjs";
|
|
4
|
+
import { derived } from "svelte/store";
|
|
5
|
+
import { getDictionary } from "@intlayer/core/interpreter";
|
|
6
|
+
|
|
7
|
+
//#region src/useDictionaryDynamic.ts
|
|
8
|
+
/**
|
|
9
|
+
* Per-locale lazy variant of `useDictionary`: only the active locale's
|
|
10
|
+
* dictionary is fetched. Until it arrives, ids resolve to their `default`
|
|
11
|
+
* message or the id itself.
|
|
12
|
+
*
|
|
13
|
+
* @param dictionaryLoaders - One loader per locale.
|
|
14
|
+
* @param _dictionaryKey - Dictionary key, kept for the optimize-pass shape.
|
|
15
|
+
* @param keyPrefix - Optional prefix applied to every id.
|
|
16
|
+
*/
|
|
17
|
+
const useDictionaryDynamic = (dictionaryLoaders, _dictionaryKey, keyPrefix) => {
|
|
18
|
+
const loadedDictionaries = /* @__PURE__ */ new Map();
|
|
19
|
+
const readContent = (targetLocale) => {
|
|
20
|
+
const loadedDictionary = loadedDictionaries.get(targetLocale);
|
|
21
|
+
return loadedDictionary ? getDictionary(loadedDictionary, targetLocale) : void 0;
|
|
22
|
+
};
|
|
23
|
+
const contentStore = derived(locale, ($locale, set) => {
|
|
24
|
+
const targetLocale = $locale ?? configDefaultLocale;
|
|
25
|
+
const publish = () => set({
|
|
26
|
+
locale: $locale,
|
|
27
|
+
readContent
|
|
28
|
+
});
|
|
29
|
+
publish();
|
|
30
|
+
if (loadedDictionaries.has(targetLocale)) return;
|
|
31
|
+
const loader = dictionaryLoaders[targetLocale];
|
|
32
|
+
if (!loader) return;
|
|
33
|
+
let isCancelled = false;
|
|
34
|
+
loader().then((loadedDictionary) => {
|
|
35
|
+
loadedDictionaries.set(targetLocale, loadedDictionary);
|
|
36
|
+
if (!isCancelled) publish();
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
isCancelled = true;
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
locale: configDefaultLocale,
|
|
43
|
+
readContent
|
|
44
|
+
});
|
|
45
|
+
return createDictionaryStores(contentStore, keyPrefix);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { useDictionaryDynamic };
|
|
50
|
+
//# sourceMappingURL=useDictionaryDynamic.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"sourcesContent":["import { getDictionary } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { derived } from 'svelte/store';\nimport { configDefaultLocale } from './configuration';\nimport { locale } from './locale';\nimport {\n createDictionaryStores,\n type DictionaryMessageStores,\n} from './useDictionary';\n\n/**\n * Per-locale lazy variant of `useDictionary`: only the active locale's\n * dictionary is fetched. Until it arrives, ids resolve to their `default`\n * message or the id itself.\n *\n * @param dictionaryLoaders - One loader per locale.\n * @param _dictionaryKey - Dictionary key, kept for the optimize-pass shape.\n * @param keyPrefix - Optional prefix applied to every id.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n _dictionaryKey: K,\n keyPrefix?: string\n): DictionaryMessageStores => {\n const loadedDictionaries = new Map<string, T>();\n\n const readContent = (targetLocale: string): unknown => {\n const loadedDictionary = loadedDictionaries.get(targetLocale);\n\n return loadedDictionary\n ? getDictionary(loadedDictionary, targetLocale as LocalesValues)\n : undefined;\n };\n\n const contentStore = derived(\n locale,\n ($locale, set) => {\n const targetLocale = $locale ?? configDefaultLocale;\n const publish = () => set({ locale: $locale, readContent });\n\n publish();\n\n if (loadedDictionaries.has(targetLocale)) return;\n\n const loader =\n dictionaryLoaders[targetLocale as keyof typeof dictionaryLoaders];\n if (!loader) return;\n\n let isCancelled = false;\n\n loader().then((loadedDictionary) => {\n loadedDictionaries.set(targetLocale, loadedDictionary);\n if (!isCancelled) publish();\n });\n\n return () => {\n isCancelled = true;\n };\n },\n { locale: configDefaultLocale as string | null | undefined, readContent }\n );\n\n return createDictionaryStores(contentStore, keyPrefix);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,wBAIX,mBACA,gBACA,cAC4B;CAC5B,MAAM,qCAAqB,IAAI,IAAe;CAE9C,MAAM,eAAe,iBAAkC;EACrD,MAAM,mBAAmB,mBAAmB,IAAI,YAAY;EAE5D,OAAO,mBACH,cAAc,kBAAkB,YAA6B,IAC7D;CACN;CAEA,MAAM,eAAe,QACnB,SACC,SAAS,QAAQ;EAChB,MAAM,eAAe,WAAW;EAChC,MAAM,gBAAgB,IAAI;GAAE,QAAQ;GAAS;EAAY,CAAC;EAE1D,QAAQ;EAER,IAAI,mBAAmB,IAAI,YAAY,GAAG;EAE1C,MAAM,SACJ,kBAAkB;EACpB,IAAI,CAAC,QAAQ;EAEb,IAAI,cAAc;EAElB,OAAO,CAAC,CAAC,MAAM,qBAAqB;GAClC,mBAAmB,IAAI,cAAc,gBAAgB;GACrD,IAAI,CAAC,aAAa,QAAQ;EAC5B,CAAC;EAED,aAAa;GACX,cAAc;EAChB;CACF,GACA;EAAE,QAAQ;EAAkD;CAAY,CAC1E;CAEA,OAAO,uBAAuB,cAAc,SAAS;AACvD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConfigureOptions, Formats } from "./types.js";
|
|
2
|
+
//#region src/configuration.d.ts
|
|
3
|
+
/** svelte-i18n's built-in named formats (intl-messageformat defaults). */
|
|
4
|
+
export declare const defaultFormats: Formats;
|
|
5
|
+
/** Locale used when nothing else is set: intlayer's configured default. */
|
|
6
|
+
export declare const configDefaultLocale: string;
|
|
7
|
+
/** Locales declared in the intlayer configuration. */
|
|
8
|
+
export declare const configLocales: string[];
|
|
9
|
+
/** Options set through `init()`, read by every store. */
|
|
10
|
+
export declare const runtimeOptions: Omit<ConfigureOptions, 'formats'> & {
|
|
11
|
+
formats: Formats;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Applies `init()` options, merging custom formats over the defaults.
|
|
15
|
+
*/
|
|
16
|
+
export declare const setRuntimeOptions: (options: Partial<ConfigureOptions>) => void;
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","names":[],"sources":["../../src/configuration.ts"],"mappings":";;;qBAIa,gBAAgB;;qBAgChB;;qBAIA;;qBAKA,gBAAgB,KAAK;EAChC,SAAS;;;;;qBASE,oBAAiB,SAAa,QAAQ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MessageFormatter } from "./types.js";
|
|
2
|
+
//#region src/createMessageFormatter.d.ts
|
|
3
|
+
/** Reads the raw message (string, node or subtree) of an id for a locale. */
|
|
4
|
+
export type MessageLookup = (id: string, locale: string) => unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Builds the `$_` function for the active locale on top of a lookup.
|
|
7
|
+
*
|
|
8
|
+
* Resolution follows svelte-i18n: the requested locale, then the
|
|
9
|
+
* `fallbackLocale` from `init()`, then `handleMissingMessage`, then the
|
|
10
|
+
* `default` message, then the id itself. Intlayer dictionaries arrive already
|
|
11
|
+
* converted to nodes, so no message parser is involved here.
|
|
12
|
+
*
|
|
13
|
+
* @param activeLocale - The current `$locale` value.
|
|
14
|
+
* @param lookup - Where messages are read from (registry, bound dictionary…).
|
|
15
|
+
*/
|
|
16
|
+
export declare const createMessageFormatter: (activeLocale: string | null | undefined, lookup: MessageLookup) => MessageFormatter;
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=createMessageFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMessageFormatter.d.ts","names":[],"sources":["../../src/createMessageFormatter.ts"],"mappings":";;;YASY,iBAAiB,YAAY;;;;;;;;;;;;qBAwB5B,yBAAsB,yCAEQ,QAC/B,kBACP"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MemoizedDateTimeFormatterFactoryOptional, MemoizedNumberFormatterFactoryOptional } from "./types.js";
|
|
2
|
+
//#region src/formatters.d.ts
|
|
3
|
+
/** Memoized `Intl.NumberFormat` honouring named `number` formats. */
|
|
4
|
+
export declare const getNumberFormatter: MemoizedNumberFormatterFactoryOptional;
|
|
5
|
+
/** Memoized `Intl.DateTimeFormat` honouring named `date` formats. */
|
|
6
|
+
export declare const getDateFormatter: MemoizedDateTimeFormatterFactoryOptional;
|
|
7
|
+
/** Memoized `Intl.DateTimeFormat` honouring named `time` formats. */
|
|
8
|
+
export declare const getTimeFormatter: MemoizedDateTimeFormatterFactoryOptional;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","names":[],"sources":["../../src/formatters.ts"],"mappings":";;;qBA0Ca,oBAAoB;;qBA4CpB,kBAAgB;;qBAGhB,kBAAgB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ConfigureOptionsInit, InterpolationValues, LocaleDictionary, MessageObject, MessagesLoader } from "./types.js";
|
|
2
|
+
import { Readable } from "svelte/store";
|
|
3
|
+
//#region src/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Configures fallback locale, formats and missing-message handling, then
|
|
6
|
+
* activates `initialLocale` (or keeps intlayer's current locale).
|
|
7
|
+
*/
|
|
8
|
+
export declare const init: (options: ConfigureOptionsInit) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges runtime messages into a locale. Messages may be raw ICU strings:
|
|
11
|
+
* this is the one entry point that bundles the ICU parser.
|
|
12
|
+
*/
|
|
13
|
+
export declare const addMessages: (targetLocale: string, ...partials: LocaleDictionary[]) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Registers a loader for runtime messages. Intlayer dictionaries need no
|
|
16
|
+
* registration — this only serves catalogs kept outside intlayer.
|
|
17
|
+
*/
|
|
18
|
+
export declare const register: (targetLocale: string, loader: MessagesLoader) => void;
|
|
19
|
+
/** Resolves once every `register()` loader has settled. */
|
|
20
|
+
export declare const waitLocale: (_locale?: string) => Promise<void>;
|
|
21
|
+
/** Identity helper typing a message map. */
|
|
22
|
+
export declare const defineMessages: <T extends Record<string, MessageObject>>(messages: T) => T;
|
|
23
|
+
type StoreValue<S> = S extends Readable<infer V> ? V : never;
|
|
24
|
+
/**
|
|
25
|
+
* Turns a function store (`$_`, `$date`…) into a plain function usable
|
|
26
|
+
* outside components. `freeze()` stops tracking locale changes.
|
|
27
|
+
*/
|
|
28
|
+
export declare const unwrapFunctionStore: <S extends Readable<(...args: never[]) => unknown>>(store: S) => StoreValue<S> & {
|
|
29
|
+
freeze: () => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Standalone ICU formatter for a raw message string — bundles the ICU
|
|
33
|
+
* parser, like `addMessages`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const getMessageFormatter: (message: string, targetLocale?: string) => {
|
|
36
|
+
format: (values?: InterpolationValues) => string;
|
|
37
|
+
};
|
|
38
|
+
/** Reads a locale from `window.location.hostname` with a capture group. */
|
|
39
|
+
export declare const getLocaleFromHostname: (hostname: RegExp) => string | null;
|
|
40
|
+
/** Reads a locale from `window.location.pathname` with a capture group. */
|
|
41
|
+
export declare const getLocaleFromPathname: (pathname: RegExp) => string | null;
|
|
42
|
+
/** The browser's preferred locale. */
|
|
43
|
+
export declare const getLocaleFromNavigator: () => string | null;
|
|
44
|
+
/** Reads the `key` query-string parameter of the current URL. */
|
|
45
|
+
export declare const getLocaleFromQueryString: (key: string) => string | null;
|
|
46
|
+
/** Reads the `key` parameter of the current URL hash (`#lang=fr`). */
|
|
47
|
+
export declare const getLocaleFromHash: (key: string) => string | null;
|
|
48
|
+
//#endregion
|
|
49
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigureOptions, ConfigureOptionsInit, DateFormatter, FormatXMLElementFn, Formats, InterpolationValues, IntlFormatterOptions, JSONGetter, LocaleDictionary, LocalesDictionary, MemoizedIntlFormatterOptional, MessageFormatter, MessageObject, MessagesLoader, MissingKeyHandler, MissingKeyHandlerInput, MissingKeyHandlerOutput, NumberFormatter, TimeFormatter } from "./types.js";
|
|
2
|
+
import { getDateFormatter, getNumberFormatter, getTimeFormatter } from "./formatters.js";
|
|
3
|
+
import { addMessages, defineMessages, getLocaleFromHash, getLocaleFromHostname, getLocaleFromNavigator, getLocaleFromPathname, getLocaleFromQueryString, getMessageFormatter, init, register, unwrapFunctionStore, waitLocale } from "./helpers.js";
|
|
4
|
+
import { LocaleStore, isLoading, locale, locales } from "./locale.js";
|
|
5
|
+
import { dictionary } from "./runtimeMessages.js";
|
|
6
|
+
import { _, date, format, json, number, t, time } from "./stores.js";
|
|
7
|
+
import { DictionaryMessageStores, useDictionary } from "./useDictionary.js";
|
|
8
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
9
|
+
export { type ConfigureOptions, type ConfigureOptionsInit, type DateFormatter, type DictionaryMessageStores, type FormatXMLElementFn, type Formats, type InterpolationValues, type IntlFormatterOptions, type JSONGetter, type LocaleDictionary, type LocaleStore, type LocalesDictionary, type MemoizedIntlFormatterOptional, type MessageFormatter, type MessageObject, type MessagesLoader, type MissingKeyHandler, type MissingKeyHandlerInput, type MissingKeyHandlerOutput, type NumberFormatter, type TimeFormatter, _, 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 };
|