i18next-cli 1.42.11 → 1.42.12

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/cjs/cli.js CHANGED
@@ -28,7 +28,7 @@ const program = new commander.Command();
28
28
  program
29
29
  .name('i18next-cli')
30
30
  .description('A unified, high-performance i18next CLI.')
31
- .version('1.42.11'); // This string is replaced with the actual version at build time by rollup
31
+ .version('1.42.12'); // This string is replaced with the actual version at build time by rollup
32
32
  // new: global config override option
33
33
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
34
34
  program
@@ -161,16 +161,23 @@ function isSimpleTemplateLiteral(literal) {
161
161
  *
162
162
  * @param object - Object expression to search
163
163
  * @param propName - Property name to find
164
+ * @param identifierResolver - callback to resolve Identifier type values when needed
164
165
  * @returns String value if found, empty string if property exists but isn't a string, undefined if not found
165
166
  *
166
167
  * @private
167
168
  */
168
- function getObjectPropValue(object, propName) {
169
+ function getObjectPropValue(object, propName, identifierResolver) {
169
170
  const prop = getObjectProperty(object, propName);
170
171
  if (prop?.type === 'KeyValueProperty') {
171
172
  const val = prop.value;
172
173
  if (val.type === 'StringLiteral')
173
174
  return val.value;
175
+ if (val.type === 'Identifier') {
176
+ if (identifierResolver) {
177
+ return identifierResolver(val.value);
178
+ }
179
+ return '';
180
+ }
174
181
  if (val.type === 'TemplateLiteral' && isSimpleTemplateLiteral(val))
175
182
  return val.quasis[0].cooked;
176
183
  if (val.type === 'BooleanLiteral')
@@ -322,14 +322,10 @@ class ScopeManager {
322
322
  kpArg = kpArgIndex === -1 ? undefined : callExpr.arguments?.[kpArgIndex]?.expression;
323
323
  }
324
324
  if (kpArg?.type === 'ObjectExpression') {
325
- const kp = astUtils.getObjectPropValue(kpArg, 'keyPrefix');
325
+ const kp = astUtils.getObjectPropValue(kpArg, 'keyPrefix', this.resolveSimpleStringIdentifier.bind(this));
326
326
  if (typeof kp === 'string') {
327
327
  keyPrefix = kp;
328
328
  }
329
- else if (kp && typeof kp === 'object' && kp.type === 'Identifier') {
330
- // ← FIX B: resolve { keyPrefix: I18N_PREFIX } where the value is an Identifier
331
- keyPrefix = this.resolveSimpleStringIdentifier(kp.value);
332
- }
333
329
  }
334
330
  else if (kpArg?.type === 'StringLiteral') {
335
331
  keyPrefix = kpArg.value;
package/dist/esm/cli.js CHANGED
@@ -26,7 +26,7 @@ const program = new Command();
26
26
  program
27
27
  .name('i18next-cli')
28
28
  .description('A unified, high-performance i18next CLI.')
29
- .version('1.42.11'); // This string is replaced with the actual version at build time by rollup
29
+ .version('1.42.12'); // This string is replaced with the actual version at build time by rollup
30
30
  // new: global config override option
31
31
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
32
32
  program
@@ -159,16 +159,23 @@ function isSimpleTemplateLiteral(literal) {
159
159
  *
160
160
  * @param object - Object expression to search
161
161
  * @param propName - Property name to find
162
+ * @param identifierResolver - callback to resolve Identifier type values when needed
162
163
  * @returns String value if found, empty string if property exists but isn't a string, undefined if not found
163
164
  *
164
165
  * @private
165
166
  */
166
- function getObjectPropValue(object, propName) {
167
+ function getObjectPropValue(object, propName, identifierResolver) {
167
168
  const prop = getObjectProperty(object, propName);
168
169
  if (prop?.type === 'KeyValueProperty') {
169
170
  const val = prop.value;
170
171
  if (val.type === 'StringLiteral')
171
172
  return val.value;
173
+ if (val.type === 'Identifier') {
174
+ if (identifierResolver) {
175
+ return identifierResolver(val.value);
176
+ }
177
+ return '';
178
+ }
172
179
  if (val.type === 'TemplateLiteral' && isSimpleTemplateLiteral(val))
173
180
  return val.quasis[0].cooked;
174
181
  if (val.type === 'BooleanLiteral')
@@ -320,14 +320,10 @@ class ScopeManager {
320
320
  kpArg = kpArgIndex === -1 ? undefined : callExpr.arguments?.[kpArgIndex]?.expression;
321
321
  }
322
322
  if (kpArg?.type === 'ObjectExpression') {
323
- const kp = getObjectPropValue(kpArg, 'keyPrefix');
323
+ const kp = getObjectPropValue(kpArg, 'keyPrefix', this.resolveSimpleStringIdentifier.bind(this));
324
324
  if (typeof kp === 'string') {
325
325
  keyPrefix = kp;
326
326
  }
327
- else if (kp && typeof kp === 'object' && kp.type === 'Identifier') {
328
- // ← FIX B: resolve { keyPrefix: I18N_PREFIX } where the value is an Identifier
329
- keyPrefix = this.resolveSimpleStringIdentifier(kp.value);
330
- }
331
327
  }
332
328
  else if (kpArg?.type === 'StringLiteral') {
333
329
  keyPrefix = kpArg.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.42.11",
3
+ "version": "1.42.12",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -76,6 +76,7 @@ export declare function getObjectPropValueExpression(object: ObjectExpression, p
76
76
  * @private
77
77
  */
78
78
  export declare function isSimpleTemplateLiteral(literal: TemplateLiteral): boolean;
79
+ type IdentifierResolver = (name: string) => string | boolean | number | undefined;
79
80
  /**
80
81
  * Extracts string value from object property.
81
82
  *
@@ -84,9 +85,11 @@ export declare function isSimpleTemplateLiteral(literal: TemplateLiteral): boole
84
85
  *
85
86
  * @param object - Object expression to search
86
87
  * @param propName - Property name to find
88
+ * @param identifierResolver - callback to resolve Identifier type values when needed
87
89
  * @returns String value if found, empty string if property exists but isn't a string, undefined if not found
88
90
  *
89
91
  * @private
90
92
  */
91
- export declare function getObjectPropValue(object: ObjectExpression, propName: string): string | boolean | number | undefined;
93
+ export declare function getObjectPropValue(object: ObjectExpression, propName: string, identifierResolver?: IdentifierResolver): string | boolean | number | undefined;
94
+ export {};
92
95
  //# sourceMappingURL=ast-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAc,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE1F;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB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