@lingui/conf 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/dist/index.cjs CHANGED
@@ -242,24 +242,28 @@ const getSymbolSource = (defaults, config) => {
242
242
  }
243
243
  return defaults;
244
244
  }
245
- return config[name] || defaults;
245
+ const override = config[name];
246
+ if (!override) {
247
+ return defaults;
248
+ }
249
+ return [override[0], override[1] || name];
246
250
  };
247
251
  function normalizeRuntimeConfigModule(config) {
248
- const [i18nImportModule, i18nImportName] = getSymbolSource(
249
- ["@lingui/core", "i18n"],
250
- config.runtimeConfigModule
251
- );
252
- const [TransImportModule, TransImportName] = getSymbolSource(
253
- ["@lingui/react", "Trans"],
254
- config.runtimeConfigModule
255
- );
256
252
  return {
257
253
  ...config,
258
254
  runtimeConfigModule: {
259
- i18nImportModule,
260
- i18nImportName,
261
- TransImportModule,
262
- TransImportName
255
+ i18n: getSymbolSource(
256
+ ["@lingui/core", "i18n"],
257
+ config.runtimeConfigModule
258
+ ),
259
+ useLingui: getSymbolSource(
260
+ ["@lingui/react", "useLingui"],
261
+ config.runtimeConfigModule
262
+ ),
263
+ Trans: getSymbolSource(
264
+ ["@lingui/react", "Trans"],
265
+ config.runtimeConfigModule
266
+ )
263
267
  }
264
268
  };
265
269
  }
package/dist/index.d.cts CHANGED
@@ -34,6 +34,7 @@ type ExtractedMessageType<Extra = CatalogExtra> = {
34
34
  * formatters can store additional data
35
35
  */
36
36
  extra?: Extra;
37
+ placeholders?: Record<string, string[]>;
37
38
  };
