i18next-cli 1.37.0 → 1.37.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/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.37.0'); // This string is replaced with the actual version at build time by rollup
31
+ .version('1.37.1'); // 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
@@ -268,35 +268,6 @@ class ScopeManager {
268
268
  * @param hookConfig - Configuration describing argument positions for namespace and keyPrefix
269
269
  */
270
270
  handleUseTranslationDeclarator(node, callExpr, hookConfig) {
271
- let variableName;
272
- // Handle simple assignment: let t = useTranslation()
273
- if (node.id.type === 'Identifier') {
274
- variableName = node.id.value;
275
- }
276
- // Handle array destructuring: const [t, i18n] = useTranslation()
277
- if (node.id.type === 'ArrayPattern') {
278
- const firstElement = node.id.elements[0];
279
- if (firstElement?.type === 'Identifier') {
280
- variableName = firstElement.value;
281
- }
282
- }
283
- // Handle object destructuring: const { t } or { t: t1 } = useTranslation()
284
- if (node.id.type === 'ObjectPattern') {
285
- for (const prop of node.id.properties) {
286
- // Also consider getFixedT so scope info is attached to that identifier
287
- if (prop.type === 'AssignmentPatternProperty' && prop.key.type === 'Identifier' && (prop.key.value === 't' || prop.key.value === 'getFixedT')) {
288
- variableName = prop.key.value;
289
- break;
290
- }
291
- if (prop.type === 'KeyValuePatternProperty' && prop.key.type === 'Identifier' && (prop.key.value === 't' || prop.key.value === 'getFixedT') && prop.value.type === 'Identifier') {
292
- variableName = prop.value.value;
293
- break;
294
- }
295
- }
296
- }
297
- // If we couldn't find a `t` function being declared, exit
298
- if (!variableName)
299
- return;
300
271
  // Position-driven extraction: respect hookConfig positions (nsArg/keyPrefixArg).
301
272
  const nsArgIndex = hookConfig.nsArg ?? 0;
302
273
  const kpArgIndex = hookConfig.keyPrefixArg ?? 1;
@@ -343,8 +314,26 @@ class ScopeManager {
343
314
  keyPrefix = tpl.quasis?.[0]?.cooked ?? undefined;
344
315
  }
345
316
  }
346
- // Store the scope info for the declared variable
347
- this.setVarInScope(variableName, { defaultNs, keyPrefix });
317
+ // Attach scope info to all destructured properties (custom functions, t, getFixedT, etc.)
318
+ if (node.id.type === 'ObjectPattern') {
319
+ for (const prop of node.id.properties) {
320
+ if (prop.type === 'AssignmentPatternProperty' && prop.key.type === 'Identifier') {
321
+ this.setVarInScope(prop.key.value, { defaultNs, keyPrefix });
322
+ }
323
+ if (prop.type === 'KeyValuePatternProperty' && prop.value.type === 'Identifier') {
324
+ this.setVarInScope(prop.value.value, { defaultNs, keyPrefix });
325
+ }
326
+ }
327
+ }
328
+ else if (node.id.type === 'Identifier') {
329
+ this.setVarInScope(node.id.value, { defaultNs, keyPrefix });
330
+ }
331
+ else if (node.id.type === 'ArrayPattern') {
332
+ const firstElement = node.id.elements[0];
333
+ if (firstElement?.type === 'Identifier') {
334
+ this.setVarInScope(firstElement.value, { defaultNs, keyPrefix });
335
+ }
336
+ }
348
337
  }
349
338
  /**
350
339
  * Processes getFixedT function declarations to extract scope information.
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.37.0'); // This string is replaced with the actual version at build time by rollup
29
+ .version('1.37.1'); // 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
@@ -266,35 +266,6 @@ class ScopeManager {
266
266
  * @param hookConfig - Configuration describing argument positions for namespace and keyPrefix
267
267
  */
268
268
  handleUseTranslationDeclarator(node, callExpr, hookConfig) {
269
- let variableName;
270
- // Handle simple assignment: let t = useTranslation()
271
- if (node.id.type === 'Identifier') {
272
- variableName = node.id.value;
273
- }
274
- // Handle array destructuring: const [t, i18n] = useTranslation()
275
- if (node.id.type === 'ArrayPattern') {
276
- const firstElement = node.id.elements[0];
277
- if (firstElement?.type === 'Identifier') {
278
- variableName = firstElement.value;
279
- }
280
- }
281
- // Handle object destructuring: const { t } or { t: t1 } = useTranslation()
282
- if (node.id.type === 'ObjectPattern') {
283
- for (const prop of node.id.properties) {
284
- // Also consider getFixedT so scope info is attached to that identifier
285
- if (prop.type === 'AssignmentPatternProperty' && prop.key.type === 'Identifier' && (prop.key.value === 't' || prop.key.value === 'getFixedT')) {
286
- variableName = prop.key.value;
287
- break;
288
- }
289
- if (prop.type === 'KeyValuePatternProperty' && prop.key.type === 'Identifier' && (prop.key.value === 't' || prop.key.value === 'getFixedT') && prop.value.type === 'Identifier') {
290
- variableName = prop.value.value;
291
- break;
292
- }
293
- }
294
- }
295
- // If we couldn't find a `t` function being declared, exit
296
- if (!variableName)
297
- return;
298
269
  // Position-driven extraction: respect hookConfig positions (nsArg/keyPrefixArg).
299
270
  const nsArgIndex = hookConfig.nsArg ?? 0;
300
271
  const kpArgIndex = hookConfig.keyPrefixArg ?? 1;
@@ -341,8 +312,26 @@ class ScopeManager {
341
312
  keyPrefix = tpl.quasis?.[0]?.cooked ?? undefined;
342
313
  }
343
314
  }
