i18next-cli 1.51.4 → 1.51.6

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.51.4'); // This string is replaced with the actual version at build time by rollup
34
+ .version('1.51.6'); // 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
@@ -149,8 +149,20 @@ class ExpressionResolver {
149
149
  return;
150
150
  }
151
151
  }
152
- // For other initializers, try to resolve to one-or-more strings
152
+ // For other initializers, try to resolve to one-or-more strings.
153
+ // Also check the type annotation: when the type resolves to a broader set
154
+ // (e.g. an enum type), prefer it over the single initializer value.
155
+ // Example: `const status: Status = Status.New` — the init resolves to ["new"]
156
+ // but the type annotation `Status` resolves to ["new", "active", "done"].
153
157
  const vals = this.resolvePossibleStringValuesFromExpression(init);
158
+ const typeAnnotation = this.extractTypeAnnotation(node.id);
159
+ if (typeAnnotation) {
160
+ const typeVals = this.resolvePossibleStringValuesFromType(typeAnnotation);
161
+ if (typeVals.length > vals.length) {
162
+ this.variableTable.set(name, typeVals);
163
+ return;
164
+ }
165
+ }
154
166
  if (vals.length > 0) {
155
167
  this.variableTable.set(name, vals);
156
168
  return;
@@ -118,7 +118,7 @@ class ScopeManager {
118
118
  return undefined;
119
119
  }
120
120
  getUseTranslationConfig(name) {
121
- const useTranslationNames = this.config.extract.useTranslationNames || ['useTranslation'];
121
+ const useTranslationNames = this.config.extract.useTranslationNames || ['useTranslation', 'getT', 'useT'];
122
122
  for (const item of useTranslationNames) {
123
123
  if (typeof item === 'string' && item === name) {
124
124
  // Default behavior for simple string entries
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.51.4'); // This string is replaced with the actual version at build time by rollup
32
+ .version('1.51.6'); // 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
@@ -147,8 +147,20 @@ class ExpressionResolver {
147
147
  return;
148
148
  }
149
149
  }
150
- // For other initializers, try to resolve to one-or-more strings
150
+ // For other initializers, try to resolve to one-or-more strings.
151
+ // Also check the type annotation: when the type resolves to a broader set
152
+ // (e.g. an enum type), prefer it over the single initializer value.
153
+ // Example: `const status: Status = Status.New` — the init resolves to ["new"]
154
+ // but the type annotation `Status` resolves to ["new", "active", "done"].
151
155
  const vals = this.resolvePossibleStringValuesFromExpression(init);
156
+ const typeAnnotation = this.extractTypeAnnotation(node.id);
157
+ if (typeAnnotation) {
158
+ const typeVals = this.resolvePossibleStringValuesFromType(typeAnnotation);
159
+ if (typeVals.length > vals.length) {
160
+ this.variableTable.set(name, typeVals);
161
+ return;
162
+ }
163
+ }
152
164
  if (vals.length > 0) {
153
165
  this.variableTable.set(name, vals);
154
166
  return;
@@ -116,7 +116,7 @@ class ScopeManager {
116
116
  return undefined;
117
117
  }
118
118
  getUseTranslationConfig(name) {
119
- const useTranslationNames = this.config.extract.useTranslationNames || ['useTranslation'];
119
+ const useTranslationNames = this.config.extract.useTranslationNames || ['useTranslation', 'getT', 'useT'];
120
120
  for (const item of useTranslationNames) {
121
121
  if (typeof item === 'string' && item === name) {
122
122
  // Default behavior for simple string entries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.51.4",
3
+ "version": "1.51.6",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,19 +56,19 @@
56
56
  "@rollup/plugin-terser": "^1.0.0",
57
57
  "@rollup/plugin-typescript": "^12.3.0",
58
58
  "@types/inquirer": "^9.0.9",
59
- "@types/node": "^25.5.0",
59
+ "@types/node": "^25.5.2",
60
60
  "@types/react": "^19.2.14",
61
- "@typescript-eslint/parser": "^8.57.1",
62
- "@vitest/coverage-v8": "^4.1.0",
61
+ "@typescript-eslint/parser": "^8.58.0",
62
+ "@vitest/coverage-v8": "^4.1.2",
63
63
  "eslint": "^9.39.2",
64
64
  "eslint-import-resolver-typescript": "^4.4.4",
65
65
  "eslint-plugin-import": "^2.32.0",
66
66
  "memfs": "^4.57.1",
67
67
  "neostandard": "^0.13.0",
68
- "rollup": "^4.60.0",
69
- "typescript": "^5.9.3",
68
+ "rollup": "^4.60.1",
69
+ "typescript": "^6.0.2",
70
70
  "unplugin-swc": "^1.5.9",
71
- "vitest": "^4.1.0"
71
+ "vitest": "^4.1.2"
72
72
  },
73
73
  "dependencies": {
74
74
  "@croct/json5-parser": "^0.2.2",
@@ -82,10 +82,10 @@
82
82
  "jiti": "^2.6.1",
83
83
  "jsonc-parser": "^3.3.1",
84
84
  "magic-string": "^0.30.21",
85
- "minimatch": "^10.2.4",
85
+ "minimatch": "^10.2.5",
86
86
  "ora": "^9.3.0",
87
87
  "react": "^19.2.4",
88
- "react-i18next": "^17.0.0",
88
+ "react-i18next": "^17.0.2",
89
89
  "yaml": "^2.8.3"
90
90
  }
91
91
  }
package/tsconfig.json CHANGED
@@ -5,7 +5,7 @@
5
5
  /* Basic Options */
6
6
  // "incremental": true, /* Enable incremental compilation */
7
7
  "target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
- "module": "ES2022", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
8
+ "module": "Node16", /* Specify module code generation. */
9
9
  // "lib": [], /* Specify library files to be included in the compilation. */
10
10
  // "allowJs": true, /* Allow javascript files to be compiled. */
11
11
  // "checkJs": true, /* Report errors in .js files. */
@@ -15,7 +15,7 @@
15
15
  // "sourceMap": true, /* Generates corresponding '.map' file. */
16
16
  // "outFile": "./", /* Concatenate and emit output to single file. */
17
17
  // "outDir": "./", /* Redirect output structure to the directory. */
18
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18
+ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
19
  // "composite": true, /* Enable project compilation */
20
20
  // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
21
  // "removeComments": true, /* Do not emit comments to output. */
@@ -41,7 +41,7 @@
41
41
  // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
42
 
43
43
  /* Module Resolution Options */
44
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
44
+ "moduleResolution": "node16", /* Specify module resolution strategy. */
45
45
  // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46
46
  // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47
47
  // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
@@ -1 +1 @@
1
- {"version":3,"file":"expression-resolver.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/expression-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkD,MAAM,WAAW,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,KAAK,CAAiB;IAK9B,OAAO,CAAC,aAAa,CAA4D;IAGjF,OAAO,CAAC,eAAe,CAAiD;IAIxE,OAAO,CAAC,cAAc,CAAmC;IAIzD,OAAO,CAAC,mBAAmB,CAAmC;IAI9D,OAAO,CAAC,oBAAoB,CAAmC;IAI/D,OAAO,CAAC,kBAAkB,CAAmC;gBAEhD,KAAK,EAAE,eAAe;IAInC;;OAEG;IACI,gBAAgB,IAAK,IAAI;IA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