i18next-cli 1.80.0 → 1.80.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 +1 -1
- package/dist/cjs/syncer.js +11 -4
- package/dist/cjs/utils/nested-object.js +7 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/syncer.js +11 -4
- package/dist/esm/utils/nested-object.js +7 -1
- package/package.json +19 -19
- package/types/syncer.d.ts.map +1 -1
- package/types/utils/nested-object.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -39,7 +39,7 @@ const program = new commander.Command();
|
|
|
39
39
|
program
|
|
40
40
|
.name('i18next-cli')
|
|
41
41
|
.description('A unified, high-performance i18next CLI.')
|
|
42
|
-
.version('1.80.
|
|
42
|
+
.version('1.80.2') // This string is replaced with the actual version at build time by rollup
|
|
43
43
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
44
44
|
// new: global config override option
|
|
45
45
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
package/dist/cjs/syncer.js
CHANGED
|
@@ -181,6 +181,13 @@ async function runSyncer(config, options = {}) {
|
|
|
181
181
|
// canonical order, a subsequent `sync` will read that order and reproduce
|
|
182
182
|
// it exactly — the pipeline becomes idempotent.
|
|
183
183
|
const existingSecondaryKeys = nestedObject.getNestedKeys(existingSecondaryTranslations, keySeparator ?? '.');
|
|
184
|
+
// Keep a key flat when the primary or the existing secondary file has it as one flat
|
|
185
|
+
// top-level key, which is how the extractor writes keys like "Loading..." or
|
|
186
|
+
// "Hello. World". Splitting them on the separator would nest them under new parents.
|
|
187
|
+
const keySeparatorFor = (key) => Object.prototype.hasOwnProperty.call(primaryTranslations, key) ||
|
|
188
|
+
Object.prototype.hasOwnProperty.call(existingSecondaryTranslations, key)
|
|
189
|
+
? false
|
|
190
|
+
: (keySeparator ?? '.');
|
|
184
191
|
const handledKeys = new Set();
|
|
185
192
|
// Pass 1: existing keys in their current order (preserves extract's ordering)
|
|
186
193
|
for (const key of existingSecondaryKeys) {
|
|
@@ -188,7 +195,7 @@ async function runSyncer(config, options = {}) {
|
|
|
188
195
|
const primaryValue = nestedObject.getNestedValue(primaryTranslations, key, keySeparator ?? '.');
|
|
189
196
|
const existingValue = nestedObject.getNestedValue(existingSecondaryTranslations, key, keySeparator ?? '.');
|
|
190
197
|
const valueToSet = existingValue ?? defaultValue.resolveDefaultValue(defaultValue$1, key, ns, lang, primaryValue);
|
|
191
|
-
nestedObject.setNestedValue(newSecondaryTranslations, key, valueToSet,
|
|
198
|
+
nestedObject.setNestedValue(newSecondaryTranslations, key, valueToSet, keySeparatorFor(key));
|
|
192
199
|
handledKeys.add(key);
|
|
193
200
|
}
|
|
194
201
|
else if (isLocaleSpecificPluralExtension(key)) {
|
|
@@ -197,14 +204,14 @@ async function runSyncer(config, options = {}) {
|
|
|
197
204
|
// placeholder left by a previous (buggy) sync run and should not
|
|
198
205
|
// be perpetuated. Under --changed-only nothing is ever dropped.
|
|
199
206
|
if ((existingValue !== '' && existingValue != null) || isChangedKey) {
|
|
200
|
-
nestedObject.setNestedValue(newSecondaryTranslations, key, existingValue,
|
|
207
|
+
nestedObject.setNestedValue(newSecondaryTranslations, key, existingValue, keySeparatorFor(key));
|
|
201
208
|
handledKeys.add(key);
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
else if (isChangedKey) {
|
|
205
212
|
// --changed-only: removals are out of scope, keep obsolete keys as-is
|
|
206
213
|
const existingValue = nestedObject.getNestedValue(existingSecondaryTranslations, key, keySeparator ?? '.');
|
|
207
|
-
nestedObject.setNestedValue(newSecondaryTranslations, key, existingValue,
|
|
214
|
+
nestedObject.setNestedValue(newSecondaryTranslations, key, existingValue, keySeparatorFor(key));
|
|
208
215
|
}
|
|
209
216
|
// else: obsolete key — omit it from the output
|
|
210
217
|
}
|
|
@@ -216,7 +223,7 @@ async function runSyncer(config, options = {}) {
|
|
|
216
223
|
continue;
|
|
217
224
|
const primaryValue = nestedObject.getNestedValue(primaryTranslations, key, keySeparator ?? '.');
|
|
218
225
|
const valueToSet = defaultValue.resolveDefaultValue(defaultValue$1, key, ns, lang, primaryValue);
|
|
219
|
-
nestedObject.setNestedValue(newSecondaryTranslations, key, valueToSet,
|
|
226
|
+
nestedObject.setNestedValue(newSecondaryTranslations, key, valueToSet, keySeparatorFor(key));
|
|
220
227
|
}
|
|
221
228
|
}
|
|
222
229
|
untranslatedByLocale[lang] = (untranslatedByLocale[lang] ?? 0) + nestedObject.getNestedKeys(newSecondaryTranslations, keySeparator ?? '.')
|
|
@@ -74,7 +74,13 @@ function getNestedValue(obj, path, keySeparator) {
|
|
|
74
74
|
if (keySeparator === false) {
|
|
75
75
|
return obj[path];
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
const value = path.split(keySeparator).reduce((acc, key) => acc && acc[key], obj);
|
|
78
|
+
// The extractor writes a key that cannot be used as a path ("Loading...", or a
|
|
79
|
+
// natural-language key such as "Hello. World") as a single flat top-level key.
|
|
80
|
+
if (value === undefined && obj != null && Object.prototype.hasOwnProperty.call(obj, path)) {
|
|
81
|
+
return obj[path];
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* Extracts all nested keys from an object, optionally with a prefix.
|
package/dist/esm/cli.js
CHANGED
|
@@ -33,7 +33,7 @@ const program = new Command();
|
|
|
33
33
|
program
|
|
34
34
|
.name('i18next-cli')
|
|
35
35
|
.description('A unified, high-performance i18next CLI.')
|
|
36
|
-
.version('1.80.
|
|
36
|
+
.version('1.80.2') // This string is replaced with the actual version at build time by rollup
|
|
37
37
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
38
38
|
// new: global config override option
|
|
39
39
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
package/dist/esm/syncer.js
CHANGED
|
@@ -179,6 +179,13 @@ async function runSyncer(config, options = {}) {
|
|
|
179
179
|
// canonical order, a subsequent `sync` will read that order and reproduce
|
|
180
180
|
// it exactly — the pipeline becomes idempotent.
|
|
181
181
|
const existingSecondaryKeys = getNestedKeys(existingSecondaryTranslations, keySeparator ?? '.');
|
|
182
|
+
// Keep a key flat when the primary or the existing secondary file has it as one flat
|
|
183
|
+
// top-level key, which is how the extractor writes keys like "Loading..." or
|
|
184
|
+
// "Hello. World". Splitting them on the separator would nest them under new parents.
|
|
185
|
+
const keySeparatorFor = (key) => Object.prototype.hasOwnProperty.call(primaryTranslations, key) ||
|
|
186
|
+
Object.prototype.hasOwnProperty.call(existingSecondaryTranslations, key)
|
|
187
|
+
? false
|
|
188
|
+
: (keySeparator ?? '.');
|
|
182
189
|
const handledKeys = new Set();
|
|
183
190
|
// Pass 1: existing keys in their current order (preserves extract's ordering)
|
|
184
191
|
for (const key of existingSecondaryKeys) {
|
|
@@ -186,7 +193,7 @@ async function runSyncer(config, options = {}) {
|
|
|
186
193
|
const primaryValue = getNestedValue(primaryTranslations, key, keySeparator ?? '.');
|
|
187
194
|
const existingValue = getNestedValue(existingSecondaryTranslations, key, keySeparator ?? '.');
|
|
188
195
|
const valueToSet = existingValue ?? resolveDefaultValue(defaultValue, key, ns, lang, primaryValue);
|
|
189
|
-
setNestedValue(newSecondaryTranslations, key, valueToSet,
|
|
196
|
+
setNestedValue(newSecondaryTranslations, key, valueToSet, keySeparatorFor(key));
|
|
190
197
|
handledKeys.add(key);
|
|
191
198
|
}
|
|
192
199
|
else if (isLocaleSpecificPluralExtension(key)) {
|
|
@@ -195,14 +202,14 @@ async function runSyncer(config, options = {}) {
|
|
|
195
202
|
// placeholder left by a previous (buggy) sync run and should not
|
|
196
203
|
// be perpetuated. Under --changed-only nothing is ever dropped.
|
|
197
204
|
if ((existingValue !== '' && existingValue != null) || isChangedKey) {
|
|
198
|
-
setNestedValue(newSecondaryTranslations, key, existingValue,
|
|
205
|
+
setNestedValue(newSecondaryTranslations, key, existingValue, keySeparatorFor(key));
|
|
199
206
|
handledKeys.add(key);
|
|
200
207
|
}
|
|
201
208
|
}
|
|
202
209
|
else if (isChangedKey) {
|
|
203
210
|
// --changed-only: removals are out of scope, keep obsolete keys as-is
|
|
204
211
|
const existingValue = getNestedValue(existingSecondaryTranslations, key, keySeparator ?? '.');
|
|
205
|
-
setNestedValue(newSecondaryTranslations, key, existingValue,
|
|
212
|
+
setNestedValue(newSecondaryTranslations, key, existingValue, keySeparatorFor(key));
|
|
206
213
|
}
|
|
207
214
|
// else: obsolete key — omit it from the output
|
|
208
215
|
}
|
|
@@ -214,7 +221,7 @@ async function runSyncer(config, options = {}) {
|
|
|
214
221
|
continue;
|
|
215
222
|
const primaryValue = getNestedValue(primaryTranslations, key, keySeparator ?? '.');
|
|
216
223
|
const valueToSet = resolveDefaultValue(defaultValue, key, ns, lang, primaryValue);
|
|
217
|
-
setNestedValue(newSecondaryTranslations, key, valueToSet,
|
|
224
|
+
setNestedValue(newSecondaryTranslations, key, valueToSet, keySeparatorFor(key));
|
|
218
225
|
}
|
|
219
226
|
}
|
|
220
227
|
untranslatedByLocale[lang] = (untranslatedByLocale[lang] ?? 0) + getNestedKeys(newSecondaryTranslations, keySeparator ?? '.')
|
|
@@ -72,7 +72,13 @@ function getNestedValue(obj, path, keySeparator) {
|
|
|
72
72
|
if (keySeparator === false) {
|
|
73
73
|
return obj[path];
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
const value = path.split(keySeparator).reduce((acc, key) => acc && acc[key], obj);
|
|
76
|
+
// The extractor writes a key that cannot be used as a path ("Loading...", or a
|
|
77
|
+
// natural-language key such as "Hello. World") as a single flat top-level key.
|
|
78
|
+
if (value === undefined && obj != null && Object.prototype.hasOwnProperty.call(obj, path)) {
|
|
79
|
+
return obj[path];
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
78
84
|
* Extracts all nested keys from an object, optionally with a prefix.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.80.
|
|
3
|
+
"version": "1.80.2",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -53,42 +53,42 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@rollup/plugin-replace": "^6.0.3",
|
|
56
|
-
"@rollup/plugin-terser": "^1.0.
|
|
57
|
-
"@rollup/plugin-typescript": "^12.3.
|
|
56
|
+
"@rollup/plugin-terser": "^1.0.2",
|
|
57
|
+
"@rollup/plugin-typescript": "^12.3.1",
|
|
58
58
|
"@types/inquirer": "^9.0.10",
|
|
59
|
-
"@types/node": "^26.6.
|
|
59
|
+
"@types/node": "^26.6.5",
|
|
60
60
|
"@types/react": "^19.3.0",
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@vitest/coverage-v8": "^5.0.
|
|
61
|
+
"@typescript-eslint/parser": "^8.72.0",
|
|
62
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
63
63
|
"eslint": "^9.39.5",
|
|
64
64
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
65
65
|
"eslint-plugin-import": "^2.32.0",
|
|
66
|
-
"memfs": "^4.
|
|
67
|
-
"neostandard": "^0.
|
|
68
|
-
"react": "^19.3.
|
|
69
|
-
"rollup": "^4.
|
|
66
|
+
"memfs": "^4.80.0",
|
|
67
|
+
"neostandard": "^0.14.1",
|
|
68
|
+
"react": "^19.3.1",
|
|
69
|
+
"rollup": "^4.65.0",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"unplugin-swc": "^2.0.0",
|
|
72
|
-
"vitest": "^5.0.
|
|
72
|
+
"vitest": "^5.0.5"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@croct/json5-parser": "^0.2.2",
|
|
76
|
-
"@formatjs/icu-messageformat-parser": "^3.5.
|
|
77
|
-
"@swc/core": "^1.16.
|
|
76
|
+
"@formatjs/icu-messageformat-parser": "^3.5.22",
|
|
77
|
+
"@swc/core": "^1.16.20",
|
|
78
78
|
"chokidar": "^5.0.0",
|
|
79
79
|
"commander": "^15.0.0",
|
|
80
|
-
"execa": "^10.
|
|
80
|
+
"execa": "^10.2.1",
|
|
81
81
|
"glob": "^13.0.6",
|
|
82
|
-
"i18next": "^26.5.
|
|
83
|
-
"i18next-resources-for-ts": "^2.1.
|
|
84
|
-
"inquirer": "^14.2.
|
|
82
|
+
"i18next": "^26.5.10",
|
|
83
|
+
"i18next-resources-for-ts": "^2.1.2",
|
|
84
|
+
"inquirer": "^14.2.4",
|
|
85
85
|
"jiti": "^2.7.0",
|
|
86
86
|
"jsonc-parser": "^3.3.1",
|
|
87
|
-
"magic-string": "^1.4.
|
|
87
|
+
"magic-string": "^1.4.3",
|
|
88
88
|
"messageformat": "^4.1.0",
|
|
89
89
|
"minimatch": "^10.2.6",
|
|
90
90
|
"ora": "^9.4.1",
|
|
91
|
-
"react-i18next": "^17.1.
|
|
91
|
+
"react-i18next": "^17.1.8",
|
|
92
92
|
"yaml": "^2.9.1"
|
|
93
93
|
}
|
|
94
94
|
}
|
package/types/syncer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncer.d.ts","sourceRoot":"","sources":["../src/syncer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAU9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"syncer.d.ts","sourceRoot":"","sources":["../src/syncer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAU9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,iBAyOzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nested-object.d.ts","sourceRoot":"","sources":["../../src/utils/nested-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,YAAY,EAAE,MAAM,GAAG,KAAK,GAC3B,IAAI,CAoCN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,KAAK,GAC3B,GAAG,
|
|
1
|
+
{"version":3,"file":"nested-object.d.ts","sourceRoot":"","sources":["../../src/utils/nested-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,YAAY,EAAE,MAAM,GAAG,KAAK,GAC3B,IAAI,CAoCN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,KAAK,GAC3B,GAAG,CAWL;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,EAAE,MAAM,SAAK,GAAG,MAAM,EAAE,CAa/F"}
|