38
39
  type MessageType<Extra = CatalogExtra> = ExtractedMessageType<Extra> & {
39
40
  translation: string;
@@ -73,6 +74,7 @@ type ExtractedMessage = {
73
74
  context?: string;
74
75
  origin?: [filename: string, line: number, column?: number];
75
76
  comment?: string;
77
+ placeholders?: Record<string, string>;
76
78
  };
77
79
  type CatalogFormatOptions = {
78
80
  origins?: boolean;
@@ -91,7 +93,7 @@ type LocaleObject = {
91
93
  default?: string;
92
94
  };
93
95
  type FallbackLocales = LocaleObject;
94
- type ModuleSource = [string, string?];
96
+ type ModuleSource = readonly [module: string, specifier?: string];
95
97
  type CatalogService = {
96
98
  name: string;
97
99
  apiKey: string;
@@ -179,22 +181,20 @@ type LinguiConfig = {
179
181
  orderBy?: OrderBy;
180
182
  pseudoLocale?: string;
181
183
  rootDir?: string;
182
- runtimeConfigModule?: ModuleSource | {
183
- [symbolName: string]: ModuleSource;
184
- };
184
+ runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
185
185
  sourceLocale?: string;
186
186
  service?: CatalogService;
187
187
  experimental?: {
188
188
  extractor?: ExperimentalExtractorOptions;
189
189
  };
190
190
  };
191
+ type ModuleSourceNormalized = readonly [module: string, specifier: string];
191
192
  type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
192
193
  fallbackLocales?: FallbackLocales;
193
194
  runtimeConfigModule: {
194
- i18nImportModule: string;
195
- i18nImportName: string;
196
- TransImportModule: string;
197
- TransImportName: string;
195
+ i18n: ModuleSourceNormalized;
196
+ useLingui: ModuleSourceNormalized;
197
+ Trans: ModuleSourceNormalized;
198
198
  };
199
199
  };
200
200
 
package/dist/index.d.mts CHANGED
@@ -34,6 +34,7 @@ type ExtractedMessageType<Extra = CatalogExtra> = {
34
34
  * formatters can store additional data
35
35
  */
36
36
  extra?: Extra;
37
+ placeholders?: Record<string, string[]>;
37
38
  };
38
39
  type MessageType<Extra = CatalogExtra> = ExtractedMessageType<Extra> & {
39
40
  translation: string;
@@ -73,6 +74,7 @@ type ExtractedMessage = {
73
74
  context?: string;
74
75
  origin?: [filename: string, line: number, column?: number];
75
76
  comment?: string;
77
+ placeholders?: Record<string, string>;
76
78
  };
77
79
  type CatalogFormatOptions = {
78
80
  origins?: boolean;
@@ -91,7 +93,7 @@ type LocaleObject = {
91
93
  default?: string;
92
94
  };
93
95
  type FallbackLocales = LocaleObject;
94
- type ModuleSource = [string, string?];
96
+ type ModuleSource = readonly [module: string, specifier?: string];
95
97
  type CatalogService = {
96
98
  name: string;
97
99
  apiKey: string;
@@ -179,22 +181,20 @@ type LinguiConfig = {
179
181
  orderBy?: OrderBy;
180
182
  pseudoLocale?: string;
181
183
  rootDir?: string;
182
- runtimeConfigModule?: ModuleSource | {
183
- [symbolName: string]: ModuleSource;
184
- };
184
+ runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
185
185
  sourceLocale?: string;
186
186
  service?: CatalogService;
187
187
  experimental?: {
188
188
  extractor?: ExperimentalExtractorOptions;
189
189
  };
190
190
  };
191
+ type ModuleSourceNormalized = readonly [module: string, specifier: string];
191
192
  type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
192
193
  fallbackLocales?: FallbackLocales;
193
194
  runtimeConfigModule: {
194
- i18nImportModule: string;
195
- i18nImportName: string;
196
- TransImportModule: string;
197
- TransImportName: string;
195
+ i18n: ModuleSourceNormalized;
196
+ useLingui: ModuleSourceNormalized;
197
+ Trans: ModuleSourceNormalized;
198
198
  };
199
199
  };
200
200
 
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ type ExtractedMessageType<Extra = CatalogExtra> = {
34
34
  * formatters can store additional data
35
35
  */
36
36
  extra?: Extra;
37
+ placeholders?: Record<string, string[]>;
37
38
  };
38
39
  type MessageType<Extra = CatalogExtra> = ExtractedMessageType<Extra> & {
39
40
  translation: string;
@@ -73,6 +74,7 @@ type ExtractedMessage = {
73
74
  context?: string;
74
75
  origin?: [filename: string, line: number, column?: number];
75
76
  comment?: string;
77
+ placeholders?: Record<string, string>;
76
78
  };
77
79
  type CatalogFormatOptions = {
78
80
  origins?: boolean;
@@ -91,7 +93,7 @@ type LocaleObject = {
91
93
  default?: string;
92
94
  };
93
95
  type FallbackLocales = LocaleObject;
94
- type ModuleSource = [string, string?];
96
+ type ModuleSource = readonly [module: string, specifier?: string];
95
97
  type CatalogService = {
96
98
  name: string;
97
99
  apiKey: string;
@@ -179,22 +181,20 @@ type LinguiConfig = {
179
181
  orderBy?: OrderBy;
180
182
  pseudoLocale?: string;
181
183
  rootDir?: string;
182
- runtimeConfigModule?: ModuleSource | {
183
- [symbolName: string]: ModuleSource;
184
- };
184
+ runtimeConfigModule?: ModuleSource | Partial<Record<"useLingui" | "Trans" | "i18n", ModuleSource>>;
185
185
  sourceLocale?: string;
186
186
  service?: CatalogService;
187
187
  experimental?: {
188
188
  extractor?: ExperimentalExtractorOptions;
189
189
  };
190
190
  };
191
+ type ModuleSourceNormalized = readonly [module: string, specifier: string];
191
192
  type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
192
193
  fallbackLocales?: FallbackLocales;
193
194
  runtimeConfigModule: {
194
- i18nImportModule: string;
195
- i18nImportName: string;
196
- TransImportModule: string;
197
- TransImportName: string;
195
+ i18n: ModuleSourceNormalized;
196
+ useLingui: ModuleSourceNormalized;
197
+ Trans: ModuleSourceNormalized;
198
198
  };
199
199
  };
200
200
 
package/dist/index.mjs CHANGED
@@ -234,24 +234,28 @@ const getSymbolSource = (defaults, config) => {
234
234
  }
235
235
  return defaults;
236
236
  }
237
- return config[name] || defaults;
237
+ const override = config[name];
238
+ if (!override) {
239
+ return defaults;
240
+ }
241
+ return [override[0], override[1] || name];
238
242
  };
239
243
  function normalizeRuntimeConfigModule(config) {
240
- const [i18nImportModule, i18nImportName] = getSymbolSource(
241
- ["@lingui/core", "i18n"],
242
- config.runtimeConfigModule
243
- );
244
- const [TransImportModule, TransImportName] = getSymbolSource(
245
- ["@lingui/react", "Trans"],
246
- config.runtimeConfigModule
247
- );
248
244
  return {
249
245
  ...config,
250
246
  runtimeConfigModule: {
251
- i18nImportModule,
252
- i18nImportName,
253
- TransImportModule,
254
- TransImportName
247
+ i18n: getSymbolSource(
248
+ ["@lingui/core", "i18n"],
249
+ config.runtimeConfigModule
250
+ ),
251
+ useLingui: getSymbolSource(
252
+ ["@lingui/react", "useLingui"],
253
+ config.runtimeConfigModule
254
+ ),
255
+ Trans: getSymbolSource(
256
+ ["@lingui/react", "Trans"],
257
+ config.runtimeConfigModule
258
+ )
255
259
  }
256
260
  };
257
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/conf",
3
- "version": "4.11.2",
3
+ "version": "5.0.0-next.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": "*",
41
+ "@lingui/jest-mocks": "^3.0.3",
42
42
  "tsd": "^0.26.1",
43
43
  "unbuild": "^2.0.0"
44
44
  },
45
- "gitHead": "17e0af54b0b9d9577db2cef1be680a6d871611e7"
45
+ "gitHead": "2192f8d54699a3846ff8fe6f3992697be2da68a8"
46
46
  }