i18next-cli 1.50.0 → 1.50.2
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
|
@@ -31,7 +31,7 @@ const program = new commander.Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name('i18next-cli')
|
|
33
33
|
.description('A unified, high-performance i18next CLI.')
|
|
34
|
-
.version('1.50.
|
|
34
|
+
.version('1.50.2'); // This string is replaced with the actual version at build time by rollup
|
|
35
35
|
// new: global config override option
|
|
36
36
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
37
37
|
program
|
|
@@ -106,6 +106,27 @@ async function runExtractor(config, options = {}) {
|
|
|
106
106
|
throw error;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns true when the given file extension (e.g. '.svelte') is explicitly
|
|
111
|
+
* referenced in at least one of the input glob patterns.
|
|
112
|
+
*
|
|
113
|
+
* This is used to decide whether to emit a warning when a non-native file is
|
|
114
|
+
* skipped because no plugin handled it. A pattern like `src/**\/*.{ts,svelte}`
|
|
115
|
+
* or `src/**\/*.svelte` clearly signals intent; a catch-all like `src/**\/*`
|
|
116
|
+
* does not.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
function isExtExplicitlyInInputPatterns(ext, input) {
|
|
121
|
+
const patterns = Array.isArray(input) ? input : [input];
|
|
122
|
+
// Strip the leading dot for matching (e.g. '.svelte' → 'svelte')
|
|
123
|
+
const bare = ext.startsWith('.') ? ext.slice(1) : ext;
|
|
124
|
+
return patterns.some(p => {
|
|
125
|
+
// Matches both `*.svelte` and `*.{ts,svelte}` style patterns
|
|
126
|
+
const escaped = bare.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
127
|
+
return new RegExp(`[{,*]${escaped}[},*]|[.]${escaped}(?:[^a-z]|$)`).test(p);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
109
130
|
/**
|
|
110
131
|
* Processes an individual source file for translation key extraction.
|
|
111
132
|
*
|
|
@@ -156,7 +177,15 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
|
|
|
156
177
|
const fileExt = node_path.extname(file).toLowerCase();
|
|
157
178
|
const isNativeExt = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts'].includes(fileExt);
|
|
158
179
|
if (!isNativeExt && !wasTransformedByPlugin) {
|
|
159
|
-
// Non-JS/TS file with no plugin handler — skip
|
|
180
|
+
// Non-JS/TS file with no plugin handler — skip, but warn when the
|
|
181
|
+
// extension was explicitly listed in the input glob patterns. That
|
|
182
|
+
// strongly suggests the developer intended to handle it (e.g. via a
|
|
183
|
+
// Svelte/Vue plugin) but forgot to install or register the plugin.
|
|
184
|
+
if (isExtExplicitlyInInputPatterns(fileExt, config.extract.input)) {
|
|
185
|
+
logger$1.warn(`No plugin handled "${file}" (${fileExt}). ` +
|
|
186
|
+
`If you intended to extract translations from ${fileExt} files, ` +
|
|
187
|
+
'make sure the appropriate plugin is installed and added to your config.');
|
|
188
|
+
}
|
|
160
189
|
return;
|
|
161
190
|
}
|
|
162
191
|
// When a plugin transformed a non-native file, always use tsx so SWC can
|
package/dist/esm/cli.js
CHANGED
|
@@ -29,7 +29,7 @@ const program = new Command();
|
|
|
29
29
|
program
|
|
30
30
|
.name('i18next-cli')
|
|
31
31
|
.description('A unified, high-performance i18next CLI.')
|
|
32
|
-
.version('1.50.
|
|
32
|
+
.version('1.50.2'); // This string is replaced with the actual version at build time by rollup
|
|
33
33
|
// new: global config override option
|
|
34
34
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
35
35
|
program
|
|
@@ -104,6 +104,27 @@ async function runExtractor(config, options = {}) {
|
|
|
104
104
|
throw error;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns true when the given file extension (e.g. '.svelte') is explicitly
|
|
109
|
+
* referenced in at least one of the input glob patterns.
|
|
110
|
+
*
|
|
111
|
+
* This is used to decide whether to emit a warning when a non-native file is
|
|
112
|
+
* skipped because no plugin handled it. A pattern like `src/**\/*.{ts,svelte}`
|
|
113
|
+
* or `src/**\/*.svelte` clearly signals intent; a catch-all like `src/**\/*`
|
|
114
|
+
* does not.
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
function isExtExplicitlyInInputPatterns(ext, input) {
|
|
119
|
+
const patterns = Array.isArray(input) ? input : [input];
|
|
120
|
+
// Strip the leading dot for matching (e.g. '.svelte' → 'svelte')
|
|
121
|
+
const bare = ext.startsWith('.') ? ext.slice(1) : ext;
|
|
122
|
+
return patterns.some(p => {
|
|
123
|
+
// Matches both `*.svelte` and `*.{ts,svelte}` style patterns
|
|
124
|
+
const escaped = bare.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
return new RegExp(`[{,*]${escaped}[},*]|[.]${escaped}(?:[^a-z]|$)`).test(p);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
107
128
|
/**
|
|
108
129
|
* Processes an individual source file for translation key extraction.
|
|
109
130
|
*
|
|
@@ -154,7 +175,15 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
|
|
|
154
175
|
const fileExt = extname(file).toLowerCase();
|
|
155
176
|
const isNativeExt = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts'].includes(fileExt);
|
|
156
177
|
if (!isNativeExt && !wasTransformedByPlugin) {
|
|
157
|
-
// Non-JS/TS file with no plugin handler — skip
|
|
178
|
+
// Non-JS/TS file with no plugin handler — skip, but warn when the
|
|
179
|
+
// extension was explicitly listed in the input glob patterns. That
|
|
180
|
+
// strongly suggests the developer intended to handle it (e.g. via a
|
|
181
|
+
// Svelte/Vue plugin) but forgot to install or register the plugin.
|
|
182
|
+
if (isExtExplicitlyInInputPatterns(fileExt, config.extract.input)) {
|
|
183
|
+
logger.warn(`No plugin handled "${file}" (${fileExt}). ` +
|
|
184
|
+
`If you intended to extract translations from ${fileExt} files, ` +
|
|
185
|
+
'make sure the appropriate plugin is installed and added to your config.');
|
|
186
|
+
}
|
|
158
187
|
return;
|
|
159
188
|
}
|
|
160
189
|
// When a plugin transformed a non-native file, always use tsx so SWC can
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.50.
|
|
3
|
+
"version": "1.50.2",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@rollup/plugin-replace": "^6.0.3",
|
|
56
56
|
"@rollup/plugin-terser": "^1.0.0",
|
|
57
57
|
"@types/inquirer": "^9.0.9",
|
|
58
|
-
"@types/node": "^25.
|
|
58
|
+
"@types/node": "^25.5.0",
|
|
59
59
|
"@types/react": "^19.2.14",
|
|
60
60
|
"@typescript-eslint/parser": "^8.57.0",
|
|
61
|
-
"@vitest/coverage-v8": "^4.0
|
|
61
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
62
62
|
"eslint": "^9.39.2",
|
|
63
63
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
64
64
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
69
|
"unplugin-swc": "^1.5.9",
|
|
70
|
-
"vitest": "^4.0
|
|
70
|
+
"vitest": "^4.1.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@croct/json5-parser": "^0.2.2",
|
|
@@ -76,15 +76,15 @@
|
|
|
76
76
|
"commander": "^14.0.3",
|
|
77
77
|
"execa": "^9.6.1",
|
|
78
78
|
"glob": "^13.0.6",
|
|
79
|
-
"i18next-resources-for-ts": "^2.0.
|
|
80
|
-
"inquirer": "^13.3.
|
|
79
|
+
"i18next-resources-for-ts": "^2.0.2",
|
|
80
|
+
"inquirer": "^13.3.2",
|
|
81
81
|
"jiti": "^2.6.1",
|
|
82
82
|
"jsonc-parser": "^3.3.1",
|
|
83
83
|
"magic-string": "^0.30.21",
|
|
84
84
|
"minimatch": "^10.2.4",
|
|
85
85
|
"ora": "^9.3.0",
|
|
86
86
|
"react": "^19.2.4",
|
|
87
|
-
"react-i18next": "^16.5.
|
|
87
|
+
"react-i18next": "^16.5.8",
|
|
88
88
|
"yaml": "^2.8.2"
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAO5G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAK/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CA6E1D;
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAA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