@lingui/conf 5.1.2 → 5.3.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.cjs CHANGED
@@ -271,17 +271,18 @@ function normalizeRuntimeConfigModule(config) {
271
271
  function makeConfig(userConfig, opts = {}) {
272
272
  let config = {
273
273
  ...defaultConfig,
274
- ...userConfig
274
+ ...userConfig,
275
+ macro: {
276
+ ...defaultConfig.macro,
277
+ ...userConfig.macro
278
+ }
275
279
  };
276
280
  if (!opts.skipValidation) {
277
281
  jestValidate.validate(config, configValidation);
278
282
  validateLocales(config);
279
283
  }
280
- config = pipe(
281
- // List config migrations from oldest to newest
282
- setCldrParentLocales,
283
- normalizeRuntimeConfigModule
284
- )(config);
284
+ config = setCldrParentLocales(config);
285
+ config = normalizeRuntimeConfigModule(config);
285
286
  return replaceRootDir(
286
287
  config,
287
288
  config.rootDir
@@ -315,6 +316,10 @@ const defaultConfig = {
315
316
  pseudoLocale: "",
316
317
  rootDir: ".",
317
318
  runtimeConfigModule: ["@lingui/core", "i18n"],
319
+ macro: {
320
+ corePackage: ["@lingui/macro", "@lingui/core/macro"],
321
+ jsxPackage: ["@lingui/macro", "@lingui/react/macro"]
322
+ },
318
323
  sourceLocale: "",
319
324
  service: { name: "", apiKey: "" }
320
325
  };
@@ -364,7 +369,6 @@ function validateLocales(config) {
364
369
  );
365
370
  }
366
371
  }
367
- const pipe = (...functions) => (args) => functions.reduce((arg, fn) => fn(arg), args);
368
372
 
369
373
  function defineConfig(config) {
370
374
  return config;
package/dist/index.d.cts CHANGED
@@ -154,8 +154,17 @@ type ExperimentalExtractorOptions = {
154
154
  resolveEsbuildOptions?: (options: any) => any;
155
155
  };
156
156
  type LinguiConfig = {
157
+ /**
158
+ * The catalogs configuration defines the location of message catalogs and specifies
159
+ * which files are included when the extract command scans for messages.
160
+ *
161
+ * https://lingui.dev/ref/conf#catalogs
162
+ */
157
163
  catalogs?: CatalogConfig[];
158
164
  compileNamespace?: "es" | "ts" | "cjs" | string;
165
+ /**
166
+ * Specify additional options used to parse source files when extracting messages.
167
+ */
159
168
  extractorParserOptions?: {
160
169
  /**
161
170
  * default false
@@ -171,19 +180,130 @@ type LinguiConfig = {
171
180
  };
172
181
  compilerBabelOptions?: any;
173
182
  fallbackLocales?: FallbackLocales | false;
183
+ /**
184
+ * Specifies custom message extractor implementations
185
+ *
186
+ * https://lingui.dev/guides/custom-extractor
187
+ */
174
188
  extractors?: ExtractorType[];
175
189
  prevFormat?: CatalogFormat;
176
- localeDir?: string;
190
+ /**
191
+ * Message catalog format. The po formatter is used by default. Other formatters are available as separate packages.
192
+ *
193
+ * @default "po"
194
+ */
177
195
  format?: CatalogFormat | CatalogFormatter;
178
196
  formatOptions?: CatalogFormatOptions;
197
+ /**
198
+ * The locale tags used in the project. The `extract` and `compile` commands write a catalog for each locale specified.
199
+ *
200
+ * Each locale should be a valid BCP-47 code:
201
+ * @example
202
+ *
203
+ * ```js
204
+ * locales: ["en", "cs"]
205
+ * ```
206
+ */
179
207
  locales: string[];
208
+ /**
209
+ * Define the path where translated catalogs are merged into a single file per locale during the compile process.
210
+ *
211
+ * https://lingui.dev/ref/conf#catalogsmergepath
212
+ */
180
213
  catalogsMergePath?: string;
214
+ /**
215
+ * Order of messages in catalog
216
+ *
217
+ * @default "message"
218
+ */
181
219
  orderBy?: OrderBy;
220
+ /**
221
+ * Locale used for pseudolocalization. For example, when you set `pseudoLocale: "en"`, all messages in the en catalog will be pseudo-localized.
222
+ * The locale must be included in the locales config.
223
+ *
224
+ * https://lingui.dev/guides/pseudolocalization
225
+ */
182
226
  pseudoLocale?: string;
227
+ /**
228
+ * This is the directory where the Lingui CLI scans for messages in your source files during the extraction process.
229
+ *
230
+ * Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
231
+ *
232
+ * @defaul: The root of the directory containing your Lingui configuration file or the package.json.
233
+ */
183
234
  rootDir?: string;
235
+ /**
236
+ * This setting specifies the module path for the exported `i18n` object and `Trans` component.
237
+ *
238
+ * @example
239
+ *
240
+ * ```js
241
+ * {
242
+ * "runtimeConfigModule": {
243
+ * "Trans": ["./myTrans", "Trans"],
244
+ * "useLingui": ["./myUseLingui", "useLingui"]
245
+ * "i18n": ["./nyI18n", "I18n"]
246
+ * }
247
+ * }
248
+ * ```
249
+ */
184
250
  runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
251
+ /**
252
+ * Specifies the default language of message IDs in your source files.
253
+ *
254
+ * The catalog for sourceLocale doesn't need actual translations since message IDs are used as-is by default.
255
+ * However, you can still override any message ID by providing a custom translation.
256
+ *
257
+ * The main difference between `sourceLocale` and `fallbackLocales` is their purpose: `sourceLocale` defines the language used for message IDs,
258
+ * while `fallbackLocales` provides alternative translations when specific messages are missing for a particular locale.
259
+ */
185
260
  sourceLocale?: string;
186
261
  service?: CatalogService;
262
+ /**
263
+ * Allow you to set macro options
264
+ */
265
+ macro?: {
266
+ /**
267
+ * Allows customizing the Core Macro package name that the Lingui macro detects.
268
+ *
269
+ * ```ts
270
+ * // lingui.config
271
+ * {
272
+ * macro: {
273
+ * corePackage: ['@lingui/myMacro']
274
+ * }
275
+ * }
276
+ *
277
+ * // app.tsx
278
+ * import { msg } from '@lingui/myMacro'
279
+ *
280
+ * msg`Hello` // <-- would be correctly picked up by macro
281
+ * ```
282
+ *
283
+ * @default ["@lingui/macro", "@lingui/core/macro"]
284
+ */
285
+ corePackage?: string[];
286
+ /**
287
+ * Allows customizing the JSX Macro package name that the Lingui macro detects.
288
+ *
289
+ * ```ts
290
+ * // lingui.config
291
+ * {
292
+ * macro: {
293
+ * jsxPackage: ["@lingui/myMacro"];
294
+ * }
295
+ * }
296
+ *
297
+ * // app.tsx
298
+ * import { Trans } from '@lingui/myMacro'
299
+ *
300
+ * <Trans>Hello</Trans> // <-- would be correctly picked up by macro
301
+ * ```
302
+ *
303
+ * @default ["@lingui/macro", "@lingui/react/macro"]
304
+ */
305
+ jsxPackage?: string[];
306
+ };
187
307
  experimental?: {
188
308
  extractor?: ExperimentalExtractorOptions;
189
309
  };
package/dist/index.d.mts CHANGED
@@ -154,8 +154,17 @@ type ExperimentalExtractorOptions = {
154
154
  resolveEsbuildOptions?: (options: any) => any;
155
155
  };
156
156
  type LinguiConfig = {
157
+ /**
158
+ * The catalogs configuration defines the location of message catalogs and specifies
159
+ * which files are included when the extract command scans for messages.
160
+ *
161
+ * https://lingui.dev/ref/conf#catalogs
162
+ */
157
163
  catalogs?: CatalogConfig[];
158
164
  compileNamespace?: "es" | "ts" | "cjs" | string;
165
+ /**
166
+ * Specify additional options used to parse source files when extracting messages.
167
+ */
159
168
  extractorParserOptions?: {
160
169
  /**
161
170
  * default false
@@ -171,19 +180,130 @@ type LinguiConfig = {
171
180
  };
172
181
  compilerBabelOptions?: any;
173
182
  fallbackLocales?: FallbackLocales | false;
183
+ /**
184
+ * Specifies custom message extractor implementations
185
+ *
186
+ * https://lingui.dev/guides/custom-extractor
187
+ */
174
188
  extractors?: ExtractorType[];
175
189
  prevFormat?: CatalogFormat;
176
- localeDir?: string;
190
+ /**
191
+ * Message catalog format. The po formatter is used by default. Other formatters are available as separate packages.
192
+ *
193
+ * @default "po"
194
+ */
177
195
  format?: CatalogFormat | CatalogFormatter;
178
196
  formatOptions?: CatalogFormatOptions;
197
+ /**
198
+ * The locale tags used in the project. The `extract` and `compile` commands write a catalog for each locale specified.
199
+ *
200
+ * Each locale should be a valid BCP-47 code:
201
+ * @example
202
+ *
203
+ * ```js
204
+ * locales: ["en", "cs"]
205
+ * ```
206
+ */
179
207
  locales: string[];
208
+ /**
209
+ * Define the path where translated catalogs are merged into a single file per locale during the compile process.
210
+ *
211
+ * https://lingui.dev/ref/conf#catalogsmergepath
212
+ */
180
213
  catalogsMergePath?: string;
214
+ /**
215
+ * Order of messages in catalog
216
+ *
217
+ * @default "message"
218
+ */
181
219
  orderBy?: OrderBy;
220
+ /**
221
+ * Locale used for pseudolocalization. For example, when you set `pseudoLocale: "en"`, all messages in the en catalog will be pseudo-localized.
222
+ * The locale must be included in the locales config.
223
+ *
224
+ * https://lingui.dev/guides/pseudolocalization
225
+ */
182
226
  pseudoLocale?: string;
227
+ /**
228
+ * This is the directory where the Lingui CLI scans for messages in your source files during the extraction process.
229
+ *
230
+ * Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
231
+ *
232
+ * @defaul: The root of the directory containing your Lingui configuration file or the package.json.
233
+ */
183
234
  rootDir?: string;
235
+ /**
236
+ * This setting specifies the module path for the exported `i18n` object and `Trans` component.
237
+ *
238
+ * @example
239
+ *
240
+ * ```js
241
+ * {
242
+ * "runtimeConfigModule": {
243
+ * "Trans": ["./myTrans", "Trans"],
244
+ * "useLingui": ["./myUseLingui", "useLingui"]
245
+ * "i18n": ["./nyI18n", "I18n"]
246
+ * }
247
+ * }
248
+ * ```
249
+ */
184
250
  runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
251
+ /**
252
+ * Specifies the default language of message IDs in your source files.
253
+ *
254
+ * The catalog for sourceLocale doesn't need actual translations since message IDs are used as-is by default.
255
+ * However, you can still override any message ID by providing a custom translation.
256
+ *
257
+ * The main difference between `sourceLocale` and `fallbackLocales` is their purpose: `sourceLocale` defines the language used for message IDs,
258
+ * while `fallbackLocales` provides alternative translations when specific messages are missing for a particular locale.
259
+ */
185
260
  sourceLocale?: string;
186
261
  service?: CatalogService;
262
+ /**
263
+ * Allow you to set macro options
264
+ */
265
+ macro?: {
266
+ /**
267
+ * Allows customizing the Core Macro package name that the Lingui macro detects.
268
+ *
269
+ * ```ts
270
+ * // lingui.config
271
+ * {
272
+ * macro: {
273
+ * corePackage: ['@lingui/myMacro']
274
+ * }
275
+ * }
276
+ *
277
+ * // app.tsx
278
+ * import { msg } from '@lingui/myMacro'
279
+ *
280
+ * msg`Hello` // <-- would be correctly picked up by macro
281
+ * ```
282
+ *
283
+ * @default ["@lingui/macro", "@lingui/core/macro"]
284
+ */
285
+ corePackage?: string[];
286
+ /**
287
+ * Allows customizing the JSX Macro package name that the Lingui macro detects.
288
+ *
289
+ * ```ts
290
+ * // lingui.config
291
+ * {
292
+ * macro: {
293
+ * jsxPackage: ["@lingui/myMacro"];
294
+ * }
295
+ * }
296
+ *
297
+ * // app.tsx
298
+ * import { Trans } from '@lingui/myMacro'
299
+ *
300
+ * <Trans>Hello</Trans> // <-- would be correctly picked up by macro
301
+ * ```
302
+ *
303
+ * @default ["@lingui/macro", "@lingui/react/macro"]
304
+ */
305
+ jsxPackage?: string[];
306
+ };
187
307
  experimental?: {
188
308
  extractor?: ExperimentalExtractorOptions;
189
309
  };
package/dist/index.d.ts CHANGED
@@ -154,8 +154,17 @@ type ExperimentalExtractorOptions = {
154
154
  resolveEsbuildOptions?: (options: any) => any;
155
155
  };
156
156
  type LinguiConfig = {
157
+ /**
158
+ * The catalogs configuration defines the location of message catalogs and specifies
159
+ * which files are included when the extract command scans for messages.
160
+ *
161
+ * https://lingui.dev/ref/conf#catalogs
162
+ */
157
163
  catalogs?: CatalogConfig[];
158
164
  compileNamespace?: "es" | "ts" | "cjs" | string;
165
+ /**
166
+ * Specify additional options used to parse source files when extracting messages.
167
+ */
159
168
  extractorParserOptions?: {
160
169
  /**
161
170
  * default false
@@ -171,19 +180,130 @@ type LinguiConfig = {
171
180
  };
172
181
  compilerBabelOptions?: any;
173
182
  fallbackLocales?: FallbackLocales | false;
183
+ /**
184
+ * Specifies custom message extractor implementations
185
+ *
186
+ * https://lingui.dev/guides/custom-extractor
187
+ */
174
188
  extractors?: ExtractorType[];
175
189
  prevFormat?: CatalogFormat;
176
- localeDir?: string;
190
+ /**
191
+ * Message catalog format. The po formatter is used by default. Other formatters are available as separate packages.
192
+ *
193
+ * @default "po"
194
+ */
177
195
  format?: CatalogFormat | CatalogFormatter;
178
196
  formatOptions?: CatalogFormatOptions;
197
+ /**
198
+ * The locale tags used in the project. The `extract` and `compile` commands write a catalog for each locale specified.
199
+ *
200
+ * Each locale should be a valid BCP-47 code:
201
+ * @example
202
+ *
203
+ * ```js
204
+ * locales: ["en", "cs"]
205
+ * ```
206
+ */
179
207
  locales: string[];
208
+ /**
209
+ * Define the path where translated catalogs are merged into a single file per locale during the compile process.
210
+ *
211
+ * https://lingui.dev/ref/conf#catalogsmergepath
212
+ */
180
213
  catalogsMergePath?: string;
214
+ /**
215
+ * Order of messages in catalog
216
+ *
217
+ * @default "message"
218
+ */
181
219
  orderBy?: OrderBy;
220
+ /**
221
+ * Locale used for pseudolocalization. For example, when you set `pseudoLocale: "en"`, all messages in the en catalog will be pseudo-localized.
222
+ * The locale must be included in the locales config.
223
+ *
224
+ * https://lingui.dev/guides/pseudolocalization
225
+ */
182
226
  pseudoLocale?: string;
227
+ /**
228
+ * This is the directory where the Lingui CLI scans for messages in your source files during the extraction process.
229
+ *
230
+ * Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
231
+ *
232
+ * @defaul: The root of the directory containing your Lingui configuration file or the package.json.
233
+ */
183
234
  rootDir?: string;
235
+ /**
236
+ * This setting specifies the module path for the exported `i18n` object and `Trans` component.
237
+ *
238
+ * @example
239
+ *
240
+ * ```js
241
+ * {
242
+ * "runtimeConfigModule": {
243
+ * "Trans": ["./myTrans", "Trans"],
244
+ * "useLingui": ["./myUseLingui", "useLingui"]
245
+ * "i18n": ["./nyI18n", "I18n"]
246
+ * }
247
+ * }
248
+ * ```
249
+ */
184
250
  runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
251
+ /**
252
+ * Specifies the default language of message IDs in your source files.
253
+ *
254
+ * The catalog for sourceLocale doesn't need actual translations since message IDs are used as-is by default.
255
+ * However, you can still override any message ID by providing a custom translation.
256
+ *
257
+ * The main difference between `sourceLocale` and `fallbackLocales` is their purpose: `sourceLocale` defines the language used for message IDs,
258
+ * while `fallbackLocales` provides alternative translations when specific messages are missing for a particular locale.
259
+ */
185
260
  sourceLocale?: string;
186
261
  service?: CatalogService;
262
+ /**
263
+ * Allow you to set macro options
264
+ */
265
+ macro?: {
266
+ /**
267
+ * Allows customizing the Core Macro package name that the Lingui macro detects.
268
+ *
269
+ * ```ts
270
+ * // lingui.config
271
+ * {
272
+ * macro: {
273
+ * corePackage: ['@lingui/myMacro']
274
+ * }
275
+ * }
276
+ *
277
+ * // app.tsx
278
+ * import { msg } from '@lingui/myMacro'
279
+ *
280
+ * msg`Hello` // <-- would be correctly picked up by macro
281
+ * ```
282
+ *
283
+ * @default ["@lingui/macro", "@lingui/core/macro"]
284
+ */
285
+ corePackage?: string[];
286
+ /**
287
+ * Allows customizing the JSX Macro package name that the Lingui macro detects.
288
+ *
289
+ * ```ts
290
+ * // lingui.config
291
+ * {
292
+ * macro: {
293
+ * jsxPackage: ["@lingui/myMacro"];
294
+ * }
295
+ * }
296
+ *
297
+ * // app.tsx
298
+ * import { Trans } from '@lingui/myMacro'
299
+ *
300
+ * <Trans>Hello</Trans> // <-- would be correctly picked up by macro
301
+ * ```
302
+ *
303
+ * @default ["@lingui/macro", "@lingui/react/macro"]
304
+ */
305
+ jsxPackage?: string[];
306
+ };
187
307
  experimental?: {
188
308
  extractor?: ExperimentalExtractorOptions;
189
309
  };
package/dist/index.mjs CHANGED
@@ -263,17 +263,18 @@ function normalizeRuntimeConfigModule(config) {
263
263
  function makeConfig(userConfig, opts = {}) {
264
264
  let config = {
265
265
  ...defaultConfig,
266
- ...userConfig
266
+ ...userConfig,
267
+ macro: {
268
+ ...defaultConfig.macro,
269
+ ...userConfig.macro
270
+ }
267
271
  };
268
272
  if (!opts.skipValidation) {
269
273
  validate(config, configValidation);
270
274
  validateLocales(config);
271
275
  }
272
- config = pipe(
273
- // List config migrations from oldest to newest
274
- setCldrParentLocales,
275
- normalizeRuntimeConfigModule
276
- )(config);
276
+ config = setCldrParentLocales(config);
277
+ config = normalizeRuntimeConfigModule(config);
277
278
  return replaceRootDir(
278
279
  config,
279
280
  config.rootDir
@@ -307,6 +308,10 @@ const defaultConfig = {
307
308
  pseudoLocale: "",
308
309
  rootDir: ".",
309
310
  runtimeConfigModule: ["@lingui/core", "i18n"],
311
+ macro: {
312
+ corePackage: ["@lingui/macro", "@lingui/core/macro"],
313
+ jsxPackage: ["@lingui/macro", "@lingui/react/macro"]
314
+ },
310
315
  sourceLocale: "",
311
316
  service: { name: "", apiKey: "" }
312
317
  };
@@ -356,7 +361,6 @@ function validateLocales(config) {
356
361
  );
357
362
  }
358
363
  }
359
- const pipe = (...functions) => (args) => functions.reduce((arg, fn) => fn(arg), args);
360
364
 
361
365
  function defineConfig(config) {
362
366
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/conf",
3
- "version": "5.1.2",
3
+ "version": "5.3.0",
4
4
  "sideEffects": false,
5
5
  "description": "Get lingui configuration from package.json",
6
6
  "keywords": [
@@ -38,9 +38,9 @@
38
38
  "/dist"
39
39
  ],
40
40
  "devDependencies": {
41
- "@lingui/jest-mocks": "^3.0.3",
41
+ "@lingui/jest-mocks": "*",
42
42
  "tsd": "^0.26.1",
43
43
  "unbuild": "^2.0.0"
44
44
  },
45
- "gitHead": "e45a2af5dfc1c88131fa8196d596e0f0f25678ea"
45
+ "gitHead": "ed491cce7e5209378922327e0e7b802fb7b5873d"
46
46
  }