i18next-cli 1.42.7 → 1.42.8

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
@@ -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.42.7'); // This string is replaced with the actual version at build time by rollup
31
+ .version('1.42.8'); // 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
@@ -796,6 +796,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
796
796
  const namespacesToProcess = existingIsNamespaced
797
797
  ? new Set([...keysByNS.keys(), ...existingKeys])
798
798
  : new Set([...keysByNS.keys(), NO_NS_TOKEN]);
799
+ // Remove ignored namespaces so their section is never modified
800
+ for (const ns of ignoreNamespaces) {
801
+ namespacesToProcess.delete(ns);
802
+ }
799
803
  for (const nsKey of namespacesToProcess) {
800
804
  const nsKeys = keysByNS.get(nsKey) || [];
801
805
  if (nsKey === NO_NS_TOKEN) {
@@ -808,6 +812,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
808
812
  newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults);
809
813
  }
810
814
  }
815
+ // Preserve ignored namespaces as-is from the existing merged file
816
+ for (const ns of ignoreNamespaces) {
817
+ if (ns in existingMergedFile) {
818
+ newMergedTranslations[ns] = existingMergedFile[ns];
819
+ }
820
+ }
811
821
  const oldContent = JSON.stringify(existingMergedFile, null, indentation);
812
822
  const newContent = JSON.stringify(newMergedTranslations, null, indentation);
813
823
  // Push a single result for the merged file
@@ -833,6 +843,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
833
843
  namespacesToProcess.add(ns);
834
844
  }
835
845
  }
846
+ // Remove ignored namespaces so their files are never modified
847
+ for (const ns of ignoreNamespaces) {
848
+ namespacesToProcess.delete(ns);
849
+ }
836
850
  // Process each namespace individually and create a result for each one
837
851
  for (const ns of namespacesToProcess) {
838
852
  const nsKeys = keysByNS.get(ns) || [];
@@ -23,6 +23,22 @@ function extractInterpolationKeys(str, config) {
23
23
  }
24
24
  return keys;
25
25
  }
26
+ // Known i18next t() option keys that are NOT interpolation parameters.
27
+ // These should not be flagged as "unused" in the translation string.
28
+ const i18nextOptionKeys = new Set([
29
+ 'defaultValue', 'count', 'context', 'ns', 'lng', 'lngs',
30
+ 'fallbackLng', 'returnDetails', 'returnObjects', 'joinArrays',
31
+ 'postProcess', 'interpolation', 'skipInterpolation', 'replace',
32
+ 'ordinal', 'keySeparator', 'nsSeparator', 'tDescription',
33
+ ]);
34
+ function isI18nextOptionKey(key) {
35
+ if (i18nextOptionKeys.has(key))
36
+ return true;
37
+ // defaultValue_one, defaultValue_other, defaultValue_many, etc.
38
+ if (key.startsWith('defaultValue_'))
39
+ return true;
40
+ return false;
41
+ }
26
42
  // Helper to lint interpolation parameter errors in t() calls
27
43
  function lintInterpolationParams(ast, code, config) {
28
44
  const issues = [];
@@ -132,7 +148,10 @@ function lintInterpolationParams(ast, code, config) {
132
148
  }
133
149
  }
134
150
  // For each provided param, check if it is used either directly or as the root of a dotted key.
