@intlayer/lingui 9.0.0-canary.6 → 9.0.0-canary.7
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/dist/esm/I18nClass.mjs +73 -30
- package/dist/esm/I18nClass.mjs.map +1 -1
- package/dist/esm/linguiCatalog.mjs +87 -0
- package/dist/esm/linguiCatalog.mjs.map +1 -0
- package/dist/esm/plugin/index.mjs +6 -86
- package/dist/esm/plugin/index.mjs.map +1 -1
- package/dist/types/I18nClass.d.ts +43 -10
- package/dist/types/I18nClass.d.ts.map +1 -1
- package/dist/types/linguiCatalog.d.ts +40 -0
- package/dist/types/linguiCatalog.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +1 -25
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/esm/I18nClass.mjs
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
import { EventEmitter } from "./eventEmitter.mjs";
|
|
2
|
+
import { linguiMessageToIcu, navigateCatalog } from "./linguiCatalog.mjs";
|
|
2
3
|
import { getIntlayer } from "@intlayer/core/interpreter";
|
|
3
4
|
import { resolveMessage } from "@intlayer/core/messageFormat";
|
|
4
5
|
|
|
5
6
|
//#region src/I18nClass.ts
|
|
6
7
|
/**
|
|
7
|
-
* Navigates a nested object by a dot-separated path.
|
|
8
|
-
*
|
|
9
|
-
* Example: `navigatePath({home: {title: 'Hello'}}, 'home.title')` → `'Hello'`
|
|
10
|
-
*/
|
|
11
|
-
const navigatePath = (object, path) => {
|
|
12
|
-
if (!path) return object;
|
|
13
|
-
const parts = path.split(".");
|
|
14
|
-
let current = object;
|
|
15
|
-
for (const part of parts) {
|
|
16
|
-
if (current === null || current === void 0 || typeof current !== "object") return;
|
|
17
|
-
current = current[part];
|
|
18
|
-
}
|
|
19
|
-
return current;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
8
|
* Looks up a lingui message from the `messages` intlayer dictionary.
|
|
23
9
|
*
|
|
24
10
|
* The entire lingui catalog is stored in a single `messages` dictionary.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
11
|
+
* Both flat dotted ids (`'results-table.bundleSize'`, lingui's own format)
|
|
12
|
+
* and genuinely nested paths (`'home.title'`) are supported.
|
|
27
13
|
*/
|
|
28
|
-
const
|
|
14
|
+
const lookupDictionaryMessage = (id, locale) => {
|
|
29
15
|
try {
|
|
30
|
-
const value =
|
|
31
|
-
return
|
|
16
|
+
const value = navigateCatalog(getIntlayer("messages", locale), id);
|
|
17
|
+
return value === void 0 ? void 0 : linguiMessageToIcu(value);
|
|
32
18
|
} catch {
|
|
33
19
|
return;
|
|
34
20
|
}
|
|
@@ -45,10 +31,21 @@ const lookupMessage = (id, locale) => {
|
|
|
45
31
|
var I18nClass = class extends EventEmitter {
|
|
46
32
|
_locale;
|
|
47
33
|
_locales;
|
|
48
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Per-locale catalogs supplied at runtime via the constructor, `load()` or
|
|
36
|
+
* `loadAndActivate()`. Used as a fallback when a key is absent from the
|
|
37
|
+
* compiled intlayer `messages` dictionary, so an unmodified lingui codebase
|
|
38
|
+
* (which loads its compiled `.mjs`/`.json` catalogs) keeps working as a
|
|
39
|
+
* drop-in. For optimal bundle size, compile catalogs into intlayer
|
|
40
|
+
* dictionaries instead — see the dev warning emitted by `load()`.
|
|
41
|
+
*/
|
|
42
|
+
_catalogs = {};
|
|
43
|
+
_loadFallbackWarned = false;
|
|
44
|
+
constructor({ locale = "en", locales, messages } = {}) {
|
|
49
45
|
super();
|
|
50
46
|
this._locale = typeof locale === "string" ? locale : "en";
|
|
51
47
|
this._locales = locales;
|
|
48
|
+
if (messages) this.mergeAllCatalogs(messages);
|
|
52
49
|
}
|
|
53
50
|
get locale() {
|
|
54
51
|
return this._locale;
|
|
@@ -57,11 +54,30 @@ var I18nClass = class extends EventEmitter {
|
|
|
57
54
|
return this._locales;
|
|
58
55
|
}
|
|
59
56
|
get messages() {
|
|
57
|
+
let dictionary = {};
|
|
60
58
|
try {
|
|
61
|
-
|
|
59
|
+
dictionary = getIntlayer("messages", this._locale);
|
|
62
60
|
} catch {
|
|
63
|
-
|
|
61
|
+
dictionary = {};
|
|
64
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
...this._catalogs[this._locale] ?? {},
|
|
65
|
+
...dictionary
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Merges a single-locale catalog into the in-memory fallback store. */
|
|
69
|
+
mergeLocaleCatalog(locale, catalog) {
|
|
70
|
+
this._catalogs[locale] = {
|
|
71
|
+
...this._catalogs[locale],
|
|
72
|
+
...catalog
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Merges a `{ [locale]: catalog }` map (lingui's `AllMessages`) into the
|
|
77
|
+
* in-memory fallback store.
|
|
78
|
+
*/
|
|
79
|
+
mergeAllCatalogs(messages) {
|
|
80
|
+
for (const [locale, catalog] of Object.entries(messages)) if (catalog && typeof catalog === "object") this.mergeLocaleCatalog(locale, catalog);
|
|
65
81
|
}
|
|
66
82
|
/**
|
|
67
83
|
* No-op: intlayer handles message compilation at build time.
|
|
@@ -71,16 +87,27 @@ var I18nClass = class extends EventEmitter {
|
|
|
71
87
|
return this;
|
|
72
88
|
}
|
|
73
89
|
/**
|
|
74
|
-
*
|
|
90
|
+
* Loads message catalogs into the runtime fallback store, supporting both
|
|
91
|
+
* lingui signatures: `load(locale, messages)` and `load(allMessages)`.
|
|
92
|
+
*
|
|
93
|
+
* These messages are a compatibility fallback — keys present in the compiled
|
|
94
|
+
* intlayer `messages` dictionary take precedence, and only those keys can be
|
|
95
|
+
* pruned/optimized at build time.
|
|
75
96
|
*/
|
|
76
|
-
load(
|
|
77
|
-
|
|
97
|
+
load(localeOrAll, messages) {
|
|
98
|
+
if (typeof localeOrAll === "string") this.mergeLocaleCatalog(localeOrAll, messages ?? {});
|
|
99
|
+
else this.mergeAllCatalogs(localeOrAll);
|
|
100
|
+
if (!this._loadFallbackWarned) {
|
|
101
|
+
this._loadFallbackWarned = true;
|
|
102
|
+
console.warn("@intlayer/lingui: i18n.load() messages are used as a runtime fallback. For optimal bundle size, compile your catalogs into intlayer dictionaries instead of importing lingui locale files.");
|
|
103
|
+
}
|
|
78
104
|
}
|
|
79
105
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
106
|
+
* Loads the given catalog (fallback store) and activates the locale
|
|
107
|
+
* (emits `'change'`).
|
|
82
108
|
*/
|
|
83
|
-
loadAndActivate({ locale, locales }) {
|
|
109
|
+
loadAndActivate({ locale, locales, messages }) {
|
|
110
|
+
if (messages) this.mergeLocaleCatalog(locale, messages);
|
|
84
111
|
this.activate(locale, locales);
|
|
85
112
|
}
|
|
86
113
|
/**
|
|
@@ -91,6 +118,22 @@ var I18nClass = class extends EventEmitter {
|
|
|
91
118
|
this._locales = locales;
|
|
92
119
|
this.emit("change");
|
|
93
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Resolves the raw message template for an id (before interpolation).
|
|
123
|
+
*
|
|
124
|
+
* Resolution order:
|
|
125
|
+
* 1. compiled intlayer `messages` dictionary
|
|
126
|
+
* 2. runtime fallback catalog (constructor / `load()` / `loadAndActivate()`)
|
|
127
|
+
*/
|
|
128
|
+
resolveTemplate(id) {
|
|
129
|
+
const fromDictionary = lookupDictionaryMessage(id, this._locale);
|
|
130
|
+
if (fromDictionary !== void 0) return fromDictionary;
|
|
131
|
+
const catalog = this._catalogs[this._locale];
|
|
132
|
+
if (catalog) {
|
|
133
|
+
const raw = navigateCatalog(catalog, id);
|
|
134
|
+
if (raw !== void 0) return linguiMessageToIcu(raw);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
94
137
|
_(descriptorOrId, values, options) {
|
|
95
138
|
const isDescriptor = typeof descriptorOrId === "object" && descriptorOrId !== null;
|
|
96
139
|
const id = isDescriptor ? descriptorOrId.id : descriptorOrId;
|
|
@@ -99,7 +142,7 @@ var I18nClass = class extends EventEmitter {
|
|
|
99
142
|
...descriptorOrId.values ?? {},
|
|
100
143
|
...values ?? {}
|
|
101
144
|
} : values ?? {};
|
|
102
|
-
return resolveMessage(
|
|
145
|
+
return resolveMessage(this.resolveTemplate(id) ?? defaultMessage ?? id, resolvedValues, this._locale, "icu") ?? id;
|
|
103
146
|
}
|
|
104
147
|
/**
|
|
105
148
|
* Alias for `_`. Provided for lingui API compatibility.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nClass.mjs","names":[],"sources":["../../src/I18nClass.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport { resolveMessage } from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n AllMessages,\n Locale,\n Locales,\n MessageDescriptor,\n MessageId,\n MessageOptions,\n Messages,\n} from '@lingui/core';\nimport { EventEmitter } from './eventEmitter';\n\n/** Mirrors the unexported `Values` type from `@lingui/core`. */\ntype Values = Record<string, unknown>;\n\n/** Mirrors the unexported `MessageCompiler` type from `@lingui/core`. */\ntype MessageCompiler = (message: string) => unknown;\n\n/** Mirrors the unexported `Events` type from `@lingui/core`. */\ntype LinguiEvents = {\n change: () => void;\n missing: (event: { locale: Locale; id: MessageId }) => void;\n};\n\n/** Mirrors the unexported `I18nProps` type from `@lingui/core`. */\ntype I18nProps = {\n locale?: Locale;\n locales?: Locales;\n messages?: AllMessages;\n missing?: string | ((locale: string, id: string) => string);\n};\n\n/**\n * Navigates a nested object by a dot-separated path.\n *\n * Example: `navigatePath({home: {title: 'Hello'}}, 'home.title')` → `'Hello'`\n */\nconst navigatePath = (object: unknown, path: string): unknown => {\n if (!path) return object;\n const parts = path.split('.');\n let current: unknown = object;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Looks up a lingui message from the `messages` intlayer dictionary.\n *\n * The entire lingui catalog is stored in a single `messages` dictionary.\n * Dotted IDs (e.g. `'home.title'`) are resolved as nested paths within that\n * dictionary. Hash-style IDs (no dots) are direct top-level keys.\n */\nconst lookupMessage = (\n id: string,\n locale: LocalesValues\n): string | undefined => {\n try {\n const dictionary = getIntlayer('messages' as DictionaryKeys, locale);\n const value = navigatePath(dictionary, id);\n return typeof value === 'string' ? value : undefined;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Intlayer-backed implementation of `@lingui/core`'s `I18n` class.\n *\n * - Messages are read from the `messages` intlayer dictionary.\n * - ICU MessageFormat syntax is resolved via `@intlayer/core/messageFormat`.\n * - `load()` / `loadAndActivate()` / `setMessagesCompiler()` are no-ops —\n * messages are served by intlayer's compiled dictionaries.\n * - `activate(locale)` emits `'change'` so that React consumers re-render.\n */\nexport class I18nClass extends EventEmitter<LinguiEvents> {\n private _locale: string;\n private _locales?: Locales;\n\n constructor({ locale = 'en', locales }: I18nProps = {}) {\n super();\n this._locale = typeof locale === 'string' ? locale : 'en';\n this._locales = locales;\n }\n\n get locale(): string {\n return this._locale;\n }\n\n get locales(): Locales | undefined {\n return this._locales;\n }\n\n get messages(): Messages {\n try {\n return getIntlayer(\n 'messages' as DictionaryKeys,\n this._locale as LocalesValues\n ) as Messages;\n } catch {\n return {};\n }\n }\n\n /**\n * No-op: intlayer handles message compilation at build time.\n */\n setMessagesCompiler(_compiler: MessageCompiler): this {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '@intlayer/lingui: i18n.setMessagesCompiler() is a no-op — ' +\n 'message compilation is handled at build time by intlayer.'\n );\n }\n return this;\n }\n\n /**\n * No-op: messages are loaded automatically via intlayer dictionaries.\n */\n load(_localeOrAll: Locale | AllMessages, _messages?: Messages): void {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '@intlayer/lingui: i18n.load() is a no-op — ' +\n 'messages are loaded automatically via intlayer dictionaries.'\n );\n }\n }\n\n /**\n * Activates the given locale (emits `'change'`).\n * The `messages` argument is ignored — intlayer handles the catalog.\n */\n loadAndActivate({\n locale,\n locales,\n }: {\n locale: Locale;\n locales?: Locales;\n messages: Messages;\n }): void {\n this.activate(locale, locales);\n }\n\n /**\n * Sets the active locale and emits `'change'` to notify React consumers.\n */\n activate(locale: Locale, locales?: Locales): void {\n this._locale = locale;\n this._locales = locales;\n this.emit('change');\n }\n\n /**\n * Translates a message descriptor or a plain ID.\n *\n * Resolution order:\n * 1. `messages` intlayer dictionary (dotted path navigation)\n * 2. `descriptor.message` or `options.message` (original source string)\n * 3. The raw `id` as fallback\n */\n _(descriptor: MessageDescriptor): string;\n _(id: MessageId, values?: Values, options?: MessageOptions): string;\n _(\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string {\n const isDescriptor =\n typeof descriptorOrId === 'object' && descriptorOrId !== null;\n const id = isDescriptor\n ? (descriptorOrId as MessageDescriptor).id\n : (descriptorOrId as MessageId);\n const defaultMessage = isDescriptor\n ? ((descriptorOrId as MessageDescriptor).message ?? options?.message)\n : options?.message;\n const resolvedValues: Values = isDescriptor\n ? {\n ...((descriptorOrId as MessageDescriptor).values ?? {}),\n ...(values ?? {}),\n }\n : (values ?? {});\n\n const rawValue = lookupMessage(id, this._locale as LocalesValues);\n const template = rawValue ?? defaultMessage ?? id;\n\n return (\n resolveMessage(\n template,\n resolvedValues as Record<string, string | number>,\n this._locale as LocalesValues,\n 'icu'\n ) ?? id\n );\n }\n\n /**\n * Alias for `_`. Provided for lingui API compatibility.\n */\n t = (\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string => this._(descriptorOrId as MessageId, values, options);\n\n /**\n * @deprecated Use `Intl.DateTimeFormat` directly.\n */\n date(\n value?: string | Date | number,\n format?: Intl.DateTimeFormatOptions\n ): string {\n if (value === undefined || value === null) return '';\n const dateValue =\n value instanceof Date\n ? value\n : new Date(typeof value === 'string' ? value : value);\n return new Intl.DateTimeFormat(this._locale, format).format(dateValue);\n }\n\n /**\n * @deprecated Use `Intl.NumberFormat` directly.\n */\n number(value: number | bigint, format?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(this._locale, format).format(value);\n }\n}\n"],"mappings":";;;;;;;;;;AA0CA,MAAM,gBAAgB,QAAiB,SAA0B;CAC/D,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,IAAI,UAAmB;CACvB,KAAK,MAAM,QAAQ,OAAO;EACxB,IACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,UAEnB;EAEF,UAAW,QAAoC;CACjD;CACA,OAAO;AACT;;;;;;;;AASA,MAAM,iBACJ,IACA,WACuB;CACvB,IAAI;EAEF,MAAM,QAAQ,aADK,YAAY,YAA8B,MACzB,GAAG,EAAE;EACzC,OAAO,OAAO,UAAU,WAAW,QAAQ;CAC7C,QAAQ;EACN;CACF;AACF;;;;;;;;;;AAWA,IAAa,YAAb,cAA+B,aAA2B;CACxD,AAAQ;CACR,AAAQ;CAER,YAAY,EAAE,SAAS,MAAM,YAAuB,CAAC,GAAG;EACtD,MAAM;EACN,KAAK,UAAU,OAAO,WAAW,WAAW,SAAS;EACrD,KAAK,WAAW;CAClB;CAEA,IAAI,SAAiB;EACnB,OAAO,KAAK;CACd;CAEA,IAAI,UAA+B;EACjC,OAAO,KAAK;CACd;CAEA,IAAI,WAAqB;EACvB,IAAI;GACF,OAAO,YACL,YACA,KAAK,OACP;EACF,QAAQ;GACN,OAAO,CAAC;EACV;CACF;;;;CAKA,oBAAoB,WAAkC;EAElD,QAAQ,KACN,qHAEF;EAEF,OAAO;CACT;;;;CAKA,KAAK,cAAoC,WAA4B;EAEjE,QAAQ,KACN,yGAEF;CAEJ;;;;;CAMA,gBAAgB,EACd,QACA,WAKO;EACP,KAAK,SAAS,QAAQ,OAAO;CAC/B;;;;CAKA,SAAS,QAAgB,SAAyB;EAChD,KAAK,UAAU;EACf,KAAK,WAAW;EAChB,KAAK,KAAK,QAAQ;CACpB;CAYA,EACE,gBACA,QACA,SACQ;EACR,MAAM,eACJ,OAAO,mBAAmB,YAAY,mBAAmB;EAC3D,MAAM,KAAK,eACN,eAAqC,KACrC;EACL,MAAM,iBAAiB,eACjB,eAAqC,WAAW,SAAS,UAC3D,SAAS;EACb,MAAM,iBAAyB,eAC3B;GACE,GAAK,eAAqC,UAAU,CAAC;GACrD,GAAI,UAAU,CAAC;EACjB,IACC,UAAU,CAAC;EAKhB,OACE,eAJe,cAAc,IAAI,KAAK,OAChB,KAAK,kBAAkB,IAK3C,gBACA,KAAK,SACL,KACF,KAAK;CAET;;;;CAKA,KACE,gBACA,QACA,YACW,KAAK,EAAE,gBAA6B,QAAQ,OAAO;;;;CAKhE,KACE,OACA,QACQ;EACR,IAAI,UAAU,UAAa,UAAU,MAAM,OAAO;EAClD,MAAM,YACJ,iBAAiB,OACb,QACA,IAAI,KAAK,OAAO,UAAU,WAAW,QAAQ,KAAK;EACxD,OAAO,IAAI,KAAK,eAAe,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,SAAS;CACvE;;;;CAKA,OAAO,OAAwB,QAA2C;EACxE,OAAO,IAAI,KAAK,aAAa,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,KAAK;CACjE;AACF"}
|
|
1
|
+
{"version":3,"file":"I18nClass.mjs","names":[],"sources":["../../src/I18nClass.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport { resolveMessage } from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n AllMessages,\n Locale,\n Locales,\n MessageDescriptor,\n MessageId,\n MessageOptions,\n Messages,\n} from '@lingui/core';\nimport { EventEmitter } from './eventEmitter';\nimport { linguiMessageToIcu, navigateCatalog } from './linguiCatalog';\n\n/** Mirrors the unexported `Values` type from `@lingui/core`. */\ntype Values = Record<string, unknown>;\n\n/** Mirrors the unexported `MessageCompiler` type from `@lingui/core`. */\ntype MessageCompiler = (message: string) => unknown;\n\n/** Mirrors the unexported `Events` type from `@lingui/core`. */\ntype LinguiEvents = {\n change: () => void;\n missing: (event: { locale: Locale; id: MessageId }) => void;\n};\n\n/** Mirrors the unexported `I18nProps` type from `@lingui/core`. */\ntype I18nProps = {\n locale?: Locale;\n locales?: Locales;\n messages?: AllMessages;\n missing?: string | ((locale: string, id: string) => string);\n};\n\n/**\n * Looks up a lingui message from the `messages` intlayer dictionary.\n *\n * The entire lingui catalog is stored in a single `messages` dictionary.\n * Both flat dotted ids (`'results-table.bundleSize'`, lingui's own format)\n * and genuinely nested paths (`'home.title'`) are supported.\n */\nconst lookupDictionaryMessage = (\n id: string,\n locale: LocalesValues\n): string | undefined => {\n try {\n const dictionary = getIntlayer('messages' as DictionaryKeys, locale);\n const value = navigateCatalog(dictionary, id);\n return value === undefined ? undefined : linguiMessageToIcu(value);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Intlayer-backed implementation of `@lingui/core`'s `I18n` class.\n *\n * - Messages are read from the `messages` intlayer dictionary.\n * - ICU MessageFormat syntax is resolved via `@intlayer/core/messageFormat`.\n * - `load()` / `loadAndActivate()` / `setMessagesCompiler()` are no-ops —\n * messages are served by intlayer's compiled dictionaries.\n * - `activate(locale)` emits `'change'` so that React consumers re-render.\n */\nexport class I18nClass extends EventEmitter<LinguiEvents> {\n private _locale: string;\n private _locales?: Locales;\n /**\n * Per-locale catalogs supplied at runtime via the constructor, `load()` or\n * `loadAndActivate()`. Used as a fallback when a key is absent from the\n * compiled intlayer `messages` dictionary, so an unmodified lingui codebase\n * (which loads its compiled `.mjs`/`.json` catalogs) keeps working as a\n * drop-in. For optimal bundle size, compile catalogs into intlayer\n * dictionaries instead — see the dev warning emitted by `load()`.\n */\n private _catalogs: Record<string, Messages> = {};\n private _loadFallbackWarned = false;\n\n constructor({ locale = 'en', locales, messages }: I18nProps = {}) {\n super();\n this._locale = typeof locale === 'string' ? locale : 'en';\n this._locales = locales;\n if (messages) this.mergeAllCatalogs(messages);\n }\n\n get locale(): string {\n return this._locale;\n }\n\n get locales(): Locales | undefined {\n return this._locales;\n }\n\n get messages(): Messages {\n let dictionary: Messages = {};\n try {\n dictionary = getIntlayer(\n 'messages' as DictionaryKeys,\n this._locale as LocalesValues\n ) as Messages;\n } catch {\n dictionary = {};\n }\n // The compiled dictionary wins over the runtime fallback catalog.\n return { ...(this._catalogs[this._locale] ?? {}), ...dictionary };\n }\n\n /** Merges a single-locale catalog into the in-memory fallback store. */\n private mergeLocaleCatalog(locale: string, catalog: Messages) {\n this._catalogs[locale] = { ...this._catalogs[locale], ...catalog };\n }\n\n /**\n * Merges a `{ [locale]: catalog }` map (lingui's `AllMessages`) into the\n * in-memory fallback store.\n */\n private mergeAllCatalogs(messages: AllMessages) {\n for (const [locale, catalog] of Object.entries(messages)) {\n if (catalog && typeof catalog === 'object') {\n this.mergeLocaleCatalog(locale, catalog as Messages);\n }\n }\n }\n\n /**\n * No-op: intlayer handles message compilation at build time.\n */\n setMessagesCompiler(_compiler: MessageCompiler): this {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '@intlayer/lingui: i18n.setMessagesCompiler() is a no-op — ' +\n 'message compilation is handled at build time by intlayer.'\n );\n }\n return this;\n }\n\n /**\n * Loads message catalogs into the runtime fallback store, supporting both\n * lingui signatures: `load(locale, messages)` and `load(allMessages)`.\n *\n * These messages are a compatibility fallback — keys present in the compiled\n * intlayer `messages` dictionary take precedence, and only those keys can be\n * pruned/optimized at build time.\n */\n load(localeOrAll: Locale | AllMessages, messages?: Messages): void {\n if (typeof localeOrAll === 'string') {\n this.mergeLocaleCatalog(localeOrAll, messages ?? {});\n } else {\n this.mergeAllCatalogs(localeOrAll);\n }\n\n if (process.env.NODE_ENV === 'development' && !this._loadFallbackWarned) {\n this._loadFallbackWarned = true;\n console.warn(\n '@intlayer/lingui: i18n.load() messages are used as a runtime ' +\n 'fallback. For optimal bundle size, compile your catalogs into ' +\n 'intlayer dictionaries instead of importing lingui locale files.'\n );\n }\n }\n\n /**\n * Loads the given catalog (fallback store) and activates the locale\n * (emits `'change'`).\n */\n loadAndActivate({\n locale,\n locales,\n messages,\n }: {\n locale: Locale;\n locales?: Locales;\n messages?: Messages;\n }): void {\n if (messages) this.mergeLocaleCatalog(locale, messages);\n this.activate(locale, locales);\n }\n\n /**\n * Sets the active locale and emits `'change'` to notify React consumers.\n */\n activate(locale: Locale, locales?: Locales): void {\n this._locale = locale;\n this._locales = locales;\n this.emit('change');\n }\n\n /**\n * Resolves the raw message template for an id (before interpolation).\n *\n * Resolution order:\n * 1. compiled intlayer `messages` dictionary\n * 2. runtime fallback catalog (constructor / `load()` / `loadAndActivate()`)\n */\n private resolveTemplate(id: string): string | undefined {\n const fromDictionary = lookupDictionaryMessage(\n id,\n this._locale as LocalesValues\n );\n if (fromDictionary !== undefined) return fromDictionary;\n\n const catalog = this._catalogs[this._locale];\n if (catalog) {\n const raw = navigateCatalog(catalog, id);\n if (raw !== undefined) return linguiMessageToIcu(raw);\n }\n\n return undefined;\n }\n\n /**\n * Translates a message descriptor or a plain ID.\n *\n * Resolution order:\n * 1. `messages` intlayer dictionary (flat dotted key or nested path)\n * 2. runtime fallback catalog loaded via `load()` / `loadAndActivate()`\n * 3. `descriptor.message` or `options.message` (original source string)\n * 4. The raw `id` as fallback\n */\n _(descriptor: MessageDescriptor): string;\n _(id: MessageId, values?: Values, options?: MessageOptions): string;\n _(\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string {\n const isDescriptor =\n typeof descriptorOrId === 'object' && descriptorOrId !== null;\n const id = isDescriptor\n ? (descriptorOrId as MessageDescriptor).id\n : (descriptorOrId as MessageId);\n const defaultMessage = isDescriptor\n ? ((descriptorOrId as MessageDescriptor).message ?? options?.message)\n : options?.message;\n const resolvedValues: Values = isDescriptor\n ? {\n ...((descriptorOrId as MessageDescriptor).values ?? {}),\n ...(values ?? {}),\n }\n : (values ?? {});\n\n const rawValue = this.resolveTemplate(id);\n const template = rawValue ?? defaultMessage ?? id;\n\n return (\n resolveMessage(\n template,\n resolvedValues as Record<string, string | number>,\n this._locale as LocalesValues,\n 'icu'\n ) ?? id\n );\n }\n\n /**\n * Alias for `_`. Provided for lingui API compatibility.\n */\n t = (\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string => this._(descriptorOrId as MessageId, values, options);\n\n /**\n * @deprecated Use `Intl.DateTimeFormat` directly.\n */\n date(\n value?: string | Date | number,\n format?: Intl.DateTimeFormatOptions\n ): string {\n if (value === undefined || value === null) return '';\n const dateValue =\n value instanceof Date\n ? value\n : new Date(typeof value === 'string' ? value : value);\n return new Intl.DateTimeFormat(this._locale, format).format(dateValue);\n }\n\n /**\n * @deprecated Use `Intl.NumberFormat` directly.\n */\n number(value: number | bigint, format?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(this._locale, format).format(value);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6CA,MAAM,2BACJ,IACA,WACuB;CACvB,IAAI;EAEF,MAAM,QAAQ,gBADK,YAAY,YAA8B,MACtB,GAAG,EAAE;EAC5C,OAAO,UAAU,SAAY,SAAY,mBAAmB,KAAK;CACnE,QAAQ;EACN;CACF;AACF;;;;;;;;;;AAWA,IAAa,YAAb,cAA+B,aAA2B;CACxD,AAAQ;CACR,AAAQ;;;;;;;;;CASR,AAAQ,YAAsC,CAAC;CAC/C,AAAQ,sBAAsB;CAE9B,YAAY,EAAE,SAAS,MAAM,SAAS,aAAwB,CAAC,GAAG;EAChE,MAAM;EACN,KAAK,UAAU,OAAO,WAAW,WAAW,SAAS;EACrD,KAAK,WAAW;EAChB,IAAI,UAAU,KAAK,iBAAiB,QAAQ;CAC9C;CAEA,IAAI,SAAiB;EACnB,OAAO,KAAK;CACd;CAEA,IAAI,UAA+B;EACjC,OAAO,KAAK;CACd;CAEA,IAAI,WAAqB;EACvB,IAAI,aAAuB,CAAC;EAC5B,IAAI;GACF,aAAa,YACX,YACA,KAAK,OACP;EACF,QAAQ;GACN,aAAa,CAAC;EAChB;EAEA,OAAO;GAAE,GAAI,KAAK,UAAU,KAAK,YAAY,CAAC;GAAI,GAAG;EAAW;CAClE;;CAGA,AAAQ,mBAAmB,QAAgB,SAAmB;EAC5D,KAAK,UAAU,UAAU;GAAE,GAAG,KAAK,UAAU;GAAS,GAAG;EAAQ;CACnE;;;;;CAMA,AAAQ,iBAAiB,UAAuB;EAC9C,KAAK,MAAM,CAAC,QAAQ,YAAY,OAAO,QAAQ,QAAQ,GACrD,IAAI,WAAW,OAAO,YAAY,UAChC,KAAK,mBAAmB,QAAQ,OAAmB;CAGzD;;;;CAKA,oBAAoB,WAAkC;EAElD,QAAQ,KACN,qHAEF;EAEF,OAAO;CACT;;;;;;;;;CAUA,KAAK,aAAmC,UAA2B;EACjE,IAAI,OAAO,gBAAgB,UACzB,KAAK,mBAAmB,aAAa,YAAY,CAAC,CAAC;OAEnD,KAAK,iBAAiB,WAAW;EAGnC,IAA8C,CAAC,KAAK,qBAAqB;GACvE,KAAK,sBAAsB;GAC3B,QAAQ,KACN,4LAGF;EACF;CACF;;;;;CAMA,gBAAgB,EACd,QACA,SACA,YAKO;EACP,IAAI,UAAU,KAAK,mBAAmB,QAAQ,QAAQ;EACtD,KAAK,SAAS,QAAQ,OAAO;CAC/B;;;;CAKA,SAAS,QAAgB,SAAyB;EAChD,KAAK,UAAU;EACf,KAAK,WAAW;EAChB,KAAK,KAAK,QAAQ;CACpB;;;;;;;;CASA,AAAQ,gBAAgB,IAAgC;EACtD,MAAM,iBAAiB,wBACrB,IACA,KAAK,OACP;EACA,IAAI,mBAAmB,QAAW,OAAO;EAEzC,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,IAAI,SAAS;GACX,MAAM,MAAM,gBAAgB,SAAS,EAAE;GACvC,IAAI,QAAQ,QAAW,OAAO,mBAAmB,GAAG;EACtD;CAGF;CAaA,EACE,gBACA,QACA,SACQ;EACR,MAAM,eACJ,OAAO,mBAAmB,YAAY,mBAAmB;EAC3D,MAAM,KAAK,eACN,eAAqC,KACrC;EACL,MAAM,iBAAiB,eACjB,eAAqC,WAAW,SAAS,UAC3D,SAAS;EACb,MAAM,iBAAyB,eAC3B;GACE,GAAK,eAAqC,UAAU,CAAC;GACrD,GAAI,UAAU,CAAC;EACjB,IACC,UAAU,CAAC;EAKhB,OACE,eAJe,KAAK,gBAAgB,EACd,KAAK,kBAAkB,IAK3C,gBACA,KAAK,SACL,KACF,KAAK;CAET;;;;CAKA,KACE,gBACA,QACA,YACW,KAAK,EAAE,gBAA6B,QAAQ,OAAO;;;;CAKhE,KACE,OACA,QACQ;EACR,IAAI,UAAU,UAAa,UAAU,MAAM,OAAO;EAClD,MAAM,YACJ,iBAAiB,OACb,QACA,IAAI,KAAK,OAAO,UAAU,WAAW,QAAQ,KAAK;EACxD,OAAO,IAAI,KAAK,eAAe,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,SAAS;CACvE;;;;CAKA,OAAO,OAAwB,QAA2C;EACxE,OAAO,IAAI,KAAK,aAAa,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,KAAK;CACjE;AACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/linguiCatalog.ts
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for reading lingui message catalogs.
|
|
4
|
+
*
|
|
5
|
+
* lingui catalogs are flat maps whose keys are dotted strings
|
|
6
|
+
* (`'results-table.bundleSize'`) rather than nested objects, and whose
|
|
7
|
+
* compiled (`.mjs`) values are token arrays rather than plain strings. These
|
|
8
|
+
* helpers bridge that format onto intlayer's ICU-based `resolveMessage`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Reads a value from a catalog by id.
|
|
12
|
+
*
|
|
13
|
+
* lingui ids are flat keys that themselves contain dots
|
|
14
|
+
* (`'results-table.bundleSize'`), so the flat key is tried first. When that
|
|
15
|
+
* misses, the id is treated as a nested path (`'home.title'` →
|
|
16
|
+
* `catalog.home.title`) to also support genuinely nested intlayer
|
|
17
|
+
* dictionaries.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* navigateCatalog({ 'a.b': 'X' }, 'a.b'); // 'X' (flat key)
|
|
21
|
+
* navigateCatalog({ a: { b: 'X' } }, 'a.b'); // 'X' (nested path)
|
|
22
|
+
*/
|
|
23
|
+
const navigateCatalog = (catalog, id) => {
|
|
24
|
+
if (!id) return catalog;
|
|
25
|
+
if (catalog === null || typeof catalog !== "object") return void 0;
|
|
26
|
+
const flatValue = catalog[id];
|
|
27
|
+
if (flatValue !== void 0) return flatValue;
|
|
28
|
+
if (!id.includes(".")) return void 0;
|
|
29
|
+
let current = catalog;
|
|
30
|
+
for (const part of id.split(".")) {
|
|
31
|
+
if (current === null || current === void 0 || typeof current !== "object") return;
|
|
32
|
+
current = current[part];
|
|
33
|
+
}
|
|
34
|
+
return current;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Converts a single compiled lingui token to its ICU MessageFormat equivalent.
|
|
38
|
+
*
|
|
39
|
+
* Token shapes (from `@lingui/message-utils`):
|
|
40
|
+
* - `string` → literal text
|
|
41
|
+
* - `[name]` → `{name}`
|
|
42
|
+
* - `[name, 'number' | 'date' | 'time', format?]` → `{name, number, format}`
|
|
43
|
+
* - `[name, 'plural' | 'select' | 'selectordinal', options]` → ICU block,
|
|
44
|
+
* where each option value is itself a compiled sub-message.
|
|
45
|
+
*/
|
|
46
|
+
const tokenToIcu = (token) => {
|
|
47
|
+
if (typeof token === "string") return token;
|
|
48
|
+
if (!Array.isArray(token)) return "";
|
|
49
|
+
const [name, type, format] = token;
|
|
50
|
+
if (type === void 0) return `{${String(name)}}`;
|
|
51
|
+
if (type === "plural" || type === "select" || type === "selectordinal") {
|
|
52
|
+
const options = format ?? {};
|
|
53
|
+
const segments = [];
|
|
54
|
+
let offsetSegment = "";
|
|
55
|
+
for (const [category, value] of Object.entries(options)) {
|
|
56
|
+
if (category === "offset") {
|
|
57
|
+
offsetSegment = `offset:${String(value)} `;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
segments.push(`${category} {${linguiMessageToIcu(value)}}`);
|
|
61
|
+
}
|
|
62
|
+
return `{${String(name)}, ${type}, ${offsetSegment}${segments.join(" ")}}`;
|
|
63
|
+
}
|
|
64
|
+
return format !== void 0 ? `{${String(name)}, ${type}, ${String(format)}}` : `{${String(name)}, ${type}}`;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Converts a compiled lingui message into an ICU MessageFormat string that
|
|
68
|
+
* `@intlayer/core`'s `resolveMessage(…, 'icu')` can interpolate.
|
|
69
|
+
*
|
|
70
|
+
* Plain strings (uncompiled `.json` catalogs) pass through unchanged; token
|
|
71
|
+
* arrays (compiled `.mjs` catalogs) are flattened, including nested
|
|
72
|
+
* plural/select blocks and `{name}` placeholders.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* linguiMessageToIcu(['Bundle Size']); // 'Bundle Size'
|
|
76
|
+
* linguiMessageToIcu(['Hello ', ['name']]); // 'Hello {name}'
|
|
77
|
+
* linguiMessageToIcu('Already ICU {count}'); // 'Already ICU {count}'
|
|
78
|
+
*/
|
|
79
|
+
const linguiMessageToIcu = (compiled) => {
|
|
80
|
+
if (typeof compiled === "string") return compiled;
|
|
81
|
+
if (!Array.isArray(compiled)) return String(compiled ?? "");
|
|
82
|
+
return compiled.map(tokenToIcu).join("");
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { linguiMessageToIcu, navigateCatalog };
|
|
87
|
+
//# sourceMappingURL=linguiCatalog.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linguiCatalog.mjs","names":[],"sources":["../../src/linguiCatalog.ts"],"sourcesContent":["/**\n * Helpers for reading lingui message catalogs.\n *\n * lingui catalogs are flat maps whose keys are dotted strings\n * (`'results-table.bundleSize'`) rather than nested objects, and whose\n * compiled (`.mjs`) values are token arrays rather than plain strings. These\n * helpers bridge that format onto intlayer's ICU-based `resolveMessage`.\n */\n\n/**\n * Reads a value from a catalog by id.\n *\n * lingui ids are flat keys that themselves contain dots\n * (`'results-table.bundleSize'`), so the flat key is tried first. When that\n * misses, the id is treated as a nested path (`'home.title'` →\n * `catalog.home.title`) to also support genuinely nested intlayer\n * dictionaries.\n *\n * @example\n * navigateCatalog({ 'a.b': 'X' }, 'a.b'); // 'X' (flat key)\n * navigateCatalog({ a: { b: 'X' } }, 'a.b'); // 'X' (nested path)\n */\nexport const navigateCatalog = (catalog: unknown, id: string): unknown => {\n if (!id) return catalog;\n if (catalog === null || typeof catalog !== 'object') return undefined;\n\n const flatValue = (catalog as Record<string, unknown>)[id];\n if (flatValue !== undefined) return flatValue;\n\n if (!id.includes('.')) return undefined;\n\n let current: unknown = catalog;\n for (const part of id.split('.')) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Converts a single compiled lingui token to its ICU MessageFormat equivalent.\n *\n * Token shapes (from `@lingui/message-utils`):\n * - `string` → literal text\n * - `[name]` → `{name}`\n * - `[name, 'number' | 'date' | 'time', format?]` → `{name, number, format}`\n * - `[name, 'plural' | 'select' | 'selectordinal', options]` → ICU block,\n * where each option value is itself a compiled sub-message.\n */\nconst tokenToIcu = (token: unknown): string => {\n if (typeof token === 'string') return token;\n if (!Array.isArray(token)) return '';\n\n const [name, type, format] = token as [string, string?, unknown?];\n\n if (type === undefined) return `{${String(name)}}`;\n\n if (type === 'plural' || type === 'select' || type === 'selectordinal') {\n const options = (format ?? {}) as Record<string, unknown>;\n const segments: string[] = [];\n let offsetSegment = '';\n\n for (const [category, value] of Object.entries(options)) {\n if (category === 'offset') {\n offsetSegment = `offset:${String(value)} `;\n continue;\n }\n segments.push(`${category} {${linguiMessageToIcu(value)}}`);\n }\n\n return `{${String(name)}, ${type}, ${offsetSegment}${segments.join(' ')}}`;\n }\n\n return format !== undefined\n ? `{${String(name)}, ${type}, ${String(format)}}`\n : `{${String(name)}, ${type}}`;\n};\n\n/**\n * Converts a compiled lingui message into an ICU MessageFormat string that\n * `@intlayer/core`'s `resolveMessage(…, 'icu')` can interpolate.\n *\n * Plain strings (uncompiled `.json` catalogs) pass through unchanged; token\n * arrays (compiled `.mjs` catalogs) are flattened, including nested\n * plural/select blocks and `{name}` placeholders.\n *\n * @example\n * linguiMessageToIcu(['Bundle Size']); // 'Bundle Size'\n * linguiMessageToIcu(['Hello ', ['name']]); // 'Hello {name}'\n * linguiMessageToIcu('Already ICU {count}'); // 'Already ICU {count}'\n */\nexport const linguiMessageToIcu = (compiled: unknown): string => {\n if (typeof compiled === 'string') return compiled;\n if (!Array.isArray(compiled)) return String(compiled ?? '');\n return compiled.map(tokenToIcu).join('');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB,SAAkB,OAAwB;CACxE,IAAI,CAAC,IAAI,OAAO;CAChB,IAAI,YAAY,QAAQ,OAAO,YAAY,UAAU,OAAO;CAE5D,MAAM,YAAa,QAAoC;CACvD,IAAI,cAAc,QAAW,OAAO;CAEpC,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG,OAAO;CAE9B,IAAI,UAAmB;CACvB,KAAK,MAAM,QAAQ,GAAG,MAAM,GAAG,GAAG;EAChC,IACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,UAEnB;EAEF,UAAW,QAAoC;CACjD;CACA,OAAO;AACT;;;;;;;;;;;AAYA,MAAM,cAAc,UAA2B;CAC7C,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO;CAElC,MAAM,CAAC,MAAM,MAAM,UAAU;CAE7B,IAAI,SAAS,QAAW,OAAO,IAAI,OAAO,IAAI,EAAE;CAEhD,IAAI,SAAS,YAAY,SAAS,YAAY,SAAS,iBAAiB;EACtE,MAAM,UAAW,UAAU,CAAC;EAC5B,MAAM,WAAqB,CAAC;EAC5B,IAAI,gBAAgB;EAEpB,KAAK,MAAM,CAAC,UAAU,UAAU,OAAO,QAAQ,OAAO,GAAG;GACvD,IAAI,aAAa,UAAU;IACzB,gBAAgB,UAAU,OAAO,KAAK,EAAE;IACxC;GACF;GACA,SAAS,KAAK,GAAG,SAAS,IAAI,mBAAmB,KAAK,EAAE,EAAE;EAC5D;EAEA,OAAO,IAAI,OAAO,IAAI,EAAE,IAAI,KAAK,IAAI,gBAAgB,SAAS,KAAK,GAAG,EAAE;CAC1E;CAEA,OAAO,WAAW,SACd,IAAI,OAAO,IAAI,EAAE,IAAI,KAAK,IAAI,OAAO,MAAM,EAAE,KAC7C,IAAI,OAAO,IAAI,EAAE,IAAI,KAAK;AAChC;;;;;;;;;;;;;;AAeA,MAAa,sBAAsB,aAA8B;CAC/D,IAAI,OAAO,aAAa,UAAU,OAAO;CACzC,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG,OAAO,OAAO,YAAY,EAAE;CAC1D,OAAO,SAAS,IAAI,UAAU,CAAC,CAAC,KAAK,EAAE;AACzC"}
|
|
@@ -1,86 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
//#region src/plugin/index.ts
|
|
9
|
-
/**
|
|
10
|
-
* Caller configurations for lingui.
|
|
11
|
-
*
|
|
12
|
-
* After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles
|
|
13
|
-
* macros (`` t`Hello ${name}` `` → `i18n._(id, values)`) the intlayer field
|
|
14
|
-
* usage analyser sees these method calls and records which top-level fields of
|
|
15
|
-
* the `messages` dictionary are consumed, enabling accurate pruning.
|
|
16
|
-
*
|
|
17
|
-
* Two call forms are tracked:
|
|
18
|
-
* - `i18n._('home.title', values)` — string id
|
|
19
|
-
* - `i18n._({ id: 'home.title', message: '...' }, values)` — descriptor
|
|
20
|
-
* - `i18n.t('home.title', values)` — alias for `_`
|
|
21
|
-
*
|
|
22
|
-
* Because lingui projects may also use hashed IDs (generated from the default
|
|
23
|
-
* message string) that cannot be statically mapped to dictionary keys, a
|
|
24
|
-
* separate `'all'`-mode caller is not needed here: when the first argument is
|
|
25
|
-
* not a static string or descriptor, the `'self'` handler falls back to `'all'`
|
|
26
|
-
* automatically.
|
|
27
|
-
*/
|
|
28
|
-
const LINGUI_COMPAT_CALLERS = [{
|
|
29
|
-
callerName: "_",
|
|
30
|
-
importSources: ["@lingui/core", "@intlayer/lingui"],
|
|
31
|
-
matchAsMethod: true,
|
|
32
|
-
namespace: {
|
|
33
|
-
from: "fixed",
|
|
34
|
-
value: "messages"
|
|
35
|
-
},
|
|
36
|
-
translationFunction: "self"
|
|
37
|
-
}, {
|
|
38
|
-
callerName: "t",
|
|
39
|
-
importSources: ["@lingui/core", "@intlayer/lingui"],
|
|
40
|
-
matchAsMethod: true,
|
|
41
|
-
namespace: {
|
|
42
|
-
from: "fixed",
|
|
43
|
-
value: "messages"
|
|
44
|
-
},
|
|
45
|
-
translationFunction: "self"
|
|
46
|
-
}];
|
|
47
|
-
/**
|
|
48
|
-
* A Vite plugin for the lingui compat adapter.
|
|
49
|
-
*
|
|
50
|
-
* Wraps `vite-intlayer` and adds resolve aliases so that both
|
|
51
|
-
* `@lingui/core` **and** `@lingui/react` are redirected to
|
|
52
|
-
* `@intlayer/lingui` at bundle time.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* // vite.config.ts
|
|
57
|
-
* import { linguiVitePlugin } from '@intlayer/lingui/plugin';
|
|
58
|
-
*
|
|
59
|
-
* export default defineConfig({
|
|
60
|
-
* plugins: [linguiVitePlugin()],
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
const linguiVitePlugin = (options) => {
|
|
65
|
-
const intlayerConfig = getConfiguration();
|
|
66
|
-
const appLogger = getAppLogger(intlayerConfig);
|
|
67
|
-
runOnce(join(intlayerConfig.system.baseDir, ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
|
|
68
|
-
appLogger([colorize("Please report any issues you met on GitHub:", ANSIColors.GREY), colorize("https://github.com/aymericzip/intlayer/issues", ANSIColors.GREY_LIGHT)]);
|
|
69
|
-
}, { cacheTimeoutMs: 1e3 * 60 * 60 });
|
|
70
|
-
const basePlugins = intlayer({
|
|
71
|
-
...options,
|
|
72
|
-
compatCallers: [...options?.compatCallers ?? [], ...LINGUI_COMPAT_CALLERS]
|
|
73
|
-
});
|
|
74
|
-
const compatPlugin = {
|
|
75
|
-
name: "vite-lingui-compat-plugin",
|
|
76
|
-
config: () => ({ resolve: { alias: {
|
|
77
|
-
"@lingui/core": "@intlayer/lingui",
|
|
78
|
-
"@lingui/react": "@intlayer/lingui"
|
|
79
|
-
} } })
|
|
80
|
-
};
|
|
81
|
-
return [...Array.isArray(basePlugins) ? basePlugins : [basePlugins], compatPlugin];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
//#endregion
|
|
85
|
-
export { linguiVitePlugin as default, linguiVitePlugin };
|
|
86
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "@intlayer/chokidar/utils";
|
|
3
|
+
import "@intlayer/config/colors";
|
|
4
|
+
import "@intlayer/config/logger";
|
|
5
|
+
import "@intlayer/config/node";
|
|
6
|
+
import "vite-intlayer";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles\n * macros (`` t`Hello ${name}` `` → `i18n._(id, values)`) the intlayer field\n * usage analyser sees these method calls and records which top-level fields of\n * the `messages` dictionary are consumed, enabling accurate pruning.\n *\n * Two call forms are tracked:\n * - `i18n._('home.title', values)` — string id\n * - `i18n._({ id: 'home.title', message: '...' }, values)` — descriptor\n * - `i18n.t('home.title', values)` — alias for `_`\n *\n * Because lingui projects may also use hashed IDs (generated from the default\n * message string) that cannot be statically mapped to dictionary keys, a\n * separate `'all'`-mode caller is not needed here: when the first argument is\n * not a static string or descriptor, the `'self'` handler falls back to `'all'`\n * automatically.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: '_',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n {\n callerName: 't',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { runOnce } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { PluginOption } from 'vite';\nimport { type CompatCallerConfig, intlayer } from 'vite-intlayer';\n\n/**\n * Caller configurations for lingui.\n *\n * After `@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin` compiles\n * macros (`` t`Hello ${name}` `` → `i18n._(id, values)`) the intlayer field\n * usage analyser sees these method calls and records which top-level fields of\n * the `messages` dictionary are consumed, enabling accurate pruning.\n *\n * Two call forms are tracked:\n * - `i18n._('home.title', values)` — string id\n * - `i18n._({ id: 'home.title', message: '...' }, values)` — descriptor\n * - `i18n.t('home.title', values)` — alias for `_`\n *\n * Because lingui projects may also use hashed IDs (generated from the default\n * message string) that cannot be statically mapped to dictionary keys, a\n * separate `'all'`-mode caller is not needed here: when the first argument is\n * not a static string or descriptor, the `'self'` handler falls back to `'all'`\n * automatically.\n */\nconst LINGUI_COMPAT_CALLERS: CompatCallerConfig[] = [\n {\n callerName: '_',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n {\n callerName: 't',\n importSources: ['@lingui/core', '@intlayer/lingui'],\n matchAsMethod: true,\n namespace: { from: 'fixed', value: 'messages' },\n translationFunction: 'self',\n },\n];\n\n/**\n * A Vite plugin for the lingui compat adapter.\n *\n * Wraps `vite-intlayer` and adds resolve aliases so that both\n * `@lingui/core` **and** `@lingui/react` are redirected to\n * `@intlayer/lingui` at bundle time.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { lingui } from '@intlayer/lingui/plugin';\n *\n * export default defineConfig({\n * plugins: [lingui()],\n * });\n * ```\n */\nexport const linguiVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...LINGUI_COMPAT_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-lingui-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\n/**\n * Drop-in replacement alias for `@lingui/vite-plugin`'s `lingui` export, so an\n * existing `import { lingui } from '@lingui/vite-plugin'` only needs its source\n * swapped to `@intlayer/lingui/plugin` — the call site stays unchanged.\n */\nexport const lingui = linguiVitePlugin;\n\nexport default linguiVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,wBAA8C,CAClD;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,GACA;CACE,YAAY;CACZ,eAAe,CAAC,gBAAgB,kBAAkB;CAClD,eAAe;CACf,WAAW;EAAE,MAAM;EAAS,OAAO;CAAW;CAC9C,qBAAqB;AACvB,CACF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACX,YACmB;CACnB,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,YAAY,aAAa,cAAc;CAE7C,QACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,CACR,SACE,+CACA,WAAW,IACb,GACA,SACE,iDACA,WAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,MAAO,KAAK,GAC9B,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,qBACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO;GACL,gBAAgB;GAChB,iBAAiB;EACnB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF;;;;;;AAOA,MAAa,SAAS"}
|
|
@@ -33,44 +33,77 @@ type I18nProps = {
|
|
|
33
33
|
declare class I18nClass extends EventEmitter<LinguiEvents> {
|
|
34
34
|
private _locale;
|
|
35
35
|
private _locales?;
|
|
36
|
+
/**
|
|
37
|
+
* Per-locale catalogs supplied at runtime via the constructor, `load()` or
|
|
38
|
+
* `loadAndActivate()`. Used as a fallback when a key is absent from the
|
|
39
|
+
* compiled intlayer `messages` dictionary, so an unmodified lingui codebase
|
|
40
|
+
* (which loads its compiled `.mjs`/`.json` catalogs) keeps working as a
|
|
41
|
+
* drop-in. For optimal bundle size, compile catalogs into intlayer
|
|
42
|
+
* dictionaries instead — see the dev warning emitted by `load()`.
|
|
43
|
+
*/
|
|
44
|
+
private _catalogs;
|
|
45
|
+
private _loadFallbackWarned;
|
|
36
46
|
constructor({
|
|
37
47
|
locale,
|
|
38
|
-
locales
|
|
48
|
+
locales,
|
|
49
|
+
messages
|
|
39
50
|
}?: I18nProps);
|
|
40
51
|
get locale(): string;
|
|
41
52
|
get locales(): Locales | undefined;
|
|
42
53
|
get messages(): Messages;
|
|
54
|
+
/** Merges a single-locale catalog into the in-memory fallback store. */
|
|
55
|
+
private mergeLocaleCatalog;
|
|
56
|
+
/**
|
|
57
|
+
* Merges a `{ [locale]: catalog }` map (lingui's `AllMessages`) into the
|
|
58
|
+
* in-memory fallback store.
|
|
59
|
+
*/
|
|
60
|
+
private mergeAllCatalogs;
|
|
43
61
|
/**
|
|
44
62
|
* No-op: intlayer handles message compilation at build time.
|
|
45
63
|
*/
|
|
46
64
|
setMessagesCompiler(_compiler: MessageCompiler): this;
|
|
47
65
|
/**
|
|
48
|
-
*
|
|
66
|
+
* Loads message catalogs into the runtime fallback store, supporting both
|
|
67
|
+
* lingui signatures: `load(locale, messages)` and `load(allMessages)`.
|
|
68
|
+
*
|
|
69
|
+
* These messages are a compatibility fallback — keys present in the compiled
|
|
70
|
+
* intlayer `messages` dictionary take precedence, and only those keys can be
|
|
71
|
+
* pruned/optimized at build time.
|
|
49
72
|
*/
|
|
50
|
-
load(
|
|
73
|
+
load(localeOrAll: Locale | AllMessages, messages?: Messages): void;
|
|
51
74
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
75
|
+
* Loads the given catalog (fallback store) and activates the locale
|
|
76
|
+
* (emits `'change'`).
|
|
54
77
|
*/
|
|
55
78
|
loadAndActivate({
|
|
56
79
|
locale,
|
|
57
|
-
locales
|
|
80
|
+
locales,
|
|
81
|
+
messages
|
|
58
82
|
}: {
|
|
59
83
|
locale: Locale;
|
|
60
84
|
locales?: Locales;
|
|
61
|
-
messages
|
|
85
|
+
messages?: Messages;
|
|
62
86
|
}): void;
|
|
63
87
|
/**
|
|
64
88
|
* Sets the active locale and emits `'change'` to notify React consumers.
|
|
65
89
|
*/
|
|
66
90
|
activate(locale: Locale, locales?: Locales): void;
|
|
91
|
+
/**
|
|
92
|
+
* Resolves the raw message template for an id (before interpolation).
|
|
93
|
+
*
|
|
94
|
+
* Resolution order:
|
|
95
|
+
* 1. compiled intlayer `messages` dictionary
|
|
96
|
+
* 2. runtime fallback catalog (constructor / `load()` / `loadAndActivate()`)
|
|
97
|
+
*/
|
|
98
|
+
private resolveTemplate;
|
|
67
99
|
/**
|
|
68
100
|
* Translates a message descriptor or a plain ID.
|
|
69
101
|
*
|
|
70
102
|
* Resolution order:
|
|
71
|
-
* 1. `messages` intlayer dictionary (dotted path
|
|
72
|
-
* 2. `
|
|
73
|
-
* 3.
|
|
103
|
+
* 1. `messages` intlayer dictionary (flat dotted key or nested path)
|
|
104
|
+
* 2. runtime fallback catalog loaded via `load()` / `loadAndActivate()`
|
|
105
|
+
* 3. `descriptor.message` or `options.message` (original source string)
|
|
106
|
+
* 4. The raw `id` as fallback
|
|
74
107
|
*/
|
|
75
108
|
_(descriptor: MessageDescriptor): string;
|
|
76
109
|
_(id: MessageId, values?: Values, options?: MessageOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nClass.d.ts","names":[],"sources":["../../src/I18nClass.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"I18nClass.d.ts","names":[],"sources":["../../src/I18nClass.ts"],"mappings":";;;;;KAmBK,MAAA,GAAS,MAAM;AAJ0B;AAAA,KAOzC,eAAA,IAAmB,OAAe;;KAGlC,YAAA;EACH,MAAA;EACA,OAAA,GAAU,KAAA;IAAS,MAAA,EAAQ,MAAA;IAAQ,EAAA,EAAI,SAAS;EAAA;AAAA;AALX;AAAA,KASlC,SAAA;EACH,MAAA,GAAS,MAAA;EACT,OAAA,GAAU,OAAA;EACV,QAAA,GAAW,WAAA;EACX,OAAA,cAAqB,MAAA,UAAgB,EAAA;AAAA;;;;;;AARa;AAAA;;;cAwCvC,SAAA,SAAkB,YAAA,CAAa,YAAA;EAAA,QAClC,OAAA;EAAA,QACA,QAAA;EAnCc;;;;;;;;EAAA,QA4Cd,SAAA;EAAA,QACA,mBAAA;;IAEM,MAAA;IAAe,OAAA;IAAS;EAAA,IAAY,SAAA;EAAA,IAO9C,MAAA;EAAA,IAIA,OAAA,IAAW,OAAA;EAAA,IAIX,QAAA,IAAY,QAAA;EA7BK;EAAA,QA4Cb,kBAAA;EA5CkC;;;;EAAA,QAoDlC,gBAAA;EA3BO;;;EAsCf,mBAAA,CAAoB,SAAA,EAAW,eAAA;EAkBJ;;;;;;;;EAA3B,IAAA,CAAK,WAAA,EAAa,MAAA,GAAS,WAAA,EAAa,QAAA,GAAW,QAAA;EAqChB;;;;EAhBnC,eAAA;IACE,MAAA;IACA,OAAA;IACA;EAAA;IAEA,MAAA,EAAQ,MAAA;IACR,OAAA,GAAU,OAAA;IACV,QAAA,GAAW,QAAA;EAAA;EA+FM;;;EAtFnB,QAAA,CAAS,MAAA,EAAQ,MAAA,EAAQ,OAAA,GAAU,OAAA;EAtHM;;;;;;;EAAA,QAmIjC,eAAA;;;;;;;;;;EAyBR,CAAA,CAAE,UAAA,EAAY,iBAAA;EACd,CAAA,CAAE,EAAA,EAAI,SAAA,EAAW,MAAA,GAAS,MAAA,EAAQ,OAAA,GAAU,cAAA;EAhIxC;;;EAqKJ,CAAA,GACE,cAAA,EAAgB,iBAAA,GAAoB,SAAA,EACpC,MAAA,GAAS,MAAA,EACT,OAAA,GAAU,cAAA;EAtIZ;;;EA4IA,IAAA,CACE,KAAA,YAAiB,IAAA,WACjB,MAAA,GAAS,IAAA,CAAK,qBAAA;EA5HE;;;EAyIlB,MAAA,CAAO,KAAA,mBAAwB,MAAA,GAAS,IAAA,CAAK,mBAAA;AAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/linguiCatalog.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for reading lingui message catalogs.
|
|
4
|
+
*
|
|
5
|
+
* lingui catalogs are flat maps whose keys are dotted strings
|
|
6
|
+
* (`'results-table.bundleSize'`) rather than nested objects, and whose
|
|
7
|
+
* compiled (`.mjs`) values are token arrays rather than plain strings. These
|
|
8
|
+
* helpers bridge that format onto intlayer's ICU-based `resolveMessage`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Reads a value from a catalog by id.
|
|
12
|
+
*
|
|
13
|
+
* lingui ids are flat keys that themselves contain dots
|
|
14
|
+
* (`'results-table.bundleSize'`), so the flat key is tried first. When that
|
|
15
|
+
* misses, the id is treated as a nested path (`'home.title'` →
|
|
16
|
+
* `catalog.home.title`) to also support genuinely nested intlayer
|
|
17
|
+
* dictionaries.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* navigateCatalog({ 'a.b': 'X' }, 'a.b'); // 'X' (flat key)
|
|
21
|
+
* navigateCatalog({ a: { b: 'X' } }, 'a.b'); // 'X' (nested path)
|
|
22
|
+
*/
|
|
23
|
+
declare const navigateCatalog: (catalog: unknown, id: string) => unknown;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a compiled lingui message into an ICU MessageFormat string that
|
|
26
|
+
* `@intlayer/core`'s `resolveMessage(…, 'icu')` can interpolate.
|
|
27
|
+
*
|
|
28
|
+
* Plain strings (uncompiled `.json` catalogs) pass through unchanged; token
|
|
29
|
+
* arrays (compiled `.mjs` catalogs) are flattened, including nested
|
|
30
|
+
* plural/select blocks and `{name}` placeholders.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* linguiMessageToIcu(['Bundle Size']); // 'Bundle Size'
|
|
34
|
+
* linguiMessageToIcu(['Hello ', ['name']]); // 'Hello {name}'
|
|
35
|
+
* linguiMessageToIcu('Already ICU {count}'); // 'Already ICU {count}'
|
|
36
|
+
*/
|
|
37
|
+
declare const linguiMessageToIcu: (compiled: unknown) => string;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { linguiMessageToIcu, navigateCatalog };
|
|
40
|
+
//# sourceMappingURL=linguiCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linguiCatalog.d.ts","names":[],"sources":["../../src/linguiCatalog.ts"],"mappings":";;AAsBA;;;;AAA4D;AA2E5D;;;;AAAoD;;;;;;;;;;;cA3EvC,eAAA,GAAmB,OAAA,WAAkB,EAAU;;;;;;;;;;;;;;cA2E/C,kBAAA,GAAsB,QAAiB"}
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { intlayer } from "vite-intlayer";
|
|
3
|
-
|
|
4
|
-
//#region src/plugin/index.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* A Vite plugin for the lingui compat adapter.
|
|
7
|
-
*
|
|
8
|
-
* Wraps `vite-intlayer` and adds resolve aliases so that both
|
|
9
|
-
* `@lingui/core` **and** `@lingui/react` are redirected to
|
|
10
|
-
* `@intlayer/lingui` at bundle time.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* // vite.config.ts
|
|
15
|
-
* import { linguiVitePlugin } from '@intlayer/lingui/plugin';
|
|
16
|
-
*
|
|
17
|
-
* export default defineConfig({
|
|
18
|
-
* plugins: [linguiVitePlugin()],
|
|
19
|
-
* });
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
declare const linguiVitePlugin: (options?: Parameters<typeof intlayer>[0]) => PluginOption[];
|
|
23
|
-
//#endregion
|
|
24
|
-
export { linguiVitePlugin as default, linguiVitePlugin };
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AA6DA;;;;;;;;;;;;;AAEe
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/plugin/index.ts"],"mappings":";;;;;;AA6DA;;;;;;;;;;;;;AAEe;AA2Df;cA7Da,gBAAA,GACX,OAAA,GAAU,UAAA,QAAkB,QAAA,SAC3B,YAAA;;;;;;cA2DU,MAAA,GAAM,OAAA,GA5DP,UAAA,QAAkB,QAAA,SAC3B,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/lingui",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "lingui API adapter for intlayer — drop-in compatibility layer",
|
|
6
6
|
"keywords": [
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@intlayer/chokidar": "9.0.0-canary.
|
|
78
|
-
"@intlayer/config": "9.0.0-canary.
|
|
79
|
-
"@intlayer/core": "9.0.0-canary.
|
|
80
|
-
"@intlayer/dictionaries-entry": "9.0.0-canary.
|
|
81
|
-
"@intlayer/types": "9.0.0-canary.
|
|
82
|
-
"react-intlayer": "9.0.0-canary.
|
|
83
|
-
"vite-intlayer": "9.0.0-canary.
|
|
77
|
+
"@intlayer/chokidar": "9.0.0-canary.7",
|
|
78
|
+
"@intlayer/config": "9.0.0-canary.7",
|
|
79
|
+
"@intlayer/core": "9.0.0-canary.7",
|
|
80
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.7",
|
|
81
|
+
"@intlayer/types": "9.0.0-canary.7",
|
|
82
|
+
"react-intlayer": "9.0.0-canary.7",
|
|
83
|
+
"vite-intlayer": "9.0.0-canary.7"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@lingui/core": "^6.3.0",
|