344
- // Store the scope info for the declared variable
345
- this.setVarInScope(variableName, { defaultNs, keyPrefix });
315
+ // Attach scope info to all destructured properties (custom functions, t, getFixedT, etc.)
316
+ if (node.id.type === 'ObjectPattern') {
317
+ for (const prop of node.id.properties) {
318
+ if (prop.type === 'AssignmentPatternProperty' && prop.key.type === 'Identifier') {
319
+ this.setVarInScope(prop.key.value, { defaultNs, keyPrefix });
320
+ }
321
+ if (prop.type === 'KeyValuePatternProperty' && prop.value.type === 'Identifier') {
322
+ this.setVarInScope(prop.value.value, { defaultNs, keyPrefix });
323
+ }
324
+ }
325
+ }
326
+ else if (node.id.type === 'Identifier') {
327
+ this.setVarInScope(node.id.value, { defaultNs, keyPrefix });
328
+ }
329
+ else if (node.id.type === 'ArrayPattern') {
330
+ const firstElement = node.id.elements[0];
331
+ if (firstElement?.type === 'Identifier') {
332
+ this.setVarInScope(firstElement.value, { defaultNs, keyPrefix });
333
+ }
334
+ }
346
335
  }
347
336
  /**
348
337
  * Processes getFixedT function declarations to extract scope information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.37.0",
3
+ "version": "1.37.1",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,35 +55,35 @@
55
55
  "@rollup/plugin-replace": "6.0.3",
56
56
  "@rollup/plugin-terser": "0.4.4",
57
57
  "@types/inquirer": "9.0.9",
58
- "@types/node": "25.0.2",
59
- "@types/react": "19.2.7",
60
- "@vitest/coverage-v8": "4.0.15",
58
+ "@types/node": "25.0.10",
59
+ "@types/react": "19.2.9",
60
+ "@vitest/coverage-v8": "4.0.18",
61
61
  "eslint": "9.39.2",
62
62
  "eslint-plugin-import": "2.32.0",
63
- "memfs": "4.51.1",
63
+ "memfs": "4.56.10",
64
64
  "neostandard": "0.12.2",
65
65
  "rollup-plugin-typescript2": "0.36.0",
66
66
  "ts-node": "10.9.2",
67
67
  "typescript": "5.9.3",
68
68
  "unplugin-swc": "1.5.9",
69
- "vitest": "4.0.15"
69
+ "vitest": "4.0.18"
70
70
  },
71
71
  "dependencies": {
72
72
  "@croct/json5-parser": "0.2.2",
73
- "@swc/core": "1.15.4",
73
+ "@swc/core": "1.15.10",
74
74
  "chalk": "5.6.2",
75
75
  "chokidar": "5.0.0",
76
76
  "commander": "14.0.2",
77
77
  "execa": "9.6.1",
78
78
  "glob": "13.0.0",
79
79
  "i18next-resources-for-ts": "2.0.0",
80
- "inquirer": "13.1.0",
80
+ "inquirer": "13.2.1",
81
81
  "jiti": "2.6.1",
82
82
  "jsonc-parser": "3.3.1",
83
83
  "minimatch": "10.1.1",
84
- "ora": "9.0.0",
84
+ "ora": "9.1.0",
85
85
  "react": "^19.2.3",
86
- "react-i18next": "^16.5.1",
86
+ "react-i18next": "^16.5.3",
87
87
  "swc-walk": "1.0.1"
88
88
  }
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scope-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/scope-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAmC,MAAM,WAAW,CAAA;AACpF,OAAO,KAAK,EAAE,SAAS,EAA4B,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG5F,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,KAAK,CAAqE;IAGlF,OAAO,CAAC,eAAe,CAAiC;gBAE3C,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC;IAI1D;;;;;;OAMG;IACI,KAAK,IAAK,IAAI;IAMrB;;;OAGG;IACH,UAAU,IAAK,IAAI;IAInB;;;OAGG;IACH,SAAS,IAAK,IAAI;IAIlB;;;;;;OAMG;IACH,aAAa,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAUnD;;;;;;OAMG;IACH,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAkBrD,OAAO,CAAC,uBAAuB;IAoB/B;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAIrC;;;;;;;;;;OAUG;IACH,wBAAwB,CAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAwDzD;;;;;;;;OAQG;IACH,OAAO,CAAC,+BAA+B;IA4FvC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,8BAA8B;IAoFtC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,yBAAyB;IAoBjC;;;;;;;;;OASG;IACH,OAAO,CAAC,qCAAqC;CAuB9C"}
1
+ {"version":3,"file":"scope-manager.d.ts","sourceRo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