i18next-cli 1.74.6 → 1.74.7
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 +1 -1
- package/dist/cjs/extractor/core/ast-visitors.js +57 -9
- package/dist/cjs/extractor/parsers/call-expression-handler.js +53 -52
- package/dist/cjs/extractor/parsers/expression-resolver.js +19 -5
- package/dist/cjs/extractor/parsers/jsx-handler.js +18 -10
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/ast-visitors.js +58 -10
- package/dist/esm/extractor/parsers/call-expression-handler.js +53 -53
- package/dist/esm/extractor/parsers/expression-resolver.js +19 -6
- package/dist/esm/extractor/parsers/jsx-handler.js +19 -11
- package/package.json +2 -2
- package/types/extractor/core/ast-visitors.d.ts +1 -0
- package/types/extractor/core/ast-visitors.d.ts.map +1 -1
- package/types/extractor/parsers/call-expression-handler.d.ts +25 -25
- package/types/extractor/parsers/call-expression-handler.d.ts.map +1 -1
- package/types/extractor/parsers/expression-resolver.d.ts +5 -3
- package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
- package/types/extractor/parsers/jsx-handler.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ const program = new commander.Command();
|
|
|
37
37
|
program
|
|
38
38
|
.name('i18next-cli')
|
|
39
39
|
.description('A unified, high-performance i18next CLI.')
|
|
40
|
-
.version('1.74.
|
|
40
|
+
.version('1.74.7') // This string is replaced with the actual version at build time by rollup
|
|
41
41
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
42
42
|
// new: global config override option
|
|
43
43
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -4,6 +4,7 @@ var scopeManager = require('../parsers/scope-manager.js');
|
|
|
4
4
|
var expressionResolver = require('../parsers/expression-resolver.js');
|
|
5
5
|
var callExpressionHandler = require('../parsers/call-expression-handler.js');
|
|
6
6
|
var jsxHandler = require('../parsers/jsx-handler.js');
|
|
7
|
+
var astUtils = require('../parsers/ast-utils.js');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Array iteration methods whose callback we can bind, mapped to the position of
|
|
@@ -20,6 +21,24 @@ const ITERATION_METHODS = {
|
|
|
20
21
|
reduce: 1,
|
|
21
22
|
reduceRight: 1,
|
|
22
23
|
};
|
|
24
|
+
// `FC<Props>` / `React.FC<Props>` / `FunctionComponent<Props>` → `Props`
|
|
25
|
+
const COMPONENT_TYPES = new Set(['FC', 'FunctionComponent', 'VFC', 'VoidFunctionComponent']);
|
|
26
|
+
function componentPropsType(type) {
|
|
27
|
+
if (type?.type !== 'TsTypeReference')
|
|
28
|
+
return undefined;
|
|
29
|
+
const name = type.typeName?.type === 'TsQualifiedName' ? type.typeName.right?.value : type.typeName?.value;
|
|
30
|
+
return COMPONENT_TYPES.has(name) ? type.typeParams?.params?.[0] : undefined;
|
|
31
|
+
}
|
|
32
|
+
// `memo(fn)` / `forwardRef(fn)` → `fn`, and which type argument types its props:
|
|
33
|
+
// `memo<Props>` → 0, `forwardRef<Ref, Props>` → 1
|
|
34
|
+
const PROPS_TYPE_ARG = { memo: 0, forwardRef: 1 };
|
|
35
|
+
function reactWrapper(node) {
|
|
36
|
+
if (node?.type !== 'CallExpression')
|
|
37
|
+
return undefined;
|
|
38
|
+
const name = node.callee?.type === 'MemberExpression' ? node.callee.property?.value : node.callee?.value;
|
|
39
|
+
const propsTypeIndex = PROPS_TYPE_ARG[name];
|
|
40
|
+
return propsTypeIndex === undefined ? undefined : { fn: astUtils.unwrapParens(node.arguments?.[0]?.expression), propsTypeIndex };
|
|
41
|
+
}
|
|
23
42
|
/**
|
|
24
43
|
* AST visitor class that traverses JavaScript/TypeScript syntax trees to extract translation keys.
|
|
25
44
|
*
|
|
@@ -56,6 +75,8 @@ class ASTVisitors {
|
|
|
56
75
|
jsxHandler;
|
|
57
76
|
currentFile = '';
|
|
58
77
|
currentCode = '';
|
|
78
|
+
// `const C: React.FC<Props> = (props) => …` → the function → `Props`
|
|
79
|
+
componentPropsTypes = new WeakMap();
|
|
59
80
|
/**
|
|
60
81
|
* Creates a new AST visitor instance.
|
|
61
82
|
*
|
|
@@ -261,11 +282,13 @@ class ASTVisitors {
|
|
|
261
282
|
let ident;
|
|
262
283
|
if (!p)
|
|
263
284
|
continue;
|
|
285
|
+
// The props of `const C: React.FC<Props> = (props) => …` are typed by `Props`
|
|
286
|
+
const inheritedType = p === params[0] ? this.componentPropsTypes.get(node) : undefined;
|
|
264
287
|
// Destructured object param: `function f({ size }: IProps)`.
|
|
265
288
|
// Bind each destructured local name to its interface member's values.
|
|
266
289
|
const pat = p.pat ?? p.pattern ?? p;
|
|
267
290
|
if (pat.type === 'ObjectPattern') {
|
|
268
|
-
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation;
|
|
291
|
+
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation ?? inheritedType;
|
|
269
292
|
const members = this.expressionResolver.resolveTypeMembers(patType);
|
|
270
293
|
for (const prop of (pat.properties ?? [])) {
|
|
271
294
|
// `{ size }` / `{ size = 'all' }` → AssignmentPatternProperty (local name is the key)
|
|
@@ -289,12 +312,25 @@ class ASTVisitors {
|
|
|
289
312
|
}
|
|
290
313
|
// `({ t }: { t: TFunction<'ns'> })` → bind `t` to that namespace
|
|
291
314
|
this.bindTFunctionParam(localName, this.getMemberTypeNode(patType, memberName), typeParamConstraints);
|
|
292
|
-
if (
|
|
315
|
+
if (members?.[memberName]) {
|
|
316
|
+
this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
|
|
317
|
+
if (!paramTemporaries)
|
|
318
|
+
paramTemporaries = [];
|
|
319
|
+
paramTemporaries.push(localName);
|
|
293
320
|
continue;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
321
|
+
}
|
|
322
|
+
// `({ Bar }: DeepObject)` → `Bar.status`; `({ items }: Props)` → `items.map(({ kind }) => …)`
|
|
323
|
+
const nested = expressionResolver.nestedMembers(members, memberName);
|
|
324
|
+
if (!nested)
|
|
325
|
+
continue;
|
|
326
|
+
this.expressionResolver.setTemporaryObjectVariable(localName, nested);
|
|
327
|
+
this.expressionResolver.setArrayElementMembers(localName, nested);
|
|
328
|
+
if (!paramObjectTemporaries)
|
|
329
|
+
paramObjectTemporaries = [];
|
|
330
|
+
paramObjectTemporaries.push(localName);
|
|
331
|
+
if (!paramArrayTemporaries)
|
|
332
|
+
paramArrayTemporaries = [];
|
|
333
|
+
paramArrayTemporaries.push(localName);
|
|
298
334
|
}
|
|
299
335
|
continue;
|
|
300
336
|
}
|
|
@@ -338,7 +374,7 @@ class ASTVisitors {
|
|
|
338
374
|
paramDefaults.push(paramKey);
|
|
339
375
|
}
|
|
340
376
|
// Try to locate TypeScript type node carried on the identifier.
|
|
341
|
-
const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation));
|
|
377
|
+
const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation) ?? inheritedType);
|
|
342
378
|
let typeAnn;
|
|
343
379
|
if (rawTypeAnn) {
|
|
344
380
|
// SWC may wrap the actual TS type in a wrapper like TsTypeAnn / TsTypeAnnotation
|
|
@@ -397,12 +433,18 @@ class ASTVisitors {
|
|
|
397
433
|
// --- VISIT LOGIC ---
|
|
398
434
|
// Handle specific node types
|
|
399
435
|
switch (node.type) {
|
|
400
|
-
case 'VariableDeclarator':
|
|
436
|
+
case 'VariableDeclarator': {
|
|
401
437
|
this.scopeManager.handleVariableDeclarator(node);
|
|
402
438
|
// Capture simple variable initializers so the expressionResolver can
|
|
403
439
|
// resolve identifiers / member expressions that reference them.
|
|
404
440
|
this.expressionResolver.captureVariableDeclarator(node);
|
|
441
|
+
// `const C: React.FC<Props> = (props) => …` / `= memo((props) => …)`
|
|
442
|
+
const propsType = componentPropsType(node.id?.typeAnnotation?.typeAnnotation);
|
|
443
|
+
const init = astUtils.unwrapParens(node.init);
|
|
444
|
+
if (propsType && init)
|
|
445
|
+
this.componentPropsTypes.set(reactWrapper(init)?.fn ?? init, propsType);
|
|
405
446
|
break;
|
|
447
|
+
}
|
|
406
448
|
case 'TSEnumDeclaration':
|
|
407
449
|
case 'TsEnumDeclaration':
|
|
408
450
|
case 'TsEnumDecl':
|
|
@@ -425,9 +467,15 @@ class ASTVisitors {
|
|
|
425
467
|
case 'FnDecl':
|
|
426
468
|
this.expressionResolver.captureFunctionDeclaration(node);
|
|
427
469
|
break;
|
|
428
|
-
case 'CallExpression':
|
|
470
|
+
case 'CallExpression': {
|
|
429
471
|
this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
472
|
+
// `forwardRef<Ref, Props>((props, ref) => …)` / `memo<Props>((props) => …)`
|
|
473
|
+
const wrapper = reactWrapper(node);
|
|
474
|
+
const propsType = wrapper && node.typeArguments?.params?.[wrapper.propsTypeIndex];
|
|
475
|
+
if (propsType && wrapper.fn)
|
|
476
|
+
this.componentPropsTypes.set(wrapper.fn, propsType);
|
|
430
477
|
break;
|
|
478
|
+
}
|
|
431
479
|
case 'NewExpression':
|
|
432
480
|
// Handle NewExpression similarly to CallExpression (e.g., new TranslatedError(...))
|
|
433
481
|
// NewExpression has the same structure: callee and arguments
|
|
@@ -11,6 +11,57 @@ const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
11
11
|
// Used to prevent splitting keys like "Error message: not found" into namespace + key.
|
|
12
12
|
const naturalLanguageChars = /[ ,?!;]/;
|
|
13
13
|
const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
|
|
14
|
+
/**
|
|
15
|
+
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
16
|
+
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
17
|
+
*
|
|
18
|
+
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
19
|
+
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
20
|
+
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
21
|
+
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
22
|
+
*
|
|
23
|
+
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
24
|
+
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
25
|
+
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
26
|
+
* Mirrors `i18next/src/selector.js` strict branch.
|
|
27
|
+
*
|
|
28
|
+
* In strict mode we also accept a single-ns scope, falling back to
|
|
29
|
+
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
30
|
+
* (e.g. `useTranslation('only')`).
|
|
31
|
+
*
|
|
32
|
+
* Falls through to the input string when:
|
|
33
|
+
* - the call had no selector (string keys go through this path unchanged),
|
|
34
|
+
* - scope has no namespaces info,
|
|
35
|
+
* - first segment isn't in the scope's namespaces list, or
|
|
36
|
+
* - separators are configured off.
|
|
37
|
+
*/
|
|
38
|
+
function applySelectorNsRewrite(key, scopeInfo, config) {
|
|
39
|
+
const strict = config.types?.enableSelector === 'strict';
|
|
40
|
+
// Resolve the effective namespace list for the rule:
|
|
41
|
+
// - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
|
|
42
|
+
// - strict mode: same array if present; otherwise synthesize from `defaultNs`
|
|
43
|
+
const nsCaptured = scopeInfo?.namespaces;
|
|
44
|
+
const nsList = strict
|
|
45
|
+
? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
|
|
46
|
+
: nsCaptured;
|
|
47
|
+
if (!nsList || nsList.length < (strict ? 1 : 2))
|
|
48
|
+
return key;
|
|
49
|
+
const keySeparator = config.extract.keySeparator;
|
|
50
|
+
const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
|
|
51
|
+
const nsSeparator = config.extract.nsSeparator ?? ':';
|
|
52
|
+
if (keySeparator === false || !nsSeparator)
|
|
53
|
+
return key;
|
|
54
|
+
const firstSepAt = key.indexOf(joiner);
|
|
55
|
+
if (firstSepAt < 0)
|
|
56
|
+
return key;
|
|
57
|
+
const head = key.slice(0, firstSepAt);
|
|
58
|
+
// Default mode excludes the primary; strict mode includes it.
|
|
59
|
+
if (!strict && head === nsList[0])
|
|
60
|
+
return key;
|
|
61
|
+
if (!nsList.includes(head))
|
|
62
|
+
return key;
|
|
63
|
+
return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
|
|
64
|
+
}
|
|
14
65
|
class CallExpressionHandler {
|
|
15
66
|
pluginContext;
|
|
16
67
|
config;
|
|
@@ -593,7 +644,7 @@ class CallExpressionHandler {
|
|
|
593
644
|
if (keys.length > 0) {
|
|
594
645
|
for (const k of keys) {
|
|
595
646
|
originalKeysToProcess.push(k);
|
|
596
|
-
keysToProcess.push(
|
|
647
|
+
keysToProcess.push(applySelectorNsRewrite(k, scopeInfo, this.config));
|
|
597
648
|
}
|
|
598
649
|
isSelectorAPI = true;
|
|
599
650
|
}
|
|
@@ -627,57 +678,6 @@ class CallExpressionHandler {
|
|
|
627
678
|
isSelectorAPI,
|
|
628
679
|
};
|
|
629
680
|
}
|
|
630
|
-
/**
|
|
631
|
-
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
632
|
-
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
633
|
-
*
|
|
634
|
-
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
635
|
-
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
636
|
-
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
637
|
-
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
638
|
-
*
|
|
639
|
-
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
640
|
-
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
641
|
-
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
642
|
-
* Mirrors `i18next/src/selector.js` strict branch.
|
|
643
|
-
*
|
|
644
|
-
* In strict mode we also accept a single-ns scope, falling back to
|
|
645
|
-
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
646
|
-
* (e.g. `useTranslation('only')`).
|
|
647
|
-
*
|
|
648
|
-
* Falls through to the input string when:
|
|
649
|
-
* - the call had no selector (string keys go through this path unchanged),
|
|
650
|
-
* - scope has no namespaces info,
|
|
651
|
-
* - first segment isn't in the scope's namespaces list, or
|
|
652
|
-
* - separators are configured off.
|
|
653
|
-
*/
|
|
654
|
-
applySelectorNsRewrite(key, scopeInfo) {
|
|
655
|
-
const strict = this.config.types?.enableSelector === 'strict';
|
|
656
|
-
// Resolve the effective namespace list for the rule:
|
|
657
|
-
// - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
|
|
658
|
-
// - strict mode: same array if present; otherwise synthesize from `defaultNs`
|
|
659
|
-
const nsCaptured = scopeInfo?.namespaces;
|
|
660
|
-
const nsList = strict
|
|
661
|
-
? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
|
|
662
|
-
: nsCaptured;
|
|
663
|
-
if (!nsList || nsList.length < (strict ? 1 : 2))
|
|
664
|
-
return key;
|
|
665
|
-
const keySeparator = this.config.extract.keySeparator;
|
|
666
|
-
const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
|
|
667
|
-
const nsSeparator = this.config.extract.nsSeparator ?? ':';
|
|
668
|
-
if (keySeparator === false || !nsSeparator)
|
|
669
|
-
return key;
|
|
670
|
-
const firstSepAt = key.indexOf(joiner);
|
|
671
|
-
if (firstSepAt < 0)
|
|
672
|
-
return key;
|
|
673
|
-
const head = key.slice(0, firstSepAt);
|
|
674
|
-
// Default mode excludes the primary; strict mode includes it.
|
|
675
|
-
if (!strict && head === nsList[0])
|
|
676
|
-
return key;
|
|
677
|
-
if (!nsList.includes(head))
|
|
678
|
-
return key;
|
|
679
|
-
return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
|
|
680
|
-
}
|
|
681
681
|
/**
|
|
682
682
|
* Extracts translation key(s) from selector API arrow function.
|
|
683
683
|
*
|
|
@@ -1051,3 +1051,4 @@ class CallExpressionHandler {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
1053
|
exports.CallExpressionHandler = CallExpressionHandler;
|
|
1054
|
+
exports.applySelectorNsRewrite = applySelectorNsRewrite;
|
|
@@ -552,11 +552,12 @@ class ExpressionResolver {
|
|
|
552
552
|
map[memberName] = vals;
|
|
553
553
|
continue;
|
|
554
554
|
}
|
|
555
|
-
// `Bar: { status: '201' | '400' }` → `Bar.status
|
|
555
|
+
// `Bar: { status: '201' | '400' }` → `Bar.status`, and the element of
|
|
556
|
+
// `items: Item[]` the same way so `props.items.map(({ size }) => …)` binds
|
|
556
557
|
this.memberDepth++;
|
|
557
558
|
let nested;
|
|
558
559
|
try {
|
|
559
|
-
nested = this.resolveTypeMembers(tsType);
|
|
560
|
+
nested = this.resolveTypeMembers(tsType) ?? this.resolveArrayElementMembers(tsType);
|
|
560
561
|
}
|
|
561
562
|
finally {
|
|
562
563
|
this.memberDepth--;
|
|
@@ -626,6 +627,9 @@ class ExpressionResolver {
|
|
|
626
627
|
if (tsType.type === 'TsArrayType') {
|
|
627
628
|
return this.resolveTypeMembers(tsType.elemType);
|
|
628
629
|
}
|
|
630
|
+
if (tsType.type === 'TsTypeOperator' && tsType.op === 'readonly') {
|
|
631
|
+
return this.resolveArrayElementMembers(tsType.typeAnnotation);
|
|
632
|
+
}
|
|
629
633
|
if (tsType.type === 'TsTypeReference' && tsType.typeName?.type === 'Identifier') {
|
|
630
634
|
const name = tsType.typeName.value;
|
|
631
635
|
if (name !== 'Array' && name !== 'ReadonlyArray')
|
|
@@ -673,8 +677,8 @@ class ExpressionResolver {
|
|
|
673
677
|
return Object.keys(members).length > 0 ? members : undefined;
|
|
674
678
|
}
|
|
675
679
|
/**
|
|
676
|
-
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`)
|
|
677
|
-
* inline literal (`([1, 2, 3, 4] as const).map(…)`).
|
|
680
|
+
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`), an
|
|
681
|
+
* inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
|
|
678
682
|
*/
|
|
679
683
|
arrayValuesOf(expr) {
|
|
680
684
|
expr = unwrapExpr(expr);
|
|
@@ -682,11 +686,17 @@ class ExpressionResolver {
|
|
|
682
686
|
return this.getVariableValues(expr.value);
|
|
683
687
|
if (expr?.type === 'ArrayExpression')
|
|
684
688
|
return this.arrayLiteralValues(expr);
|
|
689
|
+
// `props.colors` where `colors: Color[]`
|
|
690
|
+
if (expr?.type === 'MemberExpression') {
|
|
691
|
+
const vals = this.resolvePossibleStringValuesFromExpression(expr);
|
|
692
|
+
return vals.length > 0 ? vals : undefined;
|
|
693
|
+
}
|
|
685
694
|
return undefined;
|
|
686
695
|
}
|
|
687
696
|
/**
|
|
688
697
|
* The element member map of an iterated array of objects: a typed or constant
|
|
689
|
-
* identifier (`items: IProps[]`)
|
|
698
|
+
* identifier (`items: IProps[]`), an inline literal (`[{ unit: 'day' }]`) or a
|
|
699
|
+
* typed member (`props.items`).
|
|
690
700
|
*/
|
|
691
701
|
arrayMembersOf(expr) {
|
|
692
702
|
expr = unwrapExpr(expr);
|
|
@@ -694,6 +704,9 @@ class ExpressionResolver {
|
|
|
694
704
|
return this.arrayElementMembers.get(expr.value);
|
|
695
705
|
if (expr?.type === 'ArrayExpression')
|
|
696
706
|
return this.arrayLiteralMembers(expr);
|
|
707
|
+
// `props.items` where `items: Item[]`
|
|
708
|
+
if (expr?.type === 'MemberExpression')
|
|
709
|
+
return this.objectMembersOf(expr);
|
|
697
710
|
return undefined;
|
|
698
711
|
}
|
|
699
712
|
/**
|
|
@@ -1390,3 +1403,4 @@ class ExpressionResolver {
|
|
|
1390
1403
|
}
|
|
1391
1404
|
|
|
1392
1405
|
exports.ExpressionResolver = ExpressionResolver;
|
|
1406
|
+
exports.nestedMembers = nestedMembers;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var pluralRules = require('../../utils/plural-rules.js');
|
|
4
4
|
var jsxParser = require('./jsx-parser.js');
|
|
5
5
|
var astUtils = require('./ast-utils.js');
|
|
6
|
+
var callExpressionHandler = require('./call-expression-handler.js');
|
|
6
7
|
|
|
7
8
|
// Checks if a string looks like natural language (contains spaces, punctuation, etc.)
|
|
8
9
|
const naturalLanguageChars = /[ ,?!;]/;
|
|
@@ -169,7 +170,22 @@ class JSXHandler {
|
|
|
169
170
|
// If ns is not explicitly set on the component, try to find it from the key
|
|
170
171
|
// or the `t` prop
|
|
171
172
|
if (!extractedAttributes.ns) {
|
|
173
|
+
const tProp = node.opening.attributes?.find(attr => attr.type === 'JSXAttribute' &&
|
|
174
|
+
attr.name.type === 'Identifier' &&
|
|
175
|
+
attr.name.value === 't');
|
|
176
|
+
// Check if the prop value is an identifier (e.g., t={t})
|
|
177
|
+
const scopeInfo = tProp?.type === 'JSXAttribute' &&
|
|
178
|
+
tProp.value?.type === 'JSXExpressionContainer' &&
|
|
179
|
+
tProp.value.expression.type === 'Identifier'
|
|
180
|
+
? getScopeInfo(tProp.value.expression.value)
|
|
181
|
+
: undefined;
|
|
182
|
+
// Trans leaves a selector key to the `t` prop, which routes it into the
|
|
183
|
+
// hook's other namespaces like t() does (react-i18next#1933)
|
|
184
|
+
const isSelector = !!extractedAttributes.keyExpression &&
|
|
185
|
+
astUtils.unwrapParens(extractedAttributes.keyExpression).type === 'ArrowFunctionExpression';
|
|
172
186
|
extractedKeys = keysToProcess.map(key => {
|
|
187
|
+
if (isSelector)
|
|
188
|
+
key = callExpressionHandler.applySelectorNsRewrite(key, scopeInfo, this.config);
|
|
173
189
|
const nsSeparator = this.config.extract.nsSeparator ?? ':';
|
|
174
190
|
let ns;
|
|
175
191
|
// If the key contains a namespace separator, it takes precedence
|
|
@@ -191,16 +207,8 @@ class JSXHandler {
|
|
|
191
207
|
locations
|
|
192
208
|
};
|
|
193
209
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
attr.name.value === 't');
|
|
197
|
-
// Check if the prop value is an identifier (e.g., t={t})
|
|
198
|
-
if (tProp?.type === 'JSXAttribute' &&
|
|
199
|
-
tProp.value?.type === 'JSXExpressionContainer' &&
|
|
200
|
-
tProp.value.expression.type === 'Identifier') {
|
|
201
|
-
const tIdentifier = tProp.value.expression.value;
|
|
202
|
-
const scopeInfo = getScopeInfo(tIdentifier);
|
|
203
|
-
if (scopeInfo?.defaultNs) {
|
|
210
|
+
if (scopeInfo) {
|
|
211
|
+
if (scopeInfo.defaultNs) {
|
|
204
212
|
// One copy per namespace when the hook's ns was a conditional (#299)
|
|
205
213
|
const scopeNamespaces = [scopeInfo.defaultNs, ...(scopeInfo.altNs ?? [])];
|
|
206
214
|
extractedKeys = extractedKeys.flatMap(key => key.ns ? [key] : scopeNamespaces.map(ns => ({ ...key, ns })));
|
package/dist/esm/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const program = new Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name('i18next-cli')
|
|
33
33
|
.description('A unified, high-performance i18next CLI.')
|
|
34
|
-
.version('1.74.
|
|
34
|
+
.version('1.74.7') // This string is replaced with the actual version at build time by rollup
|
|
35
35
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
36
36
|
// new: global config override option
|
|
37
37
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ScopeManager } from '../parsers/scope-manager.js';
|
|
2
|
-
import { ExpressionResolver } from '../parsers/expression-resolver.js';
|
|
2
|
+
import { ExpressionResolver, nestedMembers } from '../parsers/expression-resolver.js';
|
|
3
3
|
import { CallExpressionHandler } from '../parsers/call-expression-handler.js';
|
|
4
4
|
import { JSXHandler } from '../parsers/jsx-handler.js';
|
|
5
|
+
import { unwrapParens } from '../parsers/ast-utils.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Array iteration methods whose callback we can bind, mapped to the position of
|
|
@@ -18,6 +19,24 @@ const ITERATION_METHODS = {
|
|
|
18
19
|
reduce: 1,
|
|
19
20
|
reduceRight: 1,
|
|
20
21
|
};
|
|
22
|
+
// `FC<Props>` / `React.FC<Props>` / `FunctionComponent<Props>` → `Props`
|
|
23
|
+
const COMPONENT_TYPES = new Set(['FC', 'FunctionComponent', 'VFC', 'VoidFunctionComponent']);
|
|
24
|
+
function componentPropsType(type) {
|
|
25
|
+
if (type?.type !== 'TsTypeReference')
|
|
26
|
+
return undefined;
|
|
27
|
+
const name = type.typeName?.type === 'TsQualifiedName' ? type.typeName.right?.value : type.typeName?.value;
|
|
28
|
+
return COMPONENT_TYPES.has(name) ? type.typeParams?.params?.[0] : undefined;
|
|
29
|
+
}
|
|
30
|
+
// `memo(fn)` / `forwardRef(fn)` → `fn`, and which type argument types its props:
|
|
31
|
+
// `memo<Props>` → 0, `forwardRef<Ref, Props>` → 1
|
|
32
|
+
const PROPS_TYPE_ARG = { memo: 0, forwardRef: 1 };
|
|
33
|
+
function reactWrapper(node) {
|
|
34
|
+
if (node?.type !== 'CallExpression')
|
|
35
|
+
return undefined;
|
|
36
|
+
const name = node.callee?.type === 'MemberExpression' ? node.callee.property?.value : node.callee?.value;
|
|
37
|
+
const propsTypeIndex = PROPS_TYPE_ARG[name];
|
|
38
|
+
return propsTypeIndex === undefined ? undefined : { fn: unwrapParens(node.arguments?.[0]?.expression), propsTypeIndex };
|
|
39
|
+
}
|
|
21
40
|
/**
|
|
22
41
|
* AST visitor class that traverses JavaScript/TypeScript syntax trees to extract translation keys.
|
|
23
42
|
*
|
|
@@ -54,6 +73,8 @@ class ASTVisitors {
|
|
|
54
73
|
jsxHandler;
|
|
55
74
|
currentFile = '';
|
|
56
75
|
currentCode = '';
|
|
76
|
+
// `const C: React.FC<Props> = (props) => …` → the function → `Props`
|
|
77
|
+
componentPropsTypes = new WeakMap();
|
|
57
78
|
/**
|
|
58
79
|
* Creates a new AST visitor instance.
|
|
59
80
|
*
|
|
@@ -259,11 +280,13 @@ class ASTVisitors {
|
|
|
259
280
|
let ident;
|
|
260
281
|
if (!p)
|
|
261
282
|
continue;
|
|
283
|
+
// The props of `const C: React.FC<Props> = (props) => …` are typed by `Props`
|
|
284
|
+
const inheritedType = p === params[0] ? this.componentPropsTypes.get(node) : undefined;
|
|
262
285
|
// Destructured object param: `function f({ size }: IProps)`.
|
|
263
286
|
// Bind each destructured local name to its interface member's values.
|
|
264
287
|
const pat = p.pat ?? p.pattern ?? p;
|
|
265
288
|
if (pat.type === 'ObjectPattern') {
|
|
266
|
-
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation;
|
|
289
|
+
const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation ?? inheritedType;
|
|
267
290
|
const members = this.expressionResolver.resolveTypeMembers(patType);
|
|
268
291
|
for (const prop of (pat.properties ?? [])) {
|
|
269
292
|
// `{ size }` / `{ size = 'all' }` → AssignmentPatternProperty (local name is the key)
|
|
@@ -287,12 +310,25 @@ class ASTVisitors {
|
|
|
287
310
|
}
|
|
288
311
|
// `({ t }: { t: TFunction<'ns'> })` → bind `t` to that namespace
|
|
289
312
|
this.bindTFunctionParam(localName, this.getMemberTypeNode(patType, memberName), typeParamConstraints);
|
|
290
|
-
if (
|
|
313
|
+
if (members?.[memberName]) {
|
|
314
|
+
this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
|
|
315
|
+
if (!paramTemporaries)
|
|
316
|
+
paramTemporaries = [];
|
|
317
|
+
paramTemporaries.push(localName);
|
|
291
318
|
continue;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
319
|
+
}
|
|
320
|
+
// `({ Bar }: DeepObject)` → `Bar.status`; `({ items }: Props)` → `items.map(({ kind }) => …)`
|
|
321
|
+
const nested = nestedMembers(members, memberName);
|
|
322
|
+
if (!nested)
|
|
323
|
+
continue;
|
|
324
|
+
this.expressionResolver.setTemporaryObjectVariable(localName, nested);
|
|
325
|
+
this.expressionResolver.setArrayElementMembers(localName, nested);
|
|
326
|
+
if (!paramObjectTemporaries)
|
|
327
|
+
paramObjectTemporaries = [];
|
|
328
|
+
paramObjectTemporaries.push(localName);
|
|
329
|
+
if (!paramArrayTemporaries)
|
|
330
|
+
paramArrayTemporaries = [];
|
|
331
|
+
paramArrayTemporaries.push(localName);
|
|
296
332
|
}
|
|
297
333
|
continue;
|
|
298
334
|
}
|
|
@@ -336,7 +372,7 @@ class ASTVisitors {
|
|
|
336
372
|
paramDefaults.push(paramKey);
|
|
337
373
|
}
|
|
338
374
|
// Try to locate TypeScript type node carried on the identifier.
|
|
339
|
-
const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation));
|
|
375
|
+
const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation) ?? inheritedType);
|
|
340
376
|
let typeAnn;
|
|
341
377
|
if (rawTypeAnn) {
|
|
342
378
|
// SWC may wrap the actual TS type in a wrapper like TsTypeAnn / TsTypeAnnotation
|
|
@@ -395,12 +431,18 @@ class ASTVisitors {
|
|
|
395
431
|
// --- VISIT LOGIC ---
|
|
396
432
|
// Handle specific node types
|
|
397
433
|
switch (node.type) {
|
|
398
|
-
case 'VariableDeclarator':
|
|
434
|
+
case 'VariableDeclarator': {
|
|
399
435
|
this.scopeManager.handleVariableDeclarator(node);
|
|
400
436
|
// Capture simple variable initializers so the expressionResolver can
|
|
401
437
|
// resolve identifiers / member expressions that reference them.
|
|
402
438
|
this.expressionResolver.captureVariableDeclarator(node);
|
|
439
|
+
// `const C: React.FC<Props> = (props) => …` / `= memo((props) => …)`
|
|
440
|
+
const propsType = componentPropsType(node.id?.typeAnnotation?.typeAnnotation);
|
|
441
|
+
const init = unwrapParens(node.init);
|
|
442
|
+
if (propsType && init)
|
|
443
|
+
this.componentPropsTypes.set(reactWrapper(init)?.fn ?? init, propsType);
|
|
403
444
|
break;
|
|
445
|
+
}
|
|
404
446
|
case 'TSEnumDeclaration':
|
|
405
447
|
case 'TsEnumDeclaration':
|
|
406
448
|
case 'TsEnumDecl':
|
|
@@ -423,9 +465,15 @@ class ASTVisitors {
|
|
|
423
465
|
case 'FnDecl':
|
|
424
466
|
this.expressionResolver.captureFunctionDeclaration(node);
|
|
425
467
|
break;
|
|
426
|
-
case 'CallExpression':
|
|
468
|
+
case 'CallExpression': {
|
|
427
469
|
this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
470
|
+
// `forwardRef<Ref, Props>((props, ref) => …)` / `memo<Props>((props) => …)`
|
|
471
|
+
const wrapper = reactWrapper(node);
|
|
472
|
+
const propsType = wrapper && node.typeArguments?.params?.[wrapper.propsTypeIndex];
|
|
473
|
+
if (propsType && wrapper.fn)
|
|
474
|
+
this.componentPropsTypes.set(wrapper.fn, propsType);
|
|
428
475
|
break;
|
|
476
|
+
}
|
|
429
477
|
case 'NewExpression':
|
|
430
478
|
// Handle NewExpression similarly to CallExpression (e.g., new TranslatedError(...))
|
|
431
479
|
// NewExpression has the same structure: callee and arguments
|
|
@@ -9,6 +9,57 @@ const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
9
9
|
// Used to prevent splitting keys like "Error message: not found" into namespace + key.
|
|
10
10
|
const naturalLanguageChars = /[ ,?!;]/;
|
|
11
11
|
const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
|
|
12
|
+
/**
|
|
13
|
+
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
14
|
+
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
15
|
+
*
|
|
16
|
+
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
17
|
+
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
18
|
+
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
19
|
+
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
20
|
+
*
|
|
21
|
+
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
22
|
+
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
23
|
+
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
24
|
+
* Mirrors `i18next/src/selector.js` strict branch.
|
|
25
|
+
*
|
|
26
|
+
* In strict mode we also accept a single-ns scope, falling back to
|
|
27
|
+
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
28
|
+
* (e.g. `useTranslation('only')`).
|
|
29
|
+
*
|
|
30
|
+
* Falls through to the input string when:
|
|
31
|
+
* - the call had no selector (string keys go through this path unchanged),
|
|
32
|
+
* - scope has no namespaces info,
|
|
33
|
+
* - first segment isn't in the scope's namespaces list, or
|
|
34
|
+
* - separators are configured off.
|
|
35
|
+
*/
|
|
36
|
+
function applySelectorNsRewrite(key, scopeInfo, config) {
|
|
37
|
+
const strict = config.types?.enableSelector === 'strict';
|
|
38
|
+
// Resolve the effective namespace list for the rule:
|
|
39
|
+
// - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
|
|
40
|
+
// - strict mode: same array if present; otherwise synthesize from `defaultNs`
|
|
41
|
+
const nsCaptured = scopeInfo?.namespaces;
|
|
42
|
+
const nsList = strict
|
|
43
|
+
? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
|
|
44
|
+
: nsCaptured;
|
|
45
|
+
if (!nsList || nsList.length < (strict ? 1 : 2))
|
|
46
|
+
return key;
|
|
47
|
+
const keySeparator = config.extract.keySeparator;
|
|
48
|
+
const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
|
|
49
|
+
const nsSeparator = config.extract.nsSeparator ?? ':';
|
|
50
|
+
if (keySeparator === false || !nsSeparator)
|
|
51
|
+
return key;
|
|
52
|
+
const firstSepAt = key.indexOf(joiner);
|
|
53
|
+
if (firstSepAt < 0)
|
|
54
|
+
return key;
|
|
55
|
+
const head = key.slice(0, firstSepAt);
|
|
56
|
+
// Default mode excludes the primary; strict mode includes it.
|
|
57
|
+
if (!strict && head === nsList[0])
|
|
58
|
+
return key;
|
|
59
|
+
if (!nsList.includes(head))
|
|
60
|
+
return key;
|
|
61
|
+
return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
|
|
62
|
+
}
|
|
12
63
|
class CallExpressionHandler {
|
|
13
64
|
pluginContext;
|
|
14
65
|
config;
|
|
@@ -591,7 +642,7 @@ class CallExpressionHandler {
|
|
|
591
642
|
if (keys.length > 0) {
|
|
592
643
|
for (const k of keys) {
|
|
593
644
|
originalKeysToProcess.push(k);
|
|
594
|
-
keysToProcess.push(
|
|
645
|
+
keysToProcess.push(applySelectorNsRewrite(k, scopeInfo, this.config));
|
|
595
646
|
}
|
|
596
647
|
isSelectorAPI = true;
|
|
597
648
|
}
|
|
@@ -625,57 +676,6 @@ class CallExpressionHandler {
|
|
|
625
676
|
isSelectorAPI,
|
|
626
677
|
};
|
|
627
678
|
}
|
|
628
|
-
/**
|
|
629
|
-
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
630
|
-
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
631
|
-
*
|
|
632
|
-
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
633
|
-
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
634
|
-
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
635
|
-
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
636
|
-
*
|
|
637
|
-
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
638
|
-
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
639
|
-
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
640
|
-
* Mirrors `i18next/src/selector.js` strict branch.
|
|
641
|
-
*
|
|
642
|
-
* In strict mode we also accept a single-ns scope, falling back to
|
|
643
|
-
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
644
|
-
* (e.g. `useTranslation('only')`).
|
|
645
|
-
*
|
|
646
|
-
* Falls through to the input string when:
|
|
647
|
-
* - the call had no selector (string keys go through this path unchanged),
|
|
648
|
-
* - scope has no namespaces info,
|
|
649
|
-
* - first segment isn't in the scope's namespaces list, or
|
|
650
|
-
* - separators are configured off.
|
|
651
|
-
*/
|
|
652
|
-
applySelectorNsRewrite(key, scopeInfo) {
|
|
653
|
-
const strict = this.config.types?.enableSelector === 'strict';
|
|
654
|
-
// Resolve the effective namespace list for the rule:
|
|
655
|
-
// - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
|
|
656
|
-
// - strict mode: same array if present; otherwise synthesize from `defaultNs`
|
|
657
|
-
const nsCaptured = scopeInfo?.namespaces;
|
|
658
|
-
const nsList = strict
|
|
659
|
-
? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
|
|
660
|
-
: nsCaptured;
|
|
661
|
-
if (!nsList || nsList.length < (strict ? 1 : 2))
|
|
662
|
-
return key;
|
|
663
|
-
const keySeparator = this.config.extract.keySeparator;
|
|
664
|
-
const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
|
|
665
|
-
const nsSeparator = this.config.extract.nsSeparator ?? ':';
|
|
666
|
-
if (keySeparator === false || !nsSeparator)
|
|
667
|
-
return key;
|
|
668
|
-
const firstSepAt = key.indexOf(joiner);
|
|
669
|
-
if (firstSepAt < 0)
|
|
670
|
-
return key;
|
|
671
|
-
const head = key.slice(0, firstSepAt);
|
|
672
|
-
// Default mode excludes the primary; strict mode includes it.
|
|
673
|
-
if (!strict && head === nsList[0])
|
|
674
|
-
return key;
|
|
675
|
-
if (!nsList.includes(head))
|
|
676
|
-
return key;
|
|
677
|
-
return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
|
|
678
|
-
}
|
|
679
679
|
/**
|
|
680
680
|
* Extracts translation key(s) from selector API arrow function.
|
|
681
681
|
*
|
|
@@ -1048,4 +1048,4 @@ class CallExpressionHandler {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
-
export { CallExpressionHandler };
|
|
1051
|
+
export { CallExpressionHandler, applySelectorNsRewrite };
|
|
@@ -550,11 +550,12 @@ class ExpressionResolver {
|
|
|
550
550
|
map[memberName] = vals;
|
|
551
551
|
continue;
|
|
552
552
|
}
|
|
553
|
-
// `Bar: { status: '201' | '400' }` → `Bar.status
|
|
553
|
+
// `Bar: { status: '201' | '400' }` → `Bar.status`, and the element of
|
|
554
|
+
// `items: Item[]` the same way so `props.items.map(({ size }) => …)` binds
|
|
554
555
|
this.memberDepth++;
|
|
555
556
|
let nested;
|
|
556
557
|
try {
|
|
557
|
-
nested = this.resolveTypeMembers(tsType);
|
|
558
|
+
nested = this.resolveTypeMembers(tsType) ?? this.resolveArrayElementMembers(tsType);
|
|
558
559
|
}
|
|
559
560
|
finally {
|
|
560
561
|
this.memberDepth--;
|
|
@@ -624,6 +625,9 @@ class ExpressionResolver {
|
|
|
624
625
|
if (tsType.type === 'TsArrayType') {
|
|
625
626
|
return this.resolveTypeMembers(tsType.elemType);
|
|
626
627
|
}
|
|
628
|
+
if (tsType.type === 'TsTypeOperator' && tsType.op === 'readonly') {
|
|
629
|
+
return this.resolveArrayElementMembers(tsType.typeAnnotation);
|
|
630
|
+
}
|
|
627
631
|
if (tsType.type === 'TsTypeReference' && tsType.typeName?.type === 'Identifier') {
|
|
628
632
|
const name = tsType.typeName.value;
|
|
629
633
|
if (name !== 'Array' && name !== 'ReadonlyArray')
|
|
@@ -671,8 +675,8 @@ class ExpressionResolver {
|
|
|
671
675
|
return Object.keys(members).length > 0 ? members : undefined;
|
|
672
676
|
}
|
|
673
677
|
/**
|
|
674
|
-
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`)
|
|
675
|
-
* inline literal (`([1, 2, 3, 4] as const).map(…)`).
|
|
678
|
+
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`), an
|
|
679
|
+
* inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
|
|
676
680
|
*/
|
|
677
681
|
arrayValuesOf(expr) {
|
|
678
682
|
expr = unwrapExpr(expr);
|
|
@@ -680,11 +684,17 @@ class ExpressionResolver {
|
|
|
680
684
|
return this.getVariableValues(expr.value);
|
|
681
685
|
if (expr?.type === 'ArrayExpression')
|
|
682
686
|
return this.arrayLiteralValues(expr);
|
|
687
|
+
// `props.colors` where `colors: Color[]`
|
|
688
|
+
if (expr?.type === 'MemberExpression') {
|
|
689
|
+
const vals = this.resolvePossibleStringValuesFromExpression(expr);
|
|
690
|
+
return vals.length > 0 ? vals : undefined;
|
|
691
|
+
}
|
|
683
692
|
return undefined;
|
|
684
693
|
}
|
|
685
694
|
/**
|
|
686
695
|
* The element member map of an iterated array of objects: a typed or constant
|
|
687
|
-
* identifier (`items: IProps[]`)
|
|
696
|
+
* identifier (`items: IProps[]`), an inline literal (`[{ unit: 'day' }]`) or a
|
|
697
|
+
* typed member (`props.items`).
|
|
688
698
|
*/
|
|
689
699
|
arrayMembersOf(expr) {
|
|
690
700
|
expr = unwrapExpr(expr);
|
|
@@ -692,6 +702,9 @@ class ExpressionResolver {
|
|
|
692
702
|
return this.arrayElementMembers.get(expr.value);
|
|
693
703
|
if (expr?.type === 'ArrayExpression')
|
|
694
704
|
return this.arrayLiteralMembers(expr);
|
|
705
|
+
// `props.items` where `items: Item[]`
|
|
706
|
+
if (expr?.type === 'MemberExpression')
|
|
707
|
+
return this.objectMembersOf(expr);
|
|
695
708
|
return undefined;
|
|
696
709
|
}
|
|
697
710
|
/**
|
|
@@ -1387,4 +1400,4 @@ class ExpressionResolver {
|
|
|
1387
1400
|
}
|
|
1388
1401
|
}
|
|
1389
1402
|
|
|
1390
|
-
export { ExpressionResolver };
|
|
1403
|
+
export { ExpressionResolver, nestedMembers };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { safePluralRules } from '../../utils/plural-rules.js';
|
|
2
2
|
import { extractFromTransComponent } from './jsx-parser.js';
|
|
3
|
-
import { lineColumnFromOffset, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
|
|
3
|
+
import { lineColumnFromOffset, unwrapParens, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
|
|
4
|
+
import { applySelectorNsRewrite } from './call-expression-handler.js';
|
|
4
5
|
|
|
5
6
|
// Checks if a string looks like natural language (contains spaces, punctuation, etc.)
|
|
6
7
|
const naturalLanguageChars = /[ ,?!;]/;
|
|
@@ -167,7 +168,22 @@ class JSXHandler {
|
|
|
167
168
|
// If ns is not explicitly set on the component, try to find it from the key
|
|
168
169
|
// or the `t` prop
|
|
169
170
|
if (!extractedAttributes.ns) {
|
|
171
|
+
const tProp = node.opening.attributes?.find(attr => attr.type === 'JSXAttribute' &&
|
|
172
|
+
attr.name.type === 'Identifier' &&
|
|
173
|
+
attr.name.value === 't');
|
|
174
|
+
// Check if the prop value is an identifier (e.g., t={t})
|
|
175
|
+
const scopeInfo = tProp?.type === 'JSXAttribute' &&
|
|
176
|
+
tProp.value?.type === 'JSXExpressionContainer' &&
|
|
177
|
+
tProp.value.expression.type === 'Identifier'
|
|
178
|
+
? getScopeInfo(tProp.value.expression.value)
|
|
179
|
+
: undefined;
|
|
180
|
+
// Trans leaves a selector key to the `t` prop, which routes it into the
|
|
181
|
+
// hook's other namespaces like t() does (react-i18next#1933)
|
|
182
|
+
const isSelector = !!extractedAttributes.keyExpression &&
|
|
183
|
+
unwrapParens(extractedAttributes.keyExpression).type === 'ArrowFunctionExpression';
|
|
170
184
|
extractedKeys = keysToProcess.map(key => {
|
|
185
|
+
if (isSelector)
|
|
186
|
+
key = applySelectorNsRewrite(key, scopeInfo, this.config);
|
|
171
187
|
const nsSeparator = this.config.extract.nsSeparator ?? ':';
|
|
172
188
|
let ns;
|
|
173
189
|
// If the key contains a namespace separator, it takes precedence
|
|
@@ -189,16 +205,8 @@ class JSXHandler {
|
|
|
189
205
|
locations
|
|
190
206
|
};
|
|
191
207
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
attr.name.value === 't');
|
|
195
|
-
// Check if the prop value is an identifier (e.g., t={t})
|
|
196
|
-
if (tProp?.type === 'JSXAttribute' &&
|
|
197
|
-
tProp.value?.type === 'JSXExpressionContainer' &&
|
|
198
|
-
tProp.value.expression.type === 'Identifier') {
|
|
199
|
-
const tIdentifier = tProp.value.expression.value;
|
|
200
|
-
const scopeInfo = getScopeInfo(tIdentifier);
|
|
201
|
-
if (scopeInfo?.defaultNs) {
|
|
208
|
+
if (scopeInfo) {
|
|
209
|
+
if (scopeInfo.defaultNs) {
|
|
202
210
|
// One copy per namespace when the hook's ns was a conditional (#299)
|
|
203
211
|
const scopeNamespaces = [scopeInfo.defaultNs, ...(scopeInfo.altNs ?? [])];
|
|
204
212
|
extractedKeys = extractedKeys.flatMap(key => key.ns ? [key] : scopeNamespaces.map(ns => ({ ...key, ns })));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.7",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"magic-string": "^1.4.2",
|
|
87
87
|
"minimatch": "^10.2.6",
|
|
88
88
|
"ora": "^9.4.1",
|
|
89
|
-
"react-i18next": "^17.0.
|
|
89
|
+
"react-i18next": "^17.0.16",
|
|
90
90
|
"yaml": "^2.9.1"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-visitors.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/ast-visitors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,aAA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AAC,EAAE,kBAAkB;IAoCzC;;;;;;;;;;;;;OAaG;IACI,mBAAmB,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAU/C;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA0DzB;;;;;OAKG;IACI,KAAK,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAUjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI;IA+bZ;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAiH1B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAIzB,mFAAmF;IACnF,OAAO,CAAC,oBAAoB;IAoB5B;;;;;;;;OAQG;IACH,OAAO,CAAC,gCAAgC;IAiDxC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IA+CxB;;;;;;;;;OASG;IACH,OAAO,CAAC,0BAA0B;IA8ClC;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;;;;;;;OAQG;IACI,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI5D;;OAEG;IACI,cAAc,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxD;;;;;;OAMG;IACI,cAAc,IAAK,MAAM;IAIhC;;OAEG;IACI,cAAc,IAAK,MAAM;CAGjC"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import type { CallExpression } from '@swc/core';
|
|
2
2
|
import type { PluginContext, I18nextToolkitConfig, Logger, ScopeInfo } from '../../types.js';
|
|
3
3
|
import { ExpressionResolver } from './expression-resolver.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
6
|
+
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
7
|
+
*
|
|
8
|
+
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
9
|
+
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
10
|
+
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
11
|
+
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
12
|
+
*
|
|
13
|
+
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
14
|
+
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
15
|
+
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
16
|
+
* Mirrors `i18next/src/selector.js` strict branch.
|
|
17
|
+
*
|
|
18
|
+
* In strict mode we also accept a single-ns scope, falling back to
|
|
19
|
+
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
20
|
+
* (e.g. `useTranslation('only')`).
|
|
21
|
+
*
|
|
22
|
+
* Falls through to the input string when:
|
|
23
|
+
* - the call had no selector (string keys go through this path unchanged),
|
|
24
|
+
* - scope has no namespaces info,
|
|
25
|
+
* - first segment isn't in the scope's namespaces list, or
|
|
26
|
+
* - separators are configured off.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applySelectorNsRewrite(key: string, scopeInfo: ScopeInfo | undefined, config: Pick<I18nextToolkitConfig, 'extract' | 'types'>): string;
|
|
4
29
|
export declare class CallExpressionHandler {
|
|
5
30
|
private pluginContext;
|
|
6
31
|
private config;
|
|
@@ -57,31 +82,6 @@ export declare class CallExpressionHandler {
|
|
|
57
82
|
* @returns An object containing the keys to process and a flag indicating if the selector API is used
|
|
58
83
|
*/
|
|
59
84
|
private handleCallExpressionArgument;
|
|
60
|
-
/**
|
|
61
|
-
* Mirror i18next's runtime selector rule (v25.8.19 default, or
|
|
62
|
-
* `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
|
|
63
|
-
*
|
|
64
|
-
* **Default mode** — rewrite only when the hook was called with a multi-element
|
|
65
|
-
* namespace array and the path's first segment matches a *secondary* namespace.
|
|
66
|
-
* The primary is intentionally not rewritten (preserves #2405): its keys are
|
|
67
|
-
* exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
|
|
68
|
-
*
|
|
69
|
-
* **Strict mode** — every namespace (primary included) is exposed only under
|
|
70
|
-
* its own key on `$`. So a leading segment matching *any* namespace in the
|
|
71
|
-
* scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
|
|
72
|
-
* Mirrors `i18next/src/selector.js` strict branch.
|
|
73
|
-
*
|
|
74
|
-
* In strict mode we also accept a single-ns scope, falling back to
|
|
75
|
-
* `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
|
|
76
|
-
* (e.g. `useTranslation('only')`).
|
|
77
|
-
*
|
|
78
|
-
* Falls through to the input string when:
|
|
79
|
-
* - the call had no selector (string keys go through this path unchanged),
|
|
80
|
-
* - scope has no namespaces info,
|
|
81
|
-
* - first segment isn't in the scope's namespaces list, or
|
|
82
|
-
* - separators are configured off.
|
|
83
|
-
*/
|
|
84
|
-
private applySelectorNsRewrite;
|
|
85
85
|
/**
|
|
86
86
|
* Extracts translation key(s) from selector API arrow function.
|
|
87
87
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-expression-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/call-expression-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAyD,MAAM,WAAW,CAAA;AACtG,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAc7D,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,kBAAkB,CAAoB;IACvC,UAAU,cAAoB;IACrC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,iBAAiB,CAAsC;gBAG7D,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,MAAM,MAAM,EAC5B,cAAc,EAAE,MAAM,MAAM,EAC5B,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAA2B;IAW3E;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAG1B;IAED,uGAAuG;IACvG,OAAO,CAAC,mBAAmB;IAI3B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI;IA8CxG,OAAO,CAAC,eAAe;IA0XvB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAsDpC
|
|
1
|
+
{"version":3,"file":"call-expression-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/call-expression-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAyD,MAAM,WAAW,CAAA;AACtG,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAc7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG,MAAM,CAyBtJ;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,kBAAkB,CAAoB;IACvC,UAAU,cAAoB;IACrC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,iBAAiB,CAAsC;gBAG7D,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,MAAM,MAAM,EAC5B,cAAc,EAAE,MAAM,MAAM,EAC5B,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAA2B;IAW3E;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAG1B;IAED,uGAAuG;IACvG,OAAO,CAAC,mBAAmB;IAI3B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAiB3B;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,GAAG,IAAI;IA8CxG,OAAO,CAAC,eAAe;IA0XvB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAsDpC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;;;;;;;OAQG;IACH,OAAO,CAAC,iCAAiC;IAwFzC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB;IAyMxB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Expression } from '@swc/core';
|
|
2
2
|
import type { ASTVisitorHooks } from '../../types.js';
|
|
3
|
+
export declare const nestedMembers: (members: Record<string, string[]> | undefined, name: string) => Record<string, string[]> | undefined;
|
|
3
4
|
export declare class ExpressionResolver {
|
|
4
5
|
private hooks;
|
|
5
6
|
private variableTable;
|
|
@@ -122,13 +123,14 @@ export declare class ExpressionResolver {
|
|
|
122
123
|
private arrayLiteralValues;
|
|
123
124
|
private arrayLiteralMembers;
|
|
124
125
|
/**
|
|
125
|
-
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`)
|
|
126
|
-
* inline literal (`([1, 2, 3, 4] as const).map(…)`).
|
|
126
|
+
* The values an iterated array holds: a known constant (`QUARTERS.map(…)`), an
|
|
127
|
+
* inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
|
|
127
128
|
*/
|
|
128
129
|
arrayValuesOf(expr: any): string[] | undefined;
|
|
129
130
|
/**
|
|
130
131
|
* The element member map of an iterated array of objects: a typed or constant
|
|
131
|
-
* identifier (`items: IProps[]`)
|
|
132
|
+
* identifier (`items: IProps[]`), an inline literal (`[{ unit: 'day' }]`) or a
|
|
133
|
+
* typed member (`props.items`).
|
|
132
134
|
*/
|
|
133
135
|
arrayMembersOf(expr: any): Record<string, string[]> | undefined;
|
|
134
136
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-resolver.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/expression-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkD,MAAM,WAAW,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"expression-resolver.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/expression-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkD,MAAM,WAAW,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AA+BrD,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,EAA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