@lingui/conf 5.9.3 → 6.0.0-next.1
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 +78 -42
- package/dist/index.mjs +68 -29
- package/package.json +18 -13
- package/dist/index.cjs +0 -447
- package/dist/index.d.cts +0 -355
- package/dist/index.d.ts +0 -355
package/dist/index.d.cts
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated please pass formatter directly to `format`
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```js
|
|
6
|
-
* // lingui.config.{js,ts}
|
|
7
|
-
* import {formatter} from "@lingui/format-po"
|
|
8
|
-
*
|
|
9
|
-
* export default {
|
|
10
|
-
* [...]
|
|
11
|
-
* format: formatter({lineNumbers: false}),
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
|
|
16
|
-
type ExtractorCtx = {
|
|
17
|
-
/**
|
|
18
|
-
* Raw Sourcemaps object to mapping from.
|
|
19
|
-
* Check the https://github.com/mozilla/source-map#new-sourcemapconsumerrawsourcemap
|
|
20
|
-
*/
|
|
21
|
-
sourceMaps?: any;
|
|
22
|
-
linguiConfig: LinguiConfigNormalized;
|
|
23
|
-
};
|
|
24
|
-
type CatalogExtra = Record<string, unknown>;
|
|
25
|
-
type MessageOrigin = [filename: string, line?: number];
|
|
26
|
-
type ExtractedMessageType<Extra = CatalogExtra> = {
|
|
27
|
-
message?: string;
|
|
28
|
-
origin?: MessageOrigin[];
|
|
29
|
-
comments?: string[];
|
|
30
|
-
obsolete?: boolean;
|
|
31
|
-
context?: string;
|
|
32
|
-
/**
|
|
33
|
-
* the generic field where
|
|
34
|
-
* formatters can store additional data
|
|
35
|
-
*/
|
|
36
|
-
extra?: Extra;
|
|
37
|
-
placeholders?: Record<string, string[]>;
|
|
38
|
-
};
|
|
39
|
-
type MessageType<Extra = CatalogExtra> = ExtractedMessageType<Extra> & {
|
|
40
|
-
translation: string;
|
|
41
|
-
};
|
|
42
|
-
type ExtractedCatalogType<Extra = CatalogExtra> = {
|
|
43
|
-
[msgId: string]: ExtractedMessageType<Extra>;
|
|
44
|
-
};
|
|
45
|
-
type CatalogType<Extra = CatalogExtra> = {
|
|
46
|
-
[msgId: string]: MessageType<Extra>;
|
|
47
|
-
};
|
|
48
|
-
type ExtractorType = {
|
|
49
|
-
match(filename: string): boolean;
|
|
50
|
-
extract(filename: string, code: string, onMessageExtracted: (msg: ExtractedMessage) => void, ctx?: ExtractorCtx): Promise<void> | void;
|
|
51
|
-
};
|
|
52
|
-
type CatalogFormatter = {
|
|
53
|
-
catalogExtension: string;
|
|
54
|
-
/**
|
|
55
|
-
* Set extension used when extract to template
|
|
56
|
-
* Omit if the extension is the same as catalogExtension
|
|
57
|
-
*/
|
|
58
|
-
templateExtension?: string;
|
|
59
|
-
parse(content: string, ctx: {
|
|
60
|
-
locale: string | null;
|
|
61
|
-
sourceLocale: string;
|
|
62
|
-
filename: string;
|
|
63
|
-
}): Promise<CatalogType> | CatalogType;
|
|
64
|
-
serialize(catalog: CatalogType, ctx: {
|
|
65
|
-
locale: string | null;
|
|
66
|
-
sourceLocale: string;
|
|
67
|
-
filename: string;
|
|
68
|
-
existing: string | null;
|
|
69
|
-
}): Promise<string> | string;
|
|
70
|
-
};
|
|
71
|
-
type ExtractedMessage = {
|
|
72
|
-
id: string;
|
|
73
|
-
message?: string;
|
|
74
|
-
context?: string;
|
|
75
|
-
origin?: [filename: string, line: number, column?: number];
|
|
76
|
-
comment?: string;
|
|
77
|
-
placeholders?: Record<string, string>;
|
|
78
|
-
};
|
|
79
|
-
type CatalogFormatOptions = {
|
|
80
|
-
origins?: boolean;
|
|
81
|
-
lineNumbers?: boolean;
|
|
82
|
-
disableSelectWarning?: boolean;
|
|
83
|
-
};
|
|
84
|
-
type OrderByFn = (a: {
|
|
85
|
-
messageId: string;
|
|
86
|
-
entry: ExtractedMessageType;
|
|
87
|
-
}, b: {
|
|
88
|
-
messageId: string;
|
|
89
|
-
entry: ExtractedMessageType;
|
|
90
|
-
}) => number;
|
|
91
|
-
type OrderBy = "messageId" | "message" | "origin" | OrderByFn;
|
|
92
|
-
type CatalogConfig = {
|
|
93
|
-
name?: string;
|
|
94
|
-
path: string;
|
|
95
|
-
include: string[];
|
|
96
|
-
exclude?: string[];
|
|
97
|
-
};
|
|
98
|
-
type LocaleObject = Record<string, string[] | string> | (Record<string, string[] | string> & {
|
|
99
|
-
default: string;
|
|
100
|
-
});
|
|
101
|
-
type FallbackLocales = LocaleObject;
|
|
102
|
-
type ModuleSource = readonly [module: string, specifier?: string];
|
|
103
|
-
type CatalogService = {
|
|
104
|
-
name: string;
|
|
105
|
-
apiKey: string;
|
|
106
|
-
};
|
|
107
|
-
type ExperimentalExtractorOptions = {
|
|
108
|
-
/**
|
|
109
|
-
* Entries to start extracting from.
|
|
110
|
-
* Each separate resolved entry would create a separate catalog.
|
|
111
|
-
*
|
|
112
|
-
* Example for MPA application like Next.js
|
|
113
|
-
* ```
|
|
114
|
-
* <rootDir>/pages/**\/*.ts
|
|
115
|
-
* <rootDir>/pages/**\/*.page.ts
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* With this config you would have a separate
|
|
119
|
-
* catalog for every page file in your app.
|
|
120
|
-
*/
|
|
121
|
-
entries: string[];
|
|
122
|
-
/**
|
|
123
|
-
* List of package name patterns to include for extraction.
|
|
124
|
-
*
|
|
125
|
-
* For example, to include all packages from your monorepo:
|
|
126
|
-
*
|
|
127
|
-
* ["@mycompany"]
|
|
128
|
-
*
|
|
129
|
-
* By default, all imports that look like package imports are ignored.
|
|
130
|
-
* This means imports that do not start with `/`, `./`, `../`, or `#`
|
|
131
|
-
* (used for subpath imports). TypeScript path aliases are also ignored
|
|
132
|
-
* because they look like package imports.
|
|
133
|
-
*
|
|
134
|
-
* Add here the packages you want to include.
|
|
135
|
-
*/
|
|
136
|
-
includeDeps?: string[];
|
|
137
|
-
/**
|
|
138
|
-
* svg, jpg and other files which might be imported in application should be excluded from analysis.
|
|
139
|
-
* By default, extractor provides a comprehensive list of extensions. If you feel like something
|
|
140
|
-
* is missing in this list please fill an issue on GitHub
|
|
141
|
-
*
|
|
142
|
-
* NOTE: changing this param will override default list of extensions.
|
|
143
|
-
*/
|
|
144
|
-
excludeExtensions?: string[];
|
|
145
|
-
/**
|
|
146
|
-
* output path for extracted catalogs.
|
|
147
|
-
*
|
|
148
|
-
* Supported placeholders for entry: /pages/about/index.page.ts
|
|
149
|
-
* - {entryName} = index.page
|
|
150
|
-
* - {locale} = en
|
|
151
|
-
* - {entryDir} = pages/about/
|
|
152
|
-
*
|
|
153
|
-
* Examples:
|
|
154
|
-
*
|
|
155
|
-
* ```
|
|
156
|
-
* <rootDir>/locales/{entryName}.{locale} -> /locales/index.page/en.po
|
|
157
|
-
* <rootDir>/{entryDir}/locales/{locale} -> /pages/about/locales/en.po
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
output: string;
|
|
161
|
-
resolveEsbuildOptions?: (options: any) => any;
|
|
162
|
-
};
|
|
163
|
-
type LinguiConfig = {
|
|
164
|
-
/**
|
|
165
|
-
* The catalogs configuration defines the location of message catalogs and specifies
|
|
166
|
-
* which files are included when the extract command scans for messages.
|
|
167
|
-
*
|
|
168
|
-
* https://lingui.dev/ref/conf#catalogs
|
|
169
|
-
*/
|
|
170
|
-
catalogs?: CatalogConfig[];
|
|
171
|
-
compileNamespace?: "es" | "ts" | "cjs" | string;
|
|
172
|
-
/**
|
|
173
|
-
* Specify additional options used to parse source files when extracting messages.
|
|
174
|
-
*/
|
|
175
|
-
extractorParserOptions?: {
|
|
176
|
-
/**
|
|
177
|
-
* default false
|
|
178
|
-
*
|
|
179
|
-
* By default, standard decorators (Stage3) are applied for TS files
|
|
180
|
-
* Enable this if you want to use TypesScript's experimental decorators.
|
|
181
|
-
*/
|
|
182
|
-
tsExperimentalDecorators?: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Enable if you use flow. This will apply Flow syntax to js files
|
|
185
|
-
*/
|
|
186
|
-
flow?: boolean;
|
|
187
|
-
};
|
|
188
|
-
compilerBabelOptions?: any;
|
|
189
|
-
fallbackLocales?: FallbackLocales | false;
|
|
190
|
-
/**
|
|
191
|
-
* Specifies custom message extractor implementations
|
|
192
|
-
*
|
|
193
|
-
* https://lingui.dev/guides/custom-extractor
|
|
194
|
-
*/
|
|
195
|
-
extractors?: ExtractorType[];
|
|
196
|
-
prevFormat?: CatalogFormat;
|
|
197
|
-
/**
|
|
198
|
-
* Message catalog format. The po formatter is used by default. Other formatters are available as separate packages.
|
|
199
|
-
*
|
|
200
|
-
* @default "po"
|
|
201
|
-
*/
|
|
202
|
-
format?: CatalogFormat | CatalogFormatter;
|
|
203
|
-
formatOptions?: CatalogFormatOptions;
|
|
204
|
-
/**
|
|
205
|
-
* The locale tags used in the project. The `extract` and `compile` commands write a catalog for each locale specified.
|
|
206
|
-
*
|
|
207
|
-
* Each locale should be a valid BCP-47 code:
|
|
208
|
-
* @example
|
|
209
|
-
*
|
|
210
|
-
* ```js
|
|
211
|
-
* locales: ["en", "cs"]
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
locales: string[];
|
|
215
|
-
/**
|
|
216
|
-
* Define the path where translated catalogs are merged into a single file per locale during the compile process.
|
|
217
|
-
*
|
|
218
|
-
* https://lingui.dev/ref/conf#catalogsmergepath
|
|
219
|
-
*/
|
|
220
|
-
catalogsMergePath?: string;
|
|
221
|
-
/**
|
|
222
|
-
* Order of messages in catalog
|
|
223
|
-
* You can choose one of: `"messageId" | "message" | "origin"`.
|
|
224
|
-
*
|
|
225
|
-
* - `messageId` — Sorts by the message key. Not recommended if you use the source
|
|
226
|
-
* message as the key, as `messageId` is autogenerated and may lead to
|
|
227
|
-
* unexpected results.
|
|
228
|
-
* - `message` — Sorts by the message text and its context. **Recommended**.
|
|
229
|
-
* Messages are ordered alphabetically.
|
|
230
|
-
* - `origin` — Sorts by the location where the message was first defined.
|
|
231
|
-
*
|
|
232
|
-
* You can also provide a custom sorting function. See {@link OrderByFn} for the function signature.
|
|
233
|
-
*
|
|
234
|
-
* @default "message"
|
|
235
|
-
*/
|
|
236
|
-
orderBy?: OrderBy;
|
|
237
|
-
/**
|
|
238
|
-
* Locale used for pseudolocalization. For example, when you set `pseudoLocale: "en"`, all messages in the en catalog will be pseudo-localized.
|
|
239
|
-
* The locale must be included in the locales config.
|
|
240
|
-
*
|
|
241
|
-
* https://lingui.dev/guides/pseudolocalization
|
|
242
|
-
*/
|
|
243
|
-
pseudoLocale?: string;
|
|
244
|
-
/**
|
|
245
|
-
* This is the directory where the Lingui CLI scans for messages in your source files during the extraction process.
|
|
246
|
-
*
|
|
247
|
-
* Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
|
|
248
|
-
*
|
|
249
|
-
* @default: The root of the directory containing your Lingui configuration file or the package.json.
|
|
250
|
-
*/
|
|
251
|
-
rootDir?: string;
|
|
252
|
-
/**
|
|
253
|
-
* This setting specifies the module path for the exported `i18n` object and `Trans` component.
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
*
|
|
257
|
-
* ```js
|
|
258
|
-
* {
|
|
259
|
-
* "runtimeConfigModule": {
|
|
260
|
-
* "Trans": ["./myTrans", "Trans"],
|
|
261
|
-
* "useLingui": ["./myUseLingui", "useLingui"]
|
|
262
|
-
* "i18n": ["./nyI18n", "I18n"]
|
|
263
|
-
* }
|
|
264
|
-
* }
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
|
|
268
|
-
/**
|
|
269
|
-
* Specifies the default language of message IDs in your source files.
|
|
270
|
-
*
|
|
271
|
-
* The catalog for sourceLocale doesn't need actual translations since message IDs are used as-is by default.
|
|
272
|
-
* However, you can still override any message ID by providing a custom translation.
|
|
273
|
-
*
|
|
274
|
-
* The main difference between `sourceLocale` and `fallbackLocales` is their purpose: `sourceLocale` defines the language used for message IDs,
|
|
275
|
-
* while `fallbackLocales` provides alternative translations when specific messages are missing for a particular locale.
|
|
276
|
-
*/
|
|
277
|
-
sourceLocale?: string;
|
|
278
|
-
service?: CatalogService;
|
|
279
|
-
/**
|
|
280
|
-
* Allow you to set macro options
|
|
281
|
-
*/
|
|
282
|
-
macro?: {
|
|
283
|
-
/**
|
|
284
|
-
* Allows customizing the Core Macro package name that the Lingui macro detects.
|
|
285
|
-
*
|
|
286
|
-
* ```ts
|
|
287
|
-
* // lingui.config
|
|
288
|
-
* {
|
|
289
|
-
* macro: {
|
|
290
|
-
* corePackage: ['@lingui/myMacro']
|
|
291
|
-
* }
|
|
292
|
-
* }
|
|
293
|
-
*
|
|
294
|
-
* // app.tsx
|
|
295
|
-
* import { msg } from '@lingui/myMacro'
|
|
296
|
-
*
|
|
297
|
-
* msg`Hello` // <-- would be correctly picked up by macro
|
|
298
|
-
* ```
|
|
299
|
-
*
|
|
300
|
-
* @default ["@lingui/macro", "@lingui/core/macro"]
|
|
301
|
-
*/
|
|
302
|
-
corePackage?: string[];
|
|
303
|
-
/**
|
|
304
|
-
* Allows customizing the JSX Macro package name that the Lingui macro detects.
|
|
305
|
-
*
|
|
306
|
-
* ```ts
|
|
307
|
-
* // lingui.config
|
|
308
|
-
* {
|
|
309
|
-
* macro: {
|
|
310
|
-
* jsxPackage: ["@lingui/myMacro"];
|
|
311
|
-
* }
|
|
312
|
-
* }
|
|
313
|
-
*
|
|
314
|
-
* // app.tsx
|
|
315
|
-
* import { Trans } from '@lingui/myMacro'
|
|
316
|
-
*
|
|
317
|
-
* <Trans>Hello</Trans> // <-- would be correctly picked up by macro
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @default ["@lingui/macro", "@lingui/react/macro"]
|
|
321
|
-
*/
|
|
322
|
-
jsxPackage?: string[];
|
|
323
|
-
};
|
|
324
|
-
experimental?: {
|
|
325
|
-
extractor?: ExperimentalExtractorOptions;
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
type ModuleSourceNormalized = readonly [module: string, specifier: string];
|
|
329
|
-
type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
330
|
-
resolvedConfigPath?: string;
|
|
331
|
-
fallbackLocales?: FallbackLocales;
|
|
332
|
-
runtimeConfigModule: {
|
|
333
|
-
i18n: ModuleSourceNormalized;
|
|
334
|
-
useLingui: ModuleSourceNormalized;
|
|
335
|
-
Trans: ModuleSourceNormalized;
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
|
|
340
|
-
skipValidation?: boolean;
|
|
341
|
-
resolvedConfigPath?: string;
|
|
342
|
-
}): LinguiConfigNormalized;
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Type helper for lingui.config.ts, returns {@link LinguiConfig} object
|
|
346
|
-
*/
|
|
347
|
-
declare function defineConfig(config: LinguiConfig): LinguiConfig;
|
|
348
|
-
|
|
349
|
-
declare function getConfig({ cwd, configPath, skipValidation, }?: {
|
|
350
|
-
cwd?: string;
|
|
351
|
-
configPath?: string;
|
|
352
|
-
skipValidation?: boolean;
|
|
353
|
-
}): LinguiConfigNormalized;
|
|
354
|
-
|
|
355
|
-
export { type CatalogConfig, type CatalogFormat, type CatalogFormatOptions, type CatalogFormatter, type CatalogType, type ExperimentalExtractorOptions, type ExtractedCatalogType, type ExtractedMessage, type ExtractedMessageType, type ExtractorCtx, type ExtractorType, type FallbackLocales, type LinguiConfig, type LinguiConfigNormalized, type MessageOrigin, type MessageType, type OrderBy, type OrderByFn, defineConfig, getConfig, makeConfig };
|
package/dist/index.d.ts
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated please pass formatter directly to `format`
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```js
|
|
6
|
-
* // lingui.config.{js,ts}
|
|
7
|
-
* import {formatter} from "@lingui/format-po"
|
|
8
|
-
*
|
|
9
|
-
* export default {
|
|
10
|
-
* [...]
|
|
11
|
-
* format: formatter({lineNumbers: false}),
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
|
|
16
|
-
type ExtractorCtx = {
|
|
17
|
-
/**
|
|
18
|
-
* Raw Sourcemaps object to mapping from.
|
|
19
|
-
* Check the https://github.com/mozilla/source-map#new-sourcemapconsumerrawsourcemap
|
|
20
|
-
*/
|
|
21
|
-
sourceMaps?: any;
|
|
22
|
-
linguiConfig: LinguiConfigNormalized;
|
|
23
|
-
};
|
|
24
|
-
type CatalogExtra = Record<string, unknown>;
|
|
25
|
-
type MessageOrigin = [filename: string, line?: number];
|
|
26
|
-
type ExtractedMessageType<Extra = CatalogExtra> = {
|
|
27
|
-
message?: string;
|
|
28
|
-
origin?: MessageOrigin[];
|
|
29
|
-
comments?: string[];
|
|
30
|
-
obsolete?: boolean;
|
|
31
|
-
context?: string;
|
|
32
|
-
/**
|
|
33
|
-
* the generic field where
|
|
34
|
-
* formatters can store additional data
|
|
35
|
-
*/
|
|
36
|
-
extra?: Extra;
|
|
37
|
-
placeholders?: Record<string, string[]>;
|
|
38
|
-
};
|
|
39
|
-
type MessageType<Extra = CatalogExtra> = ExtractedMessageType<Extra> & {
|
|
40
|
-
translation: string;
|
|
41
|
-
};
|
|
42
|
-
type ExtractedCatalogType<Extra = CatalogExtra> = {
|
|
43
|
-
[msgId: string]: ExtractedMessageType<Extra>;
|
|
44
|
-
};
|
|
45
|
-
type CatalogType<Extra = CatalogExtra> = {
|
|
46
|
-
[msgId: string]: MessageType<Extra>;
|
|
47
|
-
};
|
|
48
|
-
type ExtractorType = {
|
|
49
|
-
match(filename: string): boolean;
|
|
50
|
-
extract(filename: string, code: string, onMessageExtracted: (msg: ExtractedMessage) => void, ctx?: ExtractorCtx): Promise<void> | void;
|
|
51
|
-
};
|
|
52
|
-
type CatalogFormatter = {
|
|
53
|
-
catalogExtension: string;
|
|
54
|
-
/**
|
|
55
|
-
* Set extension used when extract to template
|
|
56
|
-
* Omit if the extension is the same as catalogExtension
|
|
57
|
-
*/
|
|
58
|
-
templateExtension?: string;
|
|
59
|
-
parse(content: string, ctx: {
|
|
60
|
-
locale: string | null;
|
|
61
|
-
sourceLocale: string;
|
|
62
|
-
filename: string;
|
|
63
|
-
}): Promise<CatalogType> | CatalogType;
|
|
64
|
-
serialize(catalog: CatalogType, ctx: {
|
|
65
|
-
locale: string | null;
|
|
66
|
-
sourceLocale: string;
|
|
67
|
-
filename: string;
|
|
68
|
-
existing: string | null;
|
|
69
|
-
}): Promise<string> | string;
|
|
70
|
-
};
|
|
71
|
-
type ExtractedMessage = {
|
|
72
|
-
id: string;
|
|
73
|
-
message?: string;
|
|
74
|
-
context?: string;
|
|
75
|
-
origin?: [filename: string, line: number, column?: number];
|
|
76
|
-
comment?: string;
|
|
77
|
-
placeholders?: Record<string, string>;
|
|
78
|
-
};
|
|
79
|
-
type CatalogFormatOptions = {
|
|
80
|
-
origins?: boolean;
|
|
81
|
-
lineNumbers?: boolean;
|
|
82
|
-
disableSelectWarning?: boolean;
|
|
83
|
-
};
|
|
84
|
-
type OrderByFn = (a: {
|
|
85
|
-
messageId: string;
|
|
86
|
-
entry: ExtractedMessageType;
|
|
87
|
-
}, b: {
|
|
88
|
-
messageId: string;
|
|
89
|
-
entry: ExtractedMessageType;
|
|
90
|
-
}) => number;
|
|
91
|
-
type OrderBy = "messageId" | "message" | "origin" | OrderByFn;
|
|
92
|
-
type CatalogConfig = {
|
|
93
|
-
name?: string;
|
|
94
|
-
path: string;
|
|
95
|
-
include: string[];
|
|
96
|
-
exclude?: string[];
|
|
97
|
-
};
|
|
98
|
-
type LocaleObject = Record<string, string[] | string> | (Record<string, string[] | string> & {
|
|
99
|
-
default: string;
|
|
100
|
-
});
|
|
101
|
-
type FallbackLocales = LocaleObject;
|
|
102
|
-
type ModuleSource = readonly [module: string, specifier?: string];
|
|
103
|
-
type CatalogService = {
|
|
104
|
-
name: string;
|
|
105
|
-
apiKey: string;
|
|
106
|
-
};
|
|
107
|
-
type ExperimentalExtractorOptions = {
|
|
108
|
-
/**
|
|
109
|
-
* Entries to start extracting from.
|
|
110
|
-
* Each separate resolved entry would create a separate catalog.
|
|
111
|
-
*
|
|
112
|
-
* Example for MPA application like Next.js
|
|
113
|
-
* ```
|
|
114
|
-
* <rootDir>/pages/**\/*.ts
|
|
115
|
-
* <rootDir>/pages/**\/*.page.ts
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* With this config you would have a separate
|
|
119
|
-
* catalog for every page file in your app.
|
|
120
|
-
*/
|
|
121
|
-
entries: string[];
|
|
122
|
-
/**
|
|
123
|
-
* List of package name patterns to include for extraction.
|
|
124
|
-
*
|
|
125
|
-
* For example, to include all packages from your monorepo:
|
|
126
|
-
*
|
|
127
|
-
* ["@mycompany"]
|
|
128
|
-
*
|
|
129
|
-
* By default, all imports that look like package imports are ignored.
|
|
130
|
-
* This means imports that do not start with `/`, `./`, `../`, or `#`
|
|
131
|
-
* (used for subpath imports). TypeScript path aliases are also ignored
|
|
132
|
-
* because they look like package imports.
|
|
133
|
-
*
|
|
134
|
-
* Add here the packages you want to include.
|
|
135
|
-
*/
|
|
136
|
-
includeDeps?: string[];
|
|
137
|
-
/**
|
|
138
|
-
* svg, jpg and other files which might be imported in application should be excluded from analysis.
|
|
139
|
-
* By default, extractor provides a comprehensive list of extensions. If you feel like something
|
|
140
|
-
* is missing in this list please fill an issue on GitHub
|
|
141
|
-
*
|
|
142
|
-
* NOTE: changing this param will override default list of extensions.
|
|
143
|
-
*/
|
|
144
|
-
excludeExtensions?: string[];
|
|
145
|
-
/**
|
|
146
|
-
* output path for extracted catalogs.
|
|
147
|
-
*
|
|
148
|
-
* Supported placeholders for entry: /pages/about/index.page.ts
|
|
149
|
-
* - {entryName} = index.page
|
|
150
|
-
* - {locale} = en
|
|
151
|
-
* - {entryDir} = pages/about/
|
|
152
|
-
*
|
|
153
|
-
* Examples:
|
|
154
|
-
*
|
|
155
|
-
* ```
|
|
156
|
-
* <rootDir>/locales/{entryName}.{locale} -> /locales/index.page/en.po
|
|
157
|
-
* <rootDir>/{entryDir}/locales/{locale} -> /pages/about/locales/en.po
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
output: string;
|
|
161
|
-
resolveEsbuildOptions?: (options: any) => any;
|
|
162
|
-
};
|
|
163
|
-
type LinguiConfig = {
|
|
164
|
-
/**
|
|
165
|
-
* The catalogs configuration defines the location of message catalogs and specifies
|
|
166
|
-
* which files are included when the extract command scans for messages.
|
|
167
|
-
*
|
|
168
|
-
* https://lingui.dev/ref/conf#catalogs
|
|
169
|
-
*/
|
|
170
|
-
catalogs?: CatalogConfig[];
|
|
171
|
-
compileNamespace?: "es" | "ts" | "cjs" | string;
|
|
172
|
-
/**
|
|
173
|
-
* Specify additional options used to parse source files when extracting messages.
|
|
174
|
-
*/
|
|
175
|
-
extractorParserOptions?: {
|
|
176
|
-
/**
|
|
177
|
-
* default false
|
|
178
|
-
*
|
|
179
|
-
* By default, standard decorators (Stage3) are applied for TS files
|
|
180
|
-
* Enable this if you want to use TypesScript's experimental decorators.
|
|
181
|
-
*/
|
|
182
|
-
tsExperimentalDecorators?: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Enable if you use flow. This will apply Flow syntax to js files
|
|
185
|
-
*/
|
|
186
|
-
flow?: boolean;
|
|
187
|
-
};
|
|
188
|
-
compilerBabelOptions?: any;
|
|
189
|
-
fallbackLocales?: FallbackLocales | false;
|
|
190
|
-
/**
|
|
191
|
-
* Specifies custom message extractor implementations
|
|
192
|
-
*
|
|
193
|
-
* https://lingui.dev/guides/custom-extractor
|
|
194
|
-
*/
|
|
195
|
-
extractors?: ExtractorType[];
|
|
196
|
-
prevFormat?: CatalogFormat;
|
|
197
|
-
/**
|
|
198
|
-
* Message catalog format. The po formatter is used by default. Other formatters are available as separate packages.
|
|
199
|
-
*
|
|
200
|
-
* @default "po"
|
|
201
|
-
*/
|
|
202
|
-
format?: CatalogFormat | CatalogFormatter;
|
|
203
|
-
formatOptions?: CatalogFormatOptions;
|
|
204
|
-
/**
|
|
205
|
-
* The locale tags used in the project. The `extract` and `compile` commands write a catalog for each locale specified.
|
|
206
|
-
*
|
|
207
|
-
* Each locale should be a valid BCP-47 code:
|
|
208
|
-
* @example
|
|
209
|
-
*
|
|
210
|
-
* ```js
|
|
211
|
-
* locales: ["en", "cs"]
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
locales: string[];
|
|
215
|
-
/**
|
|
216
|
-
* Define the path where translated catalogs are merged into a single file per locale during the compile process.
|
|
217
|
-
*
|
|
218
|
-
* https://lingui.dev/ref/conf#catalogsmergepath
|
|
219
|
-
*/
|
|
220
|
-
catalogsMergePath?: string;
|
|
221
|
-
/**
|
|
222
|
-
* Order of messages in catalog
|
|
223
|
-
* You can choose one of: `"messageId" | "message" | "origin"`.
|
|
224
|
-
*
|
|
225
|
-
* - `messageId` — Sorts by the message key. Not recommended if you use the source
|
|
226
|
-
* message as the key, as `messageId` is autogenerated and may lead to
|
|
227
|
-
* unexpected results.
|
|
228
|
-
* - `message` — Sorts by the message text and its context. **Recommended**.
|
|
229
|
-
* Messages are ordered alphabetically.
|
|
230
|
-
* - `origin` — Sorts by the location where the message was first defined.
|
|
231
|
-
*
|
|
232
|
-
* You can also provide a custom sorting function. See {@link OrderByFn} for the function signature.
|
|
233
|
-
*
|
|
234
|
-
* @default "message"
|
|
235
|
-
*/
|
|
236
|
-
orderBy?: OrderBy;
|
|
237
|
-
/**
|
|
238
|
-
* Locale used for pseudolocalization. For example, when you set `pseudoLocale: "en"`, all messages in the en catalog will be pseudo-localized.
|
|
239
|
-
* The locale must be included in the locales config.
|
|
240
|
-
*
|
|
241
|
-
* https://lingui.dev/guides/pseudolocalization
|
|
242
|
-
*/
|
|
243
|
-
pseudoLocale?: string;
|
|
244
|
-
/**
|
|
245
|
-
* This is the directory where the Lingui CLI scans for messages in your source files during the extraction process.
|
|
246
|
-
*
|
|
247
|
-
* Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
|
|
248
|
-
*
|
|
249
|
-
* @default: The root of the directory containing your Lingui configuration file or the package.json.
|
|
250
|
-
*/
|
|
251
|
-
rootDir?: string;
|
|
252
|
-
/**
|
|
253
|
-
* This setting specifies the module path for the exported `i18n` object and `Trans` component.
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
*
|
|
257
|
-
* ```js
|
|
258
|
-
* {
|
|
259
|
-
* "runtimeConfigModule": {
|
|
260
|
-
* "Trans": ["./myTrans", "Trans"],
|
|
261
|
-
* "useLingui": ["./myUseLingui", "useLingui"]
|
|
262
|
-
* "i18n": ["./nyI18n", "I18n"]
|
|
263
|
-
* }
|
|
264
|
-
* }
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
|
|
268
|
-
/**
|
|
269
|
-
* Specifies the default language of message IDs in your source files.
|
|
270
|
-
*
|
|
271
|
-
* The catalog for sourceLocale doesn't need actual translations since message IDs are used as-is by default.
|
|
272
|
-
* However, you can still override any message ID by providing a custom translation.
|
|
273
|
-
*
|
|
274
|
-
* The main difference between `sourceLocale` and `fallbackLocales` is their purpose: `sourceLocale` defines the language used for message IDs,
|
|
275
|
-
* while `fallbackLocales` provides alternative translations when specific messages are missing for a particular locale.
|
|
276
|
-
*/
|
|
277
|
-
sourceLocale?: string;
|
|
278
|
-
service?: CatalogService;
|
|
279
|
-
/**
|
|
280
|
-
* Allow you to set macro options
|
|
281
|
-
*/
|
|
282
|
-
macro?: {
|
|
283
|
-
/**
|
|
284
|
-
* Allows customizing the Core Macro package name that the Lingui macro detects.
|
|
285
|
-
*
|
|
286
|
-
* ```ts
|
|
287
|
-
* // lingui.config
|
|
288
|
-
* {
|
|
289
|
-
* macro: {
|
|
290
|
-
* corePackage: ['@lingui/myMacro']
|
|
291
|
-
* }
|
|
292
|
-
* }
|
|
293
|
-
*
|
|
294
|
-
* // app.tsx
|
|
295
|
-
* import { msg } from '@lingui/myMacro'
|
|
296
|
-
*
|
|
297
|
-
* msg`Hello` // <-- would be correctly picked up by macro
|
|
298
|
-
* ```
|
|
299
|
-
*
|
|
300
|
-
* @default ["@lingui/macro", "@lingui/core/macro"]
|
|
301
|
-
*/
|
|
302
|
-
corePackage?: string[];
|
|
303
|
-
/**
|
|
304
|
-
* Allows customizing the JSX Macro package name that the Lingui macro detects.
|
|
305
|
-
*
|
|
306
|
-
* ```ts
|
|
307
|
-
* // lingui.config
|
|
308
|
-
* {
|
|
309
|
-
* macro: {
|
|
310
|
-
* jsxPackage: ["@lingui/myMacro"];
|
|
311
|
-
* }
|
|
312
|
-
* }
|
|
313
|
-
*
|
|
314
|
-
* // app.tsx
|
|
315
|
-
* import { Trans } from '@lingui/myMacro'
|
|
316
|
-
*
|
|
317
|
-
* <Trans>Hello</Trans> // <-- would be correctly picked up by macro
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @default ["@lingui/macro", "@lingui/react/macro"]
|
|
321
|
-
*/
|
|
322
|
-
jsxPackage?: string[];
|
|
323
|
-
};
|
|
324
|
-
experimental?: {
|
|
325
|
-
extractor?: ExperimentalExtractorOptions;
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
type ModuleSourceNormalized = readonly [module: string, specifier: string];
|
|
329
|
-
type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
330
|
-
resolvedConfigPath?: string;
|
|
331
|
-
fallbackLocales?: FallbackLocales;
|
|
332
|
-
runtimeConfigModule: {
|
|
333
|
-
i18n: ModuleSourceNormalized;
|
|
334
|
-
useLingui: ModuleSourceNormalized;
|
|
335
|
-
Trans: ModuleSourceNormalized;
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
|
|
340
|
-
skipValidation?: boolean;
|
|
341
|
-
resolvedConfigPath?: string;
|
|
342
|
-
}): LinguiConfigNormalized;
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Type helper for lingui.config.ts, returns {@link LinguiConfig} object
|
|
346
|
-
*/
|
|
347
|
-
declare function defineConfig(config: LinguiConfig): LinguiConfig;
|
|
348
|
-
|
|
349
|
-
declare function getConfig({ cwd, configPath, skipValidation, }?: {
|
|
350
|
-
cwd?: string;
|
|
351
|
-
configPath?: string;
|
|
352
|
-
skipValidation?: boolean;
|
|
353
|
-
}): LinguiConfigNormalized;
|
|
354
|
-
|
|
355
|
-
export { type CatalogConfig, type CatalogFormat, type CatalogFormatOptions, type CatalogFormatter, type CatalogType, type ExperimentalExtractorOptions, type ExtractedCatalogType, type ExtractedMessage, type ExtractedMessageType, type ExtractorCtx, type ExtractorType, type FallbackLocales, type LinguiConfig, type LinguiConfigNormalized, type MessageOrigin, type MessageType, type OrderBy, type OrderByFn, defineConfig, getConfig, makeConfig };
|