@lingui/macro 4.11.2 → 5.0.0-next.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/README.md +1 -1
- package/index.d.ts +69 -289
- package/index.js +1 -0
- package/package.json +18 -38
package/README.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,318 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
message?: string
|
|
25
|
-
}
|
|
26
|
-
| {
|
|
27
|
-
id?: string
|
|
28
|
-
message: string
|
|
29
|
-
}
|
|
30
|
-
) & {
|
|
31
|
-
comment?: string
|
|
32
|
-
context?: string
|
|
33
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
t as _t,
|
|
3
|
+
plural as _plural,
|
|
4
|
+
defineMessage as _defineMessage,
|
|
5
|
+
msg as _msg,
|
|
6
|
+
select as _select,
|
|
7
|
+
selectOrdinal as _selectOrdinal,
|
|
8
|
+
SelectOptions as _SelectOptions,
|
|
9
|
+
ChoiceOptions as _ChoiceOptions,
|
|
10
|
+
MacroMessageDescriptor as _MacroMessageDescriptor,
|
|
11
|
+
} from "@lingui/core/macro"
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
Trans as _Trans,
|
|
15
|
+
Plural as _Plural,
|
|
16
|
+
Select as _Select,
|
|
17
|
+
SelectOrdinal as _SelectOrdinal,
|
|
18
|
+
PluralChoiceProps as _PluralChoiceProps,
|
|
19
|
+
SelectChoiceProps as _SelectChoiceProps,
|
|
20
|
+
CommonProps as _CommonProps,
|
|
21
|
+
TransProps as _TransProps,
|
|
22
|
+
useLingui as _useLingui,
|
|
23
|
+
} from "@lingui/react/macro"
|
|
34
24
|
|
|
35
25
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```
|
|
40
|
-
* import { t } from "@lingui/macro";
|
|
41
|
-
* const message = t({
|
|
42
|
-
* id: "msg.hello",
|
|
43
|
-
* comment: "Greetings at the homepage",
|
|
44
|
-
* message: `Hello ${name}`,
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```
|
|
50
|
-
* import { t } from "@lingui/macro";
|
|
51
|
-
* const message = t({
|
|
52
|
-
* id: "msg.plural",
|
|
53
|
-
* message: plural(value, { one: "...", other: "..." }),
|
|
54
|
-
* });
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @param descriptor The message descriptor to translate
|
|
26
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
58
27
|
*/
|
|
59
|
-
|
|
28
|
+
declare const t: typeof _t
|
|
60
29
|
|
|
61
30
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```
|
|
66
|
-
* import { t } from "@lingui/macro";
|
|
67
|
-
* const message = t`Hello ${name}`;
|
|
68
|
-
* ```
|
|
31
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
69
32
|
*/
|
|
70
|
-
|
|
71
|
-
literals: TemplateStringsArray,
|
|
72
|
-
...placeholders: any[]
|
|
73
|
-
): string
|
|
74
|
-
|
|
33
|
+
declare const msg: typeof _msg
|
|
75
34
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```
|
|
80
|
-
* import { t } from "@lingui/macro";
|
|
81
|
-
* import { I18n } from "@lingui/core";
|
|
82
|
-
* const i18n = new I18n({
|
|
83
|
-
* locale: "nl",
|
|
84
|
-
* messages: { "Hello {0}": "Hallo {0}" },
|
|
85
|
-
* });
|
|
86
|
-
* const message = t(i18n)`Hello ${name}`;
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```
|
|
91
|
-
* import { t } from "@lingui/macro";
|
|
92
|
-
* import { I18n } from "@lingui/core";
|
|
93
|
-
* const i18n = new I18n({
|
|
94
|
-
* locale: "nl",
|
|
95
|
-
* messages: { "Hello {0}": "Hallo {0}" },
|
|
96
|
-
* });
|
|
97
|
-
* const message = t(i18n)({ message: `Hello ${name}` });
|
|
98
|
-
* ```
|
|
35
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
99
36
|
*/
|
|
100
|
-
|
|
101
|
-
(literals: TemplateStringsArray, ...placeholders: any[]): string
|
|
102
|
-
(descriptor: MacroMessageDescriptor): string
|
|
103
|
-
}
|
|
104
|
-
|
|
37
|
+
declare const plural: typeof _plural
|
|
105
38
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```
|
|
110
|
-
* import { plural } from "@lingui/macro";
|
|
111
|
-
* const message = plural(count, {
|
|
112
|
-
* one: "# Book",
|
|
113
|
-
* other: "# Books",
|
|
114
|
-
* });
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @param value Determines the plural form
|
|
118
|
-
* @param options Object with available plural forms
|
|
39
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
119
40
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
41
|
+
declare const defineMessage: typeof _defineMessage
|
|
122
42
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* Similar to `plural` but instead of using cardinal plural forms,
|
|
126
|
-
* it uses ordinal forms.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```
|
|
130
|
-
* import { selectOrdinal } from "@lingui/macro";
|
|
131
|
-
* const message = selectOrdinal(count, {
|
|
132
|
-
* one: "#st",
|
|
133
|
-
* two: "#nd",
|
|
134
|
-
* few: "#rd",
|
|
135
|
-
* other: "#th",
|
|
136
|
-
* });
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
|
-
* @param value Determines the plural form
|
|
140
|
-
* @param options Object with available plural forms
|
|
43
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
141
44
|
*/
|
|
142
|
-
|
|
143
|
-
value: number | string,
|
|
144
|
-
options: ChoiceOptions
|
|
145
|
-
): string
|
|
146
|
-
|
|
147
|
-
type SelectOptions = {
|
|
148
|
-
/** Catch-all option */
|
|
149
|
-
other: string
|
|
150
|
-
[matches: string]: string
|
|
151
|
-
}
|
|
152
|
-
|
|
45
|
+
declare const select: typeof _select
|
|
153
46
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* Select works like a switch statement. It will
|
|
157
|
-
* select one of the forms in `options` object which
|
|
158
|
-
* key matches exactly `value`.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```
|
|
162
|
-
* import { select } from "@lingui/macro";
|
|
163
|
-
* const message = select(gender, {
|
|
164
|
-
* male: "he",
|
|
165
|
-
* female: "she",
|
|
166
|
-
* other: "they",
|
|
167
|
-
* });
|
|
168
|
-
* ```
|
|
169
|
-
*
|
|
170
|
-
* @param value The key of choices to use
|
|
171
|
-
* @param choices
|
|
47
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
172
48
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
49
|
+
declare const selectOrdinal: typeof _selectOrdinal
|
|
175
50
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* `defineMessage` can be used to add comments for translators,
|
|
179
|
-
* or to override the message ID.
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```
|
|
183
|
-
* import { defineMessage } from "@lingui/macro";
|
|
184
|
-
* const message = defineMessage({
|
|
185
|
-
* comment: "Greetings on the welcome page",
|
|
186
|
-
* message: `Welcome, ${name}!`,
|
|
187
|
-
* });
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* @param descriptor The message descriptor
|
|
51
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
191
52
|
*/
|
|
192
|
-
|
|
193
|
-
descriptor: MacroMessageDescriptor
|
|
194
|
-
): MessageDescriptor
|
|
195
|
-
|
|
53
|
+
declare const SelectOptions: _SelectOptions
|
|
196
54
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* ```
|
|
201
|
-
* import { defineMessage, msg } from "@lingui/macro";
|
|
202
|
-
* const message = defineMessage`Hello ${name}`;
|
|
203
|
-
*
|
|
204
|
-
* // or using shorter version
|
|
205
|
-
* const message = msg`Hello ${name}`;
|
|
206
|
-
* ```
|
|
55
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
207
56
|
*/
|
|
208
|
-
|
|
209
|
-
literals: TemplateStringsArray,
|
|
210
|
-
...placeholders: any[]
|
|
211
|
-
): MessageDescriptor
|
|
212
|
-
|
|
57
|
+
declare const ChoiceOptions: _ChoiceOptions
|
|
213
58
|
/**
|
|
214
|
-
*
|
|
215
|
-
* Alias for {@see defineMessage}
|
|
59
|
+
* @deprecated please import from `@lingui/core/macro` directly
|
|
216
60
|
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
type CommonProps = TransRenderCallbackOrComponent & {
|
|
220
|
-
id?: string
|
|
221
|
-
comment?: string
|
|
222
|
-
context?: string
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
type TransProps = {
|
|
226
|
-
children: ReactNode
|
|
227
|
-
} & CommonProps
|
|
228
|
-
|
|
229
|
-
type PluralChoiceProps = {
|
|
230
|
-
value: string | number
|
|
231
|
-
/** Offset of value when calculating plural forms */
|
|
232
|
-
offset?: number
|
|
233
|
-
zero?: ReactNode
|
|
234
|
-
one?: ReactNode
|
|
235
|
-
two?: ReactNode
|
|
236
|
-
few?: ReactNode
|
|
237
|
-
many?: ReactNode
|
|
238
|
-
|
|
239
|
-
/** Catch-all option */
|
|
240
|
-
other: ReactNode
|
|
241
|
-
/** Exact match form, corresponds to =N rule */
|
|
242
|
-
[digit: `_${number}`]: ReactNode
|
|
243
|
-
} & CommonProps
|
|
244
|
-
|
|
245
|
-
type SelectChoiceProps = {
|
|
246
|
-
value: string
|
|
247
|
-
/** Catch-all option */
|
|
248
|
-
other: ReactNode
|
|
249
|
-
[option: `_${string}`]: ReactNode
|
|
250
|
-
} & CommonProps
|
|
61
|
+
declare const MacroMessageDescriptor: _MacroMessageDescriptor
|
|
251
62
|
|
|
252
63
|
/**
|
|
253
|
-
*
|
|
254
|
-
* messages with variables, but also for messages with inline markup
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```
|
|
258
|
-
* <Trans>Hello {username}. Read the <a href="/docs">docs</a>.</Trans>
|
|
259
|
-
* ```
|
|
260
|
-
* @example
|
|
261
|
-
* ```
|
|
262
|
-
* <Trans id="custom.id">Hello {username}.</Trans>
|
|
263
|
-
* ```
|
|
64
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
264
65
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
66
|
+
declare const Trans: typeof _Trans
|
|
267
67
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```
|
|
272
|
-
* import { Plural } from "@lingui/macro"
|
|
273
|
-
* <Plural value={numBooks} one="Book" other="Books" />
|
|
274
|
-
*
|
|
275
|
-
* // ↓ ↓ ↓ ↓ ↓ ↓
|
|
276
|
-
* import { Trans } from "@lingui/react"
|
|
277
|
-
* <Trans id="{numBooks, plural, one {Book} other {Books}}" values={{ numBooks }} />
|
|
278
|
-
* ```
|
|
68
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
279
69
|
*/
|
|
280
|
-
export const Plural:
|
|
70
|
+
export const Plural: typeof _Plural
|
|
281
71
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```
|
|
286
|
-
* // count == 1 -> 1st
|
|
287
|
-
* // count == 2 -> 2nd
|
|
288
|
-
* // count == 3 -> 3rd
|
|
289
|
-
* // count == 4 -> 4th
|
|
290
|
-
* <SelectOrdinal
|
|
291
|
-
* value={count}
|
|
292
|
-
* one="#st"
|
|
293
|
-
* two="#nd"
|
|
294
|
-
* few="#rd"
|
|
295
|
-
* other="#th"
|
|
296
|
-
* />
|
|
297
|
-
* ```
|
|
72
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
298
73
|
*/
|
|
299
|
-
export const
|
|
300
|
-
|
|
74
|
+
export const PluralChoiceProps: _PluralChoiceProps
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
77
|
+
*/
|
|
78
|
+
export const SelectChoiceProps: _SelectChoiceProps
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
81
|
+
*/
|
|
82
|
+
export const Select: typeof _Select
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
85
|
+
*/
|
|
86
|
+
export const CommonProps: _CommonProps
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
89
|
+
*/
|
|
90
|
+
export const SelectOrdinal: typeof _SelectOrdinal
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
93
|
+
*/
|
|
94
|
+
export const TransProps: _TransProps
|
|
301
95
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* ```
|
|
306
|
-
* // gender == "female" -> Her book
|
|
307
|
-
* // gender == "male" -> His book
|
|
308
|
-
* // gender == "non-binary" -> Their book
|
|
309
|
-
*
|
|
310
|
-
* <Select
|
|
311
|
-
* value={gender}
|
|
312
|
-
* _male="His book"
|
|
313
|
-
* _female="Her book"
|
|
314
|
-
* other="Their book"
|
|
315
|
-
* />
|
|
316
|
-
* ```
|
|
96
|
+
* @deprecated please import from `@lingui/react/macro` directly
|
|
317
97
|
*/
|
|
318
|
-
export const
|
|
98
|
+
export const useLingui: typeof _useLingui
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("@lingui/babel-plugin-lingui-macro/macro")
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/macro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-next.0",
|
|
4
4
|
"description": "Macro for generating messages in ICU MessageFormat syntax",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
5
|
+
"main": "./index.js",
|
|
7
6
|
"types": "./index.d.ts",
|
|
8
7
|
"sideEffects": false,
|
|
9
8
|
"author": {
|
|
@@ -11,9 +10,7 @@
|
|
|
11
10
|
"email": "tomas.ehrlich@gmail.com"
|
|
12
11
|
},
|
|
13
12
|
"scripts": {
|
|
14
|
-
"test:tsd": "tsd"
|
|
15
|
-
"build": "rimraf ./dist && unbuild",
|
|
16
|
-
"stub": "unbuild --stub"
|
|
13
|
+
"test:tsd": "tsd"
|
|
17
14
|
},
|
|
18
15
|
"license": "MIT",
|
|
19
16
|
"keywords": [
|
|
@@ -38,49 +35,32 @@
|
|
|
38
35
|
},
|
|
39
36
|
"exports": {
|
|
40
37
|
".": {
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
"default": "./dist/index.cjs"
|
|
44
|
-
},
|
|
45
|
-
"import": {
|
|
46
|
-
"types": "./index.d.ts",
|
|
47
|
-
"default": "./dist/index.mjs"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"./node": {
|
|
51
|
-
"require": {
|
|
52
|
-
"types": "./dist/index.d.ts"
|
|
53
|
-
},
|
|
54
|
-
"import": {
|
|
55
|
-
"types": "./dist/index.d.ts"
|
|
56
|
-
}
|
|
38
|
+
"types": "./index.d.ts",
|
|
39
|
+
"default": "./index.js"
|
|
57
40
|
}
|
|
58
41
|
},
|
|
59
42
|
"files": [
|
|
60
43
|
"LICENSE",
|
|
61
44
|
"README.md",
|
|
62
45
|
"dist/",
|
|
63
|
-
"index.d.ts"
|
|
46
|
+
"index.d.ts",
|
|
47
|
+
"index.js"
|
|
64
48
|
],
|
|
65
49
|
"dependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@lingui/conf": "4.11.2",
|
|
69
|
-
"@lingui/core": "4.11.2",
|
|
70
|
-
"@lingui/message-utils": "4.11.2"
|
|
50
|
+
"@lingui/core": "^5.0.0-next.0",
|
|
51
|
+
"@lingui/react": "^5.0.0-next.0"
|
|
71
52
|
},
|
|
72
53
|
"peerDependencies": {
|
|
73
|
-
"@lingui/
|
|
54
|
+
"@lingui/babel-plugin-lingui-macro": "4.11.2",
|
|
74
55
|
"babel-plugin-macros": "2 || 3"
|
|
75
56
|
},
|
|
76
|
-
"
|
|
77
|
-
"@babel
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"unbuild": "2.0.0"
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"@lingui/babel-plugin-lingui-macro": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"babel-plugin-macros": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
84
64
|
},
|
|
85
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2192f8d54699a3846ff8fe6f3992697be2da68a8"
|
|
86
66
|
}
|