151
+ // Skip known i18next t() option keys that are not interpolation parameters.
135
152
  for (const pk of paramKeys) {
153
+ if (isI18nextOptionKey(pk))
154
+ continue;
136
155
  const isUsed = keys.some(k => k === pk || k.split('.')[0] === pk);
137
156
  if (!isUsed) {
138
157
  issues.push({
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.42.7'); // This string is replaced with the actual version at build time by rollup
29
+ .version('1.42.8'); // 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
@@ -794,6 +794,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
794
794
  const namespacesToProcess = existingIsNamespaced
795
795
  ? new Set([...keysByNS.keys(), ...existingKeys])
796
796
  : new Set([...keysByNS.keys(), NO_NS_TOKEN]);
797
+ // Remove ignored namespaces so their section is never modified
798
+ for (const ns of ignoreNamespaces) {
799
+ namespacesToProcess.delete(ns);
800
+ }
797
801
  for (const nsKey of namespacesToProcess) {
798
802
  const nsKeys = keysByNS.get(nsKey) || [];
799
803
  if (nsKey === NO_NS_TOKEN) {
@@ -806,6 +810,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
806
810
  newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults);
807
811
  }
808
812
  }
813
+ // Preserve ignored namespaces as-is from the existing merged file
814
+ for (const ns of ignoreNamespaces) {
815
+ if (ns in existingMergedFile) {
816
+ newMergedTranslations[ns] = existingMergedFile[ns];
817
+ }
818
+ }
809
819
  const oldContent = JSON.stringify(existingMergedFile, null, indentation);
810
820
  const newContent = JSON.stringify(newMergedTranslations, null, indentation);
811
821
  // Push a single result for the merged file
@@ -831,6 +841,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
831
841
  namespacesToProcess.add(ns);
832
842
  }
833
843
  }
844
+ // Remove ignored namespaces so their files are never modified
845
+ for (const ns of ignoreNamespaces) {
846
+ namespacesToProcess.delete(ns);
847
+ }
834
848
  // Process each namespace individually and create a result for each one
835
849
  for (const ns of namespacesToProcess) {
836
850
  const nsKeys = keysByNS.get(ns) || [];
@@ -21,6 +21,22 @@ function extractInterpolationKeys(str, config) {
21
21
  }
22
22
  return keys;
23
23
  }
24
+ // Known i18next t() option keys that are NOT interpolation parameters.
25
+ // These should not be flagged as "unused" in the translation string.
26
+ const i18nextOptionKeys = new Set([
27
+ 'defaultValue', 'count', 'context', 'ns', 'lng', 'lngs',
28
+ 'fallbackLng', 'returnDetails', 'returnObjects', 'joinArrays',
29
+ 'postProcess', 'interpolation', 'skipInterpolation', 'replace',
30
+ 'ordinal', 'keySeparator', 'nsSeparator', 'tDescription',
31
+ ]);
32
+ function isI18nextOptionKey(key) {
33
+ if (i18nextOptionKeys.has(key))
34
+ return true;
35
+ // defaultValue_one, defaultValue_other, defaultValue_many, etc.
36
+ if (key.startsWith('defaultValue_'))
37
+ return true;
38
+ return false;
39
+ }
24
40
  // Helper to lint interpolation parameter errors in t() calls
25
41
  function lintInterpolationParams(ast, code, config) {
26
42
  const issues = [];
@@ -130,7 +146,10 @@ function lintInterpolationParams(ast, code, config) {
130
146
  }
131
147
  }
132
148
  // For each provided param, check if it is used either directly or as the root of a dotted key.
149
+ // Skip known i18next t() option keys that are not interpolation parameters.
133
150
  for (const pk of paramKeys) {
151
+ if (isI18nextOptionKey(pk))
152
+ continue;
134
153
  const isUsed = keys.some(k => k === pk || k.split('.')[0] === pk);
135
154
  if (!isUsed) {
136
155
  issues.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.42.7",
3
+ "version": "1.42.8",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAgyBnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EAChB,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CACb,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAmJ9B"}
1
+ {"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAgyBnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EAChB,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CACb,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAoK9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AA6I3D,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE;QAAC;YACT,OAAO,EAAE,MAAM,CAAC;SACjB;KAAC,CAAC;IACH,IAAI,EAAE;QAAC;YACL,OAAO,EAAE,OAAO,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;SAC1C;KAAC,CAAC;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACvB,CAAA;AAED,eAAO,MAAM,uBAAuB,UA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