i18next-cli 1.56.4 → 1.56.5
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/parsers/call-expression-handler.js +42 -1
- package/dist/cjs/extractor/parsers/jsx-handler.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/parsers/call-expression-handler.js +42 -1
- package/dist/esm/extractor/parsers/jsx-handler.js +1 -1
- package/package.json +1 -1
- package/types/extractor/parsers/call-expression-handler.d.ts +10 -0
- package/types/extractor/parsers/call-expression-handler.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const program = new commander.Command();
|
|
|
32
32
|
program
|
|
33
33
|
.name('i18next-cli')
|
|
34
34
|
.description('A unified, high-performance i18next CLI.')
|
|
35
|
-
.version('1.56.
|
|
35
|
+
.version('1.56.5'); // This string is replaced with the actual version at build time by rollup
|
|
36
36
|
// new: global config override option
|
|
37
37
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
38
38
|
program
|
|
@@ -608,7 +608,48 @@ class CallExpressionHandler {
|
|
|
608
608
|
return [];
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
|
|
611
|
+
return this.extractKeysFromSelectorExpression(body);
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Recursively extracts key paths from a selector-body expression.
|
|
615
|
+
*
|
|
616
|
+
* On top of the straight MemberExpression walk this also descends into
|
|
617
|
+
* branching forms so keys referenced in either branch are preserved
|
|
618
|
+
* (see #247): ternaries (`cond ? $.a : $.b`), nullish/logical
|
|
619
|
+
* short-circuits (`x ?? $.a`, `x && $.a`, `x || $.a`), and common
|
|
620
|
+
* wrapper nodes (parentheses, TS type assertions).
|
|
621
|
+
*/
|
|
622
|
+
extractKeysFromSelectorExpression(expr) {
|
|
623
|
+
if (!expr)
|
|
624
|
+
return [];
|
|
625
|
+
// Unwrap wrappers that don't change the expressed key path.
|
|
626
|
+
if (expr.type === 'ParenthesisExpression' ||
|
|
627
|
+
expr.type === 'TsAsExpression' ||
|
|
628
|
+
expr.type === 'TsSatisfiesExpression' ||
|
|
629
|
+
expr.type === 'TsNonNullExpression' ||
|
|
630
|
+
expr.type === 'TsConstAssertion') {
|
|
631
|
+
return this.extractKeysFromSelectorExpression(expr.expression);
|
|
632
|
+
}
|
|
633
|
+
// Ternary: union of both branches.
|
|
634
|
+
if (expr.type === 'ConditionalExpression') {
|
|
635
|
+
return [
|
|
636
|
+
...this.extractKeysFromSelectorExpression(expr.consequent),
|
|
637
|
+
...this.extractKeysFromSelectorExpression(expr.alternate),
|
|
638
|
+
];
|
|
639
|
+
}
|
|
640
|
+
// Short-circuit logicals (`||`, `&&`, `??`): union of both sides. SWC
|
|
641
|
+
// may emit these as LogicalExpression or BinaryExpression depending on
|
|
642
|
+
// version, so accept both.
|
|
643
|
+
if ((expr.type === 'LogicalExpression' || expr.type === 'BinaryExpression') &&
|
|
644
|
+
(expr.operator === '||' || expr.operator === '&&' || expr.operator === '??')) {
|
|
645
|
+
return [
|
|
646
|
+
...this.extractKeysFromSelectorExpression(expr.left),
|
|
647
|
+
...this.extractKeysFromSelectorExpression(expr.right),
|
|
648
|
+
];
|
|
649
|
+
}
|
|
650
|
+
if (expr.type !== 'MemberExpression')
|
|
651
|
+
return [];
|
|
652
|
+
let current = expr;
|
|
612
653
|
// Each element is an array of possible values for that position in the key path
|
|
613
654
|
const parts = [];
|
|
614
655
|
// Recursively walk down MemberExpressions
|
|
@@ -73,7 +73,7 @@ class JSXHandler {
|
|
|
73
73
|
const where = loc
|
|
74
74
|
? `${this.getCurrentFile()}:${loc.line}:${loc.column}`
|
|
75
75
|
: this.getCurrentFile();
|
|
76
|
-
emit(`Error: <${elementName}> child {${name}} at ${where} won't match at runtime — react-i18next inlines the value (e.g. "<1>meow</1>"), but extraction produces "<1>{{${name}}}</1>". Use {{${name}}} (double braces) with values={{ ${name} }} for interpolation
|
|
76
|
+
emit(`Error: <${elementName}> child {${name}} at ${where} won't match at runtime — react-i18next inlines the value (e.g. "<1>meow</1>"), but extraction produces "<1>{{${name}}}</1>". Use {{${name}}} (double braces) with values={{ ${name} }} for interpolation.`);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
/**
|
package/dist/esm/cli.js
CHANGED
|
@@ -30,7 +30,7 @@ const program = new Command();
|
|
|
30
30
|
program
|
|
31
31
|
.name('i18next-cli')
|
|
32
32
|
.description('A unified, high-performance i18next CLI.')
|
|
33
|
-
.version('1.56.
|
|
33
|
+
.version('1.56.5'); // This string is replaced with the actual version at build time by rollup
|
|
34
34
|
// new: global config override option
|
|
35
35
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
36
36
|
program
|
|
@@ -606,7 +606,48 @@ class CallExpressionHandler {
|
|
|
606
606
|
return [];
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
|
|
609
|
+
return this.extractKeysFromSelectorExpression(body);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Recursively extracts key paths from a selector-body expression.
|
|
613
|
+
*
|
|
614
|
+
* On top of the straight MemberExpression walk this also descends into
|
|
615
|
+
* branching forms so keys referenced in either branch are preserved
|
|
616
|
+
* (see #247): ternaries (`cond ? $.a : $.b`), nullish/logical
|
|
617
|
+
* short-circuits (`x ?? $.a`, `x && $.a`, `x || $.a`), and common
|
|
618
|
+
* wrapper nodes (parentheses, TS type assertions).
|
|
619
|
+
*/
|
|
620
|
+
extractKeysFromSelectorExpression(expr) {
|
|
621
|
+
if (!expr)
|
|
622
|
+
return [];
|
|
623
|
+
// Unwrap wrappers that don't change the expressed key path.
|
|
624
|
+
if (expr.type === 'ParenthesisExpression' ||
|
|
625
|
+
expr.type === 'TsAsExpression' ||
|
|
626
|
+
expr.type === 'TsSatisfiesExpression' ||
|
|
627
|
+
expr.type === 'TsNonNullExpression' ||
|
|
628
|
+
expr.type === 'TsConstAssertion') {
|
|
629
|
+
return this.extractKeysFromSelectorExpression(expr.expression);
|
|
630
|
+
}
|
|
631
|
+
// Ternary: union of both branches.
|
|
632
|
+
if (expr.type === 'ConditionalExpression') {
|
|
633
|
+
return [
|
|
634
|
+
...this.extractKeysFromSelectorExpression(expr.consequent),
|
|
635
|
+
...this.extractKeysFromSelectorExpression(expr.alternate),
|
|
636
|
+
];
|
|
637
|
+
}
|
|
638
|
+
// Short-circuit logicals (`||`, `&&`, `??`): union of both sides. SWC
|
|
639
|
+
// may emit these as LogicalExpression or BinaryExpression depending on
|
|
640
|
+
// version, so accept both.
|
|
641
|
+
if ((expr.type === 'LogicalExpression' || expr.type === 'BinaryExpression') &&
|
|
642
|
+
(expr.operator === '||' || expr.operator === '&&' || expr.operator === '??')) {
|
|
643
|
+
return [
|
|
644
|
+
...this.extractKeysFromSelectorExpression(expr.left),
|
|
645
|
+
...this.extractKeysFromSelectorExpression(expr.right),
|
|
646
|
+
];
|
|
647
|
+
}
|
|
648
|
+
if (expr.type !== 'MemberExpression')
|
|
649
|
+
return [];
|
|
650
|
+
let current = expr;
|
|
610
651
|
// Each element is an array of possible values for that position in the key path
|
|
611
652
|
const parts = [];
|
|
612
653
|
// Recursively walk down MemberExpressions
|
|
@@ -71,7 +71,7 @@ class JSXHandler {
|
|
|
71
71
|
const where = loc
|
|
72
72
|
? `${this.getCurrentFile()}:${loc.line}:${loc.column}`
|
|
73
73
|
: this.getCurrentFile();
|
|
74
|
-
emit(`Error: <${elementName}> child {${name}} at ${where} won't match at runtime — react-i18next inlines the value (e.g. "<1>meow</1>"), but extraction produces "<1>{{${name}}}</1>". Use {{${name}}} (double braces) with values={{ ${name} }} for interpolation
|
|
74
|
+
emit(`Error: <${elementName}> child {${name}} at ${where} won't match at runtime — react-i18next inlines the value (e.g. "<1>meow</1>"), but extraction produces "<1>{{${name}}}</1>". Use {{${name}}} (double braces) with values={{ ${name} }} for interpolation.`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
package/package.json
CHANGED
|
@@ -67,6 +67,16 @@ export declare class CallExpressionHandler {
|
|
|
67
67
|
* @returns Extracted key paths, or empty array if not statically analyzable
|
|
68
68
|
*/
|
|
69
69
|
private extractKeysFromSelector;
|
|
70
|
+
/**
|
|
71
|
+
* Recursively extracts key paths from a selector-body expression.
|
|
72
|
+
*
|
|
73
|
+
* On top of the straight MemberExpression walk this also descends into
|
|
74
|
+
* branching forms so keys referenced in either branch are preserved
|
|
75
|
+
* (see #247): ternaries (`cond ? $.a : $.b`), nullish/logical
|
|
76
|
+
* short-circuits (`x ?? $.a`, `x && $.a`, `x || $.a`), and common
|
|
77
|
+
* wrapper nodes (parentheses, TS type assertions).
|
|
78
|
+
*/
|
|
79
|
+
private extractKeysFromSelectorExpression;
|
|
70
80
|
/**
|
|
71
81
|
* Generates plural form keys based on the primary language's plural rules.
|
|
72
82
|
*
|
|
@@ -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,EAA6C,MAAM,WAAW,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAa7D,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;;;;;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;IA0ZxG;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IA8BpC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,uBAAuB;
|
|
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,EAA6C,MAAM,WAAW,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAa7D,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;;;;;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;IA0ZxG;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,wBAAwB;IAyEhC;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IA8BpC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;;;;;;OAQG;IACH,OAAO,CAAC,iCAAiC;IAwFzC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB;IAyMxB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|