@lingui/core 6.0.1 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +29 -4
- package/dist/index.mjs +2 -2
- package/macro/index.d.mts +8 -8
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -60,15 +60,40 @@ type Values = Record<string, unknown>;
|
|
|
60
60
|
type UncompiledMessage = string;
|
|
61
61
|
type Messages = Record<string, UncompiledMessage | CompiledMessage>;
|
|
62
62
|
type AllMessages = Record<Locale, Messages>;
|
|
63
|
+
/**
|
|
64
|
+
* Register interface for module augmentation.
|
|
65
|
+
* Users can augment this interface to narrow MessageId to a specific union type.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* // src/lingui.d.ts
|
|
70
|
+
* import type enMessages from "./locales/en/messages.json";
|
|
71
|
+
*
|
|
72
|
+
* declare module "@lingui/core" {
|
|
73
|
+
* interface Register {
|
|
74
|
+
* messageIds: keyof typeof enMessages;
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
interface Register {
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolves to the registered message ID union, or falls back to `string`
|
|
83
|
+
* when no augmentation exists.
|
|
84
|
+
*/
|
|
85
|
+
type MessageId = Register extends {
|
|
86
|
+
messageIds: infer TIds extends string;
|
|
87
|
+
} ? TIds : string;
|
|
63
88
|
type MessageDescriptor = {
|
|
64
|
-
id:
|
|
89
|
+
id: MessageId;
|
|
65
90
|
comment?: string;
|
|
66
91
|
message?: string;
|
|
67
92
|
values?: Record<string, unknown>;
|
|
68
93
|
};
|
|
69
94
|
type MissingMessageEvent = {
|
|
70
95
|
locale: Locale;
|
|
71
|
-
id:
|
|
96
|
+
id: MessageId;
|
|
72
97
|
};
|
|
73
98
|
type MissingHandler = string | ((locale: string, id: string) => string);
|
|
74
99
|
type I18nProps = {
|
|
@@ -125,7 +150,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
125
150
|
loadAndActivate({ locale, locales, messages }: LoadAndActivateOptions): void;
|
|
126
151
|
activate(locale: Locale, locales?: Locales): void;
|
|
127
152
|
_(descriptor: MessageDescriptor): string;
|
|
128
|
-
_(id:
|
|
153
|
+
_(id: MessageId, values?: Values, options?: MessageOptions): string;
|
|
129
154
|
/**
|
|
130
155
|
* Alias for {@see I18n._}
|
|
131
156
|
*/
|
|
@@ -144,4 +169,4 @@ declare function setupI18n(params?: I18nProps): I18n;
|
|
|
144
169
|
declare const i18n: I18n;
|
|
145
170
|
|
|
146
171
|
export { I18n, formats, i18n, setupI18n };
|
|
147
|
-
export type { AllMessages, Locale, Locales, MessageDescriptor, MessageOptions, Messages };
|
|
172
|
+
export type { AllMessages, Locale, Locales, MessageDescriptor, MessageId, MessageOptions, Messages, Register };
|
package/dist/index.mjs
CHANGED
|
@@ -344,9 +344,9 @@ class I18n extends EventEmitter {
|
|
|
344
344
|
> ${translation}
|
|
345
345
|
|
|
346
346
|
That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used.
|
|
347
|
-
ICU features such as interpolation and plurals will not work properly for that message.
|
|
347
|
+
ICU features such as interpolation and plurals will not work properly for that message.
|
|
348
348
|
|
|
349
|
-
Please compile your catalog first.
|
|
349
|
+
Please compile your catalog first.
|
|
350
350
|
`);
|
|
351
351
|
}
|
|
352
352
|
}
|
package/macro/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { I18n, MessageDescriptor } from "@lingui/core"
|
|
1
|
+
import type { I18n, MessageDescriptor, MessageId } from "@lingui/core"
|
|
2
2
|
|
|
3
3
|
export type ChoiceOptions = {
|
|
4
4
|
/** Offset of value when calculating plural forms */
|
|
@@ -17,11 +17,11 @@ export type ChoiceOptions = {
|
|
|
17
17
|
|
|
18
18
|
export type MacroMessageDescriptor = (
|
|
19
19
|
| {
|
|
20
|
-
id:
|
|
20
|
+
id: MessageId
|
|
21
21
|
message?: string
|
|
22
22
|
}
|
|
23
23
|
| {
|
|
24
|
-
id?:
|
|
24
|
+
id?: MessageId
|
|
25
25
|
message: string
|
|
26
26
|
}
|
|
27
27
|
) & {
|
|
@@ -126,7 +126,7 @@ export function t(i18n: I18n): {
|
|
|
126
126
|
*/
|
|
127
127
|
export function plural(
|
|
128
128
|
value: number | string | LabeledExpression<number | string>,
|
|
129
|
-
options: ChoiceOptions
|
|
129
|
+
options: ChoiceOptions,
|
|
130
130
|
): string
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -151,7 +151,7 @@ export function plural(
|
|
|
151
151
|
*/
|
|
152
152
|
export function selectOrdinal(
|
|
153
153
|
value: number | string | LabeledExpression<number | string>,
|
|
154
|
-
options: ChoiceOptions
|
|
154
|
+
options: ChoiceOptions,
|
|
155
155
|
): string
|
|
156
156
|
|
|
157
157
|
type SelectOptions = {
|
|
@@ -182,7 +182,7 @@ type SelectOptions = {
|
|
|
182
182
|
*/
|
|
183
183
|
export function select(
|
|
184
184
|
value: string | LabeledExpression<string>,
|
|
185
|
-
choices: SelectOptions
|
|
185
|
+
choices: SelectOptions,
|
|
186
186
|
): string
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -203,7 +203,7 @@ export function select(
|
|
|
203
203
|
* @param descriptor The message descriptor
|
|
204
204
|
*/
|
|
205
205
|
export function defineMessage(
|
|
206
|
-
descriptor: MacroMessageDescriptor
|
|
206
|
+
descriptor: MacroMessageDescriptor,
|
|
207
207
|
): MessageDescriptor
|
|
208
208
|
|
|
209
209
|
/**
|
|
@@ -232,4 +232,4 @@ export const msg: typeof defineMessage
|
|
|
232
232
|
/**
|
|
233
233
|
* Helps to define a name for a variable in the message
|
|
234
234
|
*/
|
|
235
|
-
export function ph(def: LabeledExpression<string | number>): string
|
|
235
|
+
export function ph(def: LabeledExpression<string | number>): string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/core",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Internationalization (i18n) tools for JavaScript",
|
|
6
6
|
"type": "module",
|
|
@@ -55,11 +55,12 @@
|
|
|
55
55
|
"macro/index.mjs"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@lingui/babel-plugin-lingui-macro": "6.0
|
|
59
|
-
"@lingui/message-utils": "6.0
|
|
58
|
+
"@lingui/babel-plugin-lingui-macro": "6.2.0",
|
|
59
|
+
"@lingui/message-utils": "6.2.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@lingui/test-utils": "3.0.3",
|
|
63
|
+
"typescript": "catalog:",
|
|
63
64
|
"unbuild": "catalog:",
|
|
64
65
|
"vitest": "catalog:"
|
|
65
66
|
},
|
|
@@ -74,5 +75,5 @@
|
|
|
74
75
|
"unbuild": {
|
|
75
76
|
"declaration": "node16"
|
|
76
77
|
},
|
|
77
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "9f2a37bc4a9e3de323b4b9094898e8f05cf05956"
|
|
78
79
|
}
|