i18next-cli 1.34.1 → 1.35.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/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/ast-visitors.js +8 -0
- package/dist/cjs/extractor/parsers/call-expression-handler.js +5 -4
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/ast-visitors.js +8 -0
- package/dist/esm/extractor/parsers/call-expression-handler.js +5 -4
- package/package.json +1 -1
- package/types/extractor/core/ast-visitors.d.ts.map +1 -1
- package/types/extractor/parsers/call-expression-handler.d.ts +3 -2
- package/types/extractor/parsers/call-expression-handler.d.ts.map +1 -1
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.
|
|
31
|
+
.version('1.35.0'); // 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
|
|
@@ -257,6 +257,14 @@ class ASTVisitors {
|
|
|
257
257
|
case 'CallExpression':
|
|
258
258
|
this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
259
259
|
break;
|
|
260
|
+
case 'NewExpression':
|
|
261
|
+
// Handle NewExpression similarly to CallExpression (e.g., new TranslatedError(...))
|
|
262
|
+
// NewExpression has the same structure: callee and arguments
|
|
263
|
+
this.callExpressionHandler.handleCallExpression({
|
|
264
|
+
...node,
|
|
265
|
+
arguments: node.arguments || []
|
|
266
|
+
}, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
267
|
+
break;
|
|
260
268
|
case 'JSXElement':
|
|
261
269
|
this.jsxHandler.handleJSXElement(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
262
270
|
break;
|
|
@@ -35,9 +35,9 @@ class CallExpressionHandler {
|
|
|
35
35
|
getLocationFromNode(node) {
|
|
36
36
|
const code = this.getCurrentCode();
|
|
37
37
|
// Extract searchable text from the node
|
|
38
|
-
// For CallExpression, we can search for the key argument
|
|
38
|
+
// For CallExpression and NewExpression, we can search for the key argument
|
|
39
39
|
let searchText;
|
|
40
|
-
if (node.type === 'CallExpression' && node.arguments.length > 0) {
|
|
40
|
+
if ((node.type === 'CallExpression' || node.type === 'NewExpression') && node.arguments.length > 0) {
|
|
41
41
|
const firstArg = node.arguments[0].expression;
|
|
42
42
|
if (firstArg.type === 'StringLiteral') {
|
|
43
43
|
// Search for the string literal including quotes
|
|
@@ -70,17 +70,18 @@ class CallExpressionHandler {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Processes function call expressions to extract translation keys.
|
|
73
|
+
* Processes function call expressions and new expressions to extract translation keys.
|
|
74
74
|
*
|
|
75
75
|
* This is the core extraction method that handles:
|
|
76
76
|
* - Standard t() calls with string literals
|
|
77
|
+
* - NewExpression calls like new TranslatedError(...)
|
|
77
78
|
* - Selector API calls with arrow functions: `t($ => $.path.to.key)`
|
|
78
79
|
* - Namespace resolution from multiple sources
|
|
79
80
|
* - Default value extraction from various argument patterns
|
|
80
81
|
* - Pluralization and context handling
|
|
81
82
|
* - Key prefix application from scope
|
|
82
83
|
*
|
|
83
|
-
* @param node - Call expression node to process
|
|
84
|
+
* @param node - Call expression or new expression node to process
|
|
84
85
|
* @param getScopeInfo - Function to retrieve scope information for variables
|
|
85
86
|
*/
|
|
86
87
|
handleCallExpression(node, getScopeInfo) {
|
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.
|
|
29
|
+
.version('1.35.0'); // 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
|
|
@@ -255,6 +255,14 @@ class ASTVisitors {
|
|
|
255
255
|
case 'CallExpression':
|
|
256
256
|
this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
257
257
|
break;
|
|
258
|
+
case 'NewExpression':
|
|
259
|
+
// Handle NewExpression similarly to CallExpression (e.g., new TranslatedError(...))
|
|
260
|
+
// NewExpression has the same structure: callee and arguments
|
|
261
|
+
this.callExpressionHandler.handleCallExpression({
|
|
262
|
+
...node,
|
|
263
|
+
arguments: node.arguments || []
|
|
264
|
+
}, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
265
|
+
break;
|
|
258
266
|
case 'JSXElement':
|
|
259
267
|
this.jsxHandler.handleJSXElement(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
|
|
260
268
|
break;
|
|
@@ -33,9 +33,9 @@ class CallExpressionHandler {
|
|
|
33
33
|
getLocationFromNode(node) {
|
|
34
34
|
const code = this.getCurrentCode();
|
|
35
35
|
// Extract searchable text from the node
|
|
36
|
-
// For CallExpression, we can search for the key argument
|
|
36
|
+
// For CallExpression and NewExpression, we can search for the key argument
|
|
37
37
|
let searchText;
|
|
38
|
-
if (node.type === 'CallExpression' && node.arguments.length > 0) {
|
|
38
|
+
if ((node.type === 'CallExpression' || node.type === 'NewExpression') && node.arguments.length > 0) {
|
|
39
39
|
const firstArg = node.arguments[0].expression;
|
|
40
40
|
if (firstArg.type === 'StringLiteral') {
|
|
41
41
|
// Search for the string literal including quotes
|
|
@@ -68,17 +68,18 @@ class CallExpressionHandler {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Processes function call expressions to extract translation keys.
|
|
71
|
+
* Processes function call expressions and new expressions to extract translation keys.
|
|
72
72
|
*
|
|
73
73
|
* This is the core extraction method that handles:
|
|
74
74
|
* - Standard t() calls with string literals
|
|
75
|
+
* - NewExpression calls like new TranslatedError(...)
|
|
75
76
|
* - Selector API calls with arrow functions: `t($ => $.path.to.key)`
|
|
76
77
|
* - Namespace resolution from multiple sources
|
|
77
78
|
* - Default value extraction from various argument patterns
|
|
78
79
|
* - Pluralization and context handling
|
|
79
80
|
* - Key prefix application from scope
|
|
80
81
|
*
|
|
81
|
-
* @param node - Call expression node to process
|
|
82
|
+
* @param node - Call expression or new expression node to process
|
|
82
83
|
* @param getScopeInfo - Function to retrieve scope information for variables
|
|
83
84
|
*/
|
|
84
85
|
handleCallExpression(node, getScopeInfo) {
|
package/package.json
CHANGED
|
@@ -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,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAInE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,KAAK,CAAiB;IAE9B,IAAW,UAAU,gBAEpB;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAa;IAE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ACd,KAAK,CAAC,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,kBAAkB;IAgCzC;;;;;OAKG;IACI,KAAK,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAUjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI;IA8NZ;;;;;;;;OAQG;IACI,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI5D;;;OAGG;IACI,cAAc,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQxD;;;;;;OAMG;IACI,cAAc,IAAK,MAAM;IAIhC;;OAEG;IACI,cAAc,IAAK,MAAM;CAGjC"}
|
|
@@ -22,17 +22,18 @@ export declare class CallExpressionHandler {
|
|
|
22
22
|
*/
|
|
23
23
|
private getLocationFromNode;
|
|
24
24
|
/**
|
|
25
|
-
* Processes function call expressions to extract translation keys.
|
|
25
|
+
* Processes function call expressions and new expressions to extract translation keys.
|
|
26
26
|
*
|
|
27
27
|
* This is the core extraction method that handles:
|
|
28
28
|
* - Standard t() calls with string literals
|
|
29
|
+
* - NewExpression calls like new TranslatedError(...)
|
|
29
30
|
* - Selector API calls with arrow functions: `t($ => $.path.to.key)`
|
|
30
31
|
* - Namespace resolution from multiple sources
|
|
31
32
|
* - Default value extraction from various argument patterns
|
|
32
33
|
* - Pluralization and context handling
|
|
33
34
|
* - Key prefix application from scope
|
|
34
35
|
*
|
|
35
|
-
* @param node - Call expression node to process
|
|
36
|
+
* @param node - Call expression or new expression node to process
|
|
36
37
|
* @param getScopeInfo - Function to retrieve scope information for variables
|
|
37
38
|
*/
|
|
38
39
|
handleCallExpression(node: CallExpression, getScopeInfo: (name: string) => ScopeInfo | undefined): void;
|
|
@@ -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,aAAa,CAAA;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM1D,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,eAAe,CAAY;gBAGjC,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;IAU9B;;;OAGG;IACI,gBAAgB,IAAK,IAAI;IAIhC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA4C3B
|
|
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,aAAa,CAAA;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM1D,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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