i18next-cli 1.74.6 → 1.74.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.
Files changed (34) hide show
  1. package/README.md +5 -0
  2. package/dist/cjs/cli.js +1 -1
  3. package/dist/cjs/extractor/core/ast-visitors.js +59 -9
  4. package/dist/cjs/extractor/core/extractor.js +5 -4
  5. package/dist/cjs/extractor/core/key-finder.js +1 -1
  6. package/dist/cjs/extractor/core/translation-manager.js +13 -5
  7. package/dist/cjs/extractor/parsers/call-expression-handler.js +53 -52
  8. package/dist/cjs/extractor/parsers/comment-parser.js +16 -1
  9. package/dist/cjs/extractor/parsers/expression-resolver.js +19 -5
  10. package/dist/cjs/extractor/parsers/jsx-handler.js +18 -10
  11. package/dist/esm/cli.js +1 -1
  12. package/dist/esm/extractor/core/ast-visitors.js +60 -10
  13. package/dist/esm/extractor/core/extractor.js +5 -4
  14. package/dist/esm/extractor/core/key-finder.js +1 -1
  15. package/dist/esm/extractor/core/translation-manager.js +13 -5
  16. package/dist/esm/extractor/parsers/call-expression-handler.js +53 -53
  17. package/dist/esm/extractor/parsers/comment-parser.js +16 -1
  18. package/dist/esm/extractor/parsers/expression-resolver.js +19 -6
  19. package/dist/esm/extractor/parsers/jsx-handler.js +19 -11
  20. package/package.json +2 -2
  21. package/types/extractor/core/ast-visitors.d.ts +3 -1
  22. package/types/extractor/core/ast-visitors.d.ts.map +1 -1
  23. package/types/extractor/core/extractor.d.ts.map +1 -1
  24. package/types/extractor/core/key-finder.d.ts +1 -0
  25. package/types/extractor/core/key-finder.d.ts.map +1 -1
  26. package/types/extractor/core/translation-manager.d.ts +2 -1
  27. package/types/extractor/core/translation-manager.d.ts.map +1 -1
  28. package/types/extractor/parsers/call-expression-handler.d.ts +25 -25
  29. package/types/extractor/parsers/call-expression-handler.d.ts.map +1 -1
  30. package/types/extractor/parsers/comment-parser.d.ts +3 -2
  31. package/types/extractor/parsers/comment-parser.d.ts.map +1 -1
  32. package/types/extractor/parsers/expression-resolver.d.ts +5 -3
  33. package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
  34. package/types/extractor/parsers/jsx-handler.d.ts.map +1 -1
@@ -1,7 +1,8 @@
1
1
  import { ScopeManager } from '../parsers/scope-manager.js';
2
- import { ExpressionResolver } from '../parsers/expression-resolver.js';
2
+ import { ExpressionResolver, nestedMembers } from '../parsers/expression-resolver.js';
3
3
  import { CallExpressionHandler } from '../parsers/call-expression-handler.js';
4
4
  import { JSXHandler } from '../parsers/jsx-handler.js';
5
+ import { unwrapParens } from '../parsers/ast-utils.js';
5
6
 
6
7
  /**
7
8
  * Array iteration methods whose callback we can bind, mapped to the position of
@@ -18,6 +19,24 @@ const ITERATION_METHODS = {
18
19
  reduce: 1,
19
20
  reduceRight: 1,
20
21
  };
22
+ // `FC<Props>` / `React.FC<Props>` / `FunctionComponent<Props>` → `Props`
23
+ const COMPONENT_TYPES = new Set(['FC', 'FunctionComponent', 'VFC', 'VoidFunctionComponent']);
24
+ function componentPropsType(type) {
25
+ if (type?.type !== 'TsTypeReference')
26
+ return undefined;
27
+ const name = type.typeName?.type === 'TsQualifiedName' ? type.typeName.right?.value : type.typeName?.value;
28
+ return COMPONENT_TYPES.has(name) ? type.typeParams?.params?.[0] : undefined;
29
+ }
30
+ // `memo(fn)` / `forwardRef(fn)` → `fn`, and which type argument types its props:
31
+ // `memo<Props>` → 0, `forwardRef<Ref, Props>` → 1
32
+ const PROPS_TYPE_ARG = { memo: 0, forwardRef: 1 };
33
+ function reactWrapper(node) {
34
+ if (node?.type !== 'CallExpression')
35
+ return undefined;
36
+ const name = node.callee?.type === 'MemberExpression' ? node.callee.property?.value : node.callee?.value;
37
+ const propsTypeIndex = PROPS_TYPE_ARG[name];
38
+ return propsTypeIndex === undefined ? undefined : { fn: unwrapParens(node.arguments?.[0]?.expression), propsTypeIndex };
39
+ }
21
40
  /**
22
41
  * AST visitor class that traverses JavaScript/TypeScript syntax trees to extract translation keys.
23
42
  *
@@ -48,12 +67,16 @@ class ASTVisitors {
48
67
  get objectKeys() {
49
68
  return this.callExpressionHandler.objectKeys;
50
69
  }
70
+ // Key patterns of commented template literals, `// t(`QUARTER.${q}`)` → `QUARTER.*`
71
+ keepPatterns = [];
51
72
  scopeManager;
52
73
  expressionResolver;
53
74
  callExpressionHandler;
54
75
  jsxHandler;
55
76
  currentFile = '';
56
77
  currentCode = '';
78
+ // `const C: React.FC<Props> = (props) => …` → the function → `Props`
79
+ componentPropsTypes = new WeakMap();
57
80
  /**
58
81
  * Creates a new AST visitor instance.
59
82
  *
@@ -259,11 +282,13 @@ class ASTVisitors {
259
282
  let ident;
260
283
  if (!p)
261
284
  continue;
285
+ // The props of `const C: React.FC<Props> = (props) => …` are typed by `Props`
286
+ const inheritedType = p === params[0] ? this.componentPropsTypes.get(node) : undefined;
262
287
  // Destructured object param: `function f({ size }: IProps)`.
263
288
  // Bind each destructured local name to its interface member's values.
264
289
  const pat = p.pat ?? p.pattern ?? p;
265
290
  if (pat.type === 'ObjectPattern') {
266
- const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation;
291
+ const patType = pat.typeAnnotation?.typeAnnotation ?? pat.typeAnnotation ?? inheritedType;
267
292
  const members = this.expressionResolver.resolveTypeMembers(patType);
268
293
  for (const prop of (pat.properties ?? [])) {
269
294
  // `{ size }` / `{ size = 'all' }` → AssignmentPatternProperty (local name is the key)
@@ -287,12 +312,25 @@ class ASTVisitors {
287
312
  }
288
313
  // `({ t }: { t: TFunction<'ns'> })` → bind `t` to that namespace
289
314
  this.bindTFunctionParam(localName, this.getMemberTypeNode(patType, memberName), typeParamConstraints);
290
- if (!members?.[memberName])
315
+ if (members?.[memberName]) {
316
+ this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
317
+ if (!paramTemporaries)
318
+ paramTemporaries = [];
319
+ paramTemporaries.push(localName);
291
320
  continue;
292
- this.expressionResolver.setTemporaryVariable(localName, members[memberName]);
293
- if (!paramTemporaries)
294
- paramTemporaries = [];
295
- paramTemporaries.push(localName);
321
+ }
322
+ // `({ Bar }: DeepObject)` → `Bar.status`; `({ items }: Props)` → `items.map(({ kind }) => …)`
323
+ const nested = nestedMembers(members, memberName);
324
+ if (!nested)
325
+ continue;
326
+ this.expressionResolver.setTemporaryObjectVariable(localName, nested);
327
+ this.expressionResolver.setArrayElementMembers(localName, nested);
328
+ if (!paramObjectTemporaries)
329
+ paramObjectTemporaries = [];
330
+ paramObjectTemporaries.push(localName);
331
+ if (!paramArrayTemporaries)
332
+ paramArrayTemporaries = [];
333
+ paramArrayTemporaries.push(localName);
296
334
  }
297
335
  continue;
298
336
  }
@@ -336,7 +374,7 @@ class ASTVisitors {
336
374
  paramDefaults.push(paramKey);
337
375
  }
338
376
  // Try to locate TypeScript type node carried on the identifier.
339
- const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation));
377
+ const rawTypeAnn = (ident.typeAnnotation ?? p.typeAnnotation ?? (p.left && p.left.typeAnnotation) ?? inheritedType);
340
378
  let typeAnn;
341
379
  if (rawTypeAnn) {
342
380
  // SWC may wrap the actual TS type in a wrapper like TsTypeAnn / TsTypeAnnotation
@@ -395,12 +433,18 @@ class ASTVisitors {
395
433
  // --- VISIT LOGIC ---
396
434
  // Handle specific node types
397
435
  switch (node.type) {
398
- case 'VariableDeclarator':
436
+ case 'VariableDeclarator': {
399
437
  this.scopeManager.handleVariableDeclarator(node);
400
438
  // Capture simple variable initializers so the expressionResolver can
401
439
  // resolve identifiers / member expressions that reference them.
402
440
  this.expressionResolver.captureVariableDeclarator(node);
441
+ // `const C: React.FC<Props> = (props) => …` / `= memo((props) => …)`
442
+ const propsType = componentPropsType(node.id?.typeAnnotation?.typeAnnotation);
443
+ const init = unwrapParens(node.init);
444
+ if (propsType && init)
445
+ this.componentPropsTypes.set(reactWrapper(init)?.fn ?? init, propsType);
403
446
  break;
447
+ }
404
448
  case 'TSEnumDeclaration':
405
449
  case 'TsEnumDeclaration':
406
450
  case 'TsEnumDecl':
@@ -423,9 +467,15 @@ class ASTVisitors {
423
467
  case 'FnDecl':
424
468
  this.expressionResolver.captureFunctionDeclaration(node);
425
469
  break;
426
- case 'CallExpression':
470
+ case 'CallExpression': {
427
471
  this.callExpressionHandler.handleCallExpression(node, this.scopeManager.getVarFromScope.bind(this.scopeManager));
472
+ // `forwardRef<Ref, Props>((props, ref) => …)` / `memo<Props>((props) => …)`
473
+ const wrapper = reactWrapper(node);
474
+ const propsType = wrapper && node.typeArguments?.params?.[wrapper.propsTypeIndex];
475
+ if (propsType && wrapper.fn)
476
+ this.componentPropsTypes.set(wrapper.fn, propsType);
428
477
  break;
478
+ }
429
479
  case 'NewExpression':
430
480
  // Handle NewExpression similarly to CallExpression (e.g., new TranslatedError(...))
431
481
  // NewExpression has the same structure: callee and arguments
@@ -54,9 +54,10 @@ async function runExtractor(config, options = {}) {
54
54
  const spinner = createSpinnerLike('Running i18next key extractor...\n', { quiet: !!options.quiet, logger: options.logger });
55
55
  try {
56
56
  const fileErrors = [];
57
- const { allKeys, objectKeys } = await findKeys(config, internalLogger, fileErrors);
57
+ const { allKeys, objectKeys, keepPatterns } = await findKeys(config, internalLogger, fileErrors);
58
58
  spinner.text = `Found ${allKeys.size} unique keys. Updating translation files...`;
59
59
  const results = await getTranslations(allKeys, objectKeys, config, {
60
+ keepPatterns,
60
61
  syncPrimaryWithDefaults: options.syncPrimaryWithDefaults,
61
62
  syncAll: options.syncAll,
62
63
  trustDerivedDefaults: options.trustDerivedDefaults,
@@ -302,7 +303,7 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
302
303
  astVisitors.visit(ast);
303
304
  // 4. THEN: Extract keys from comments with scope resolution (now scope info is available)
304
305
  if (config.extract.extractFromComments !== false) {
305
- extractKeysFromComments(code, pluginContext, config, astVisitors.getVarFromScope.bind(astVisitors));
306
+ extractKeysFromComments(code, pluginContext, config, astVisitors.getVarFromScope.bind(astVisitors), astVisitors.keepPatterns);
306
307
  }
307
308
  }
308
309
  catch (error) {
@@ -426,8 +427,8 @@ async function extract(config, { syncPrimaryWithDefaults = false } = {}) {
426
427
  config.extract.secondaryLanguages ||= config.locales.filter((l) => l !== config?.extract?.primaryLanguage);
427
428
  config.extract.functions ||= ['t', '*.t'];
428
429
  config.extract.transComponents ||= ['Trans'];
429
- const { allKeys, objectKeys } = await findKeys(config);
430
- return getTranslations(allKeys, objectKeys, config, { syncPrimaryWithDefaults });
430
+ const { allKeys, objectKeys, keepPatterns } = await findKeys(config);
431
+ return getTranslations(allKeys, objectKeys, config, { syncPrimaryWithDefaults, keepPatterns });
431
432
  }
432
433
 
433
434
  export { extract, preScanFile, processFile, runExtractor };
@@ -116,7 +116,7 @@ async function findKeys(config, logger = new ConsoleLogger(), fileErrors) {
116
116
  ek.isExpandedPlural = true;
117
117
  }
118
118
  }
119
- return { allKeys, objectKeys: astVisitors.objectKeys };
119
+ return { allKeys, objectKeys: astVisitors.objectKeys, keepPatterns: astVisitors.keepPatterns };
120
120
  }
121
121
  /**
122
122
  * Processes source files using glob patterns from configuration.
@@ -164,7 +164,7 @@ function sortObjectCodeUnit(obj) {
164
164
  * A helper function to build a new translation object for a single namespace.
165
165
  * This centralizes the core logic of merging keys.
166
166
  */
167
- function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, namespace, preservePatterns = [], objectKeys = new Set(), syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, primaryExistingTranslations = {}, logger = new ConsoleLogger()) {
167
+ function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, namespace, preservePatterns = [], objectKeys = new Set(), syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, primaryExistingTranslations = {}, logger = new ConsoleLogger(), keepPatterns = []) {
168
168
  const { keySeparator = '.', sort = true, removeUnusedKeys = true, defaultValue: emptyDefaultValue = '', pluralSeparator = '_', contextSeparator = '_', preserveContextVariants = false, } = config.extract;
169
169
  const primaryLanguage = config.extract.primaryLanguage || config.locales[0] || 'en';
170
170
  const nsSep = typeof config.extract.nsSeparator === 'string' ? config.extract.nsSeparator : ':';
@@ -379,12 +379,20 @@ function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale,
379
379
  }
380
380
  return false;
381
381
  };
382
+ // Patterns of commented template literals in this namespace, `// t(`QUARTER.${q}`)` (#304).
383
+ // Unlike preservePatterns they only keep existing keys, so code still extracts matching keys.
384
+ const keepRegexes = keepPatterns
385
+ .filter(p => !namespace || !p.ns || p.ns === '*' || p.ns === namespace)
386
+ .map(p => globToRegex(p.key));
382
387
  // Helper to check if an existing key should be preserved
383
388
  const shouldPreserveExistingKey = (key) => {
384
389
  // 1) keys nested under a returnObjects / selector-API base key
385
390
  if (isUnderObjectKey(key)) {
386
391
  return true;
387
392
  }
393
+ if (keepRegexes.some(re => re.test(key))) {
394
+ return true;
395
+ }
388
396
  // 2) regex-style patterns
389
397
  if (preservePatterns.some(re => re.test(key))) {
390
398
  return true;
@@ -1136,7 +1144,7 @@ async function reattributeFallbackNsKeys(keysByNS, noNsToken, config, primaryLan
1136
1144
  * // Results contain update status and new/existing translations for each locale.
1137
1145
  * ```
1138
1146
  */
1139
- async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, logger = new ConsoleLogger() } = {}) {
1147
+ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, logger = new ConsoleLogger(), keepPatterns = [] } = {}) {
1140
1148
  config.extract.primaryLanguage ||= config.locales[0] || 'en';
1141
1149
  const primaryLanguage = config.extract.primaryLanguage || config.locales[0] || 'en';
1142
1150
  config.extract.secondaryLanguages ||= config.locales.filter((l) => l !== primaryLanguage);
@@ -1233,13 +1241,13 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
1233
1241
  const nsKeys = keysByNS.get(nsKey) || [];
1234
1242
  if (isTopLevel(nsKey)) {
1235
1243
  // keys without namespace -> merged into top-level of the merged file
1236
- const built = buildNewTranslationsForNs(nsKeys, existingMergedFile, config, locale, undefined, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryMergedFile, logger);
1244
+ const built = buildNewTranslationsForNs(nsKeys, existingMergedFile, config, locale, undefined, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryMergedFile, logger, keepPatterns);
1237
1245
  Object.assign(newMergedTranslations, built);
1238
1246
  }
1239
1247
  else {
1240
1248
  const existingTranslations = existingMergedFile[nsKey] || {};
1241
1249
  const primaryExistingTranslations = primaryMergedFile[nsKey] || {};
1242
- newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger);
1250
+ newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger, keepPatterns);
1243
1251
  }
1244
1252
  }
1245
1253
  // Preserve ignored namespaces as-is from the existing merged file
@@ -1281,7 +1289,7 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
1281
1289
  const primaryExistingTranslations = locale === primaryLanguage
1282
1290
  ? existingTranslations
1283
1291
  : (await loadTranslationFile(primaryOutputPath) || {});
1284
- const newTranslations = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, ns, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger);
1292
+ const newTranslations = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, ns, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger, keepPatterns);
1285
1293
  const oldContent = JSON.stringify(existingTranslations, null, indentation);
1286
1294
  const newContent = JSON.stringify(newTranslations, null, indentation);
1287
1295
  // Push one result per namespace file
@@ -9,6 +9,57 @@ const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
9
9
  // Used to prevent splitting keys like "Error message: not found" into namespace + key.
10
10
  const naturalLanguageChars = /[ ,?!;]/;
11
11
  const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
12
+ /**
13
+ * Mirror i18next's runtime selector rule (v25.8.19 default, or
14
+ * `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
15
+ *
16
+ * **Default mode** — rewrite only when the hook was called with a multi-element
17
+ * namespace array and the path's first segment matches a *secondary* namespace.
18
+ * The primary is intentionally not rewritten (preserves #2405): its keys are
19
+ * exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
20
+ *
21
+ * **Strict mode** — every namespace (primary included) is exposed only under
22
+ * its own key on `$`. So a leading segment matching *any* namespace in the
23
+ * scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
24
+ * Mirrors `i18next/src/selector.js` strict branch.
25
+ *
26
+ * In strict mode we also accept a single-ns scope, falling back to
27
+ * `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
28
+ * (e.g. `useTranslation('only')`).
29
+ *
30
+ * Falls through to the input string when:
31
+ * - the call had no selector (string keys go through this path unchanged),
32
+ * - scope has no namespaces info,
33
+ * - first segment isn't in the scope's namespaces list, or
34
+ * - separators are configured off.
35
+ */
36
+ function applySelectorNsRewrite(key, scopeInfo, config) {
37
+ const strict = config.types?.enableSelector === 'strict';
38
+ // Resolve the effective namespace list for the rule:
39
+ // - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
40
+ // - strict mode: same array if present; otherwise synthesize from `defaultNs`
41
+ const nsCaptured = scopeInfo?.namespaces;
42
+ const nsList = strict
43
+ ? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
44
+ : nsCaptured;
45
+ if (!nsList || nsList.length < (strict ? 1 : 2))
46
+ return key;
47
+ const keySeparator = config.extract.keySeparator;
48
+ const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
49
+ const nsSeparator = config.extract.nsSeparator ?? ':';
50
+ if (keySeparator === false || !nsSeparator)
51
+ return key;
52
+ const firstSepAt = key.indexOf(joiner);
53
+ if (firstSepAt < 0)
54
+ return key;
55
+ const head = key.slice(0, firstSepAt);
56
+ // Default mode excludes the primary; strict mode includes it.
57
+ if (!strict && head === nsList[0])
58
+ return key;
59
+ if (!nsList.includes(head))
60
+ return key;
61
+ return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
62
+ }
12
63
  class CallExpressionHandler {
13
64
  pluginContext;
14
65
  config;
@@ -591,7 +642,7 @@ class CallExpressionHandler {
591
642
  if (keys.length > 0) {
592
643
  for (const k of keys) {
593
644
  originalKeysToProcess.push(k);
594
- keysToProcess.push(this.applySelectorNsRewrite(k, scopeInfo));
645
+ keysToProcess.push(applySelectorNsRewrite(k, scopeInfo, this.config));
595
646
  }
596
647
  isSelectorAPI = true;
597
648
  }
@@ -625,57 +676,6 @@ class CallExpressionHandler {
625
676
  isSelectorAPI,
626
677
  };
627
678
  }
628
- /**
629
- * Mirror i18next's runtime selector rule (v25.8.19 default, or
630
- * `enableSelector: 'strict'` when `types.enableSelector === 'strict'`).
631
- *
632
- * **Default mode** — rewrite only when the hook was called with a multi-element
633
- * namespace array and the path's first segment matches a *secondary* namespace.
634
- * The primary is intentionally not rewritten (preserves #2405): its keys are
635
- * exposed flat on `$`, so `$.primary.foo` means a literal sub-key.
636
- *
637
- * **Strict mode** — every namespace (primary included) is exposed only under
638
- * its own key on `$`. So a leading segment matching *any* namespace in the
639
- * scope's list — primary or secondary, single-ns or multi-ns — is rewritten.
640
- * Mirrors `i18next/src/selector.js` strict branch.
641
- *
642
- * In strict mode we also accept a single-ns scope, falling back to
643
- * `[scopeInfo.defaultNs]` when the scope didn't capture an explicit array
644
- * (e.g. `useTranslation('only')`).
645
- *
646
- * Falls through to the input string when:
647
- * - the call had no selector (string keys go through this path unchanged),
648
- * - scope has no namespaces info,
649
- * - first segment isn't in the scope's namespaces list, or
650
- * - separators are configured off.
651
- */
652
- applySelectorNsRewrite(key, scopeInfo) {
653
- const strict = this.config.types?.enableSelector === 'strict';
654
- // Resolve the effective namespace list for the rule:
655
- // - default mode: only the explicitly-captured `namespaces` array, length ≥ 2
656
- // - strict mode: same array if present; otherwise synthesize from `defaultNs`
657
- const nsCaptured = scopeInfo?.namespaces;
658
- const nsList = strict
659
- ? (nsCaptured ?? (scopeInfo?.defaultNs ? [scopeInfo.defaultNs] : undefined))
660
- : nsCaptured;
661
- if (!nsList || nsList.length < (strict ? 1 : 2))
662
- return key;
663
- const keySeparator = this.config.extract.keySeparator;
664
- const joiner = typeof keySeparator === 'string' ? keySeparator : '.';
665
- const nsSeparator = this.config.extract.nsSeparator ?? ':';
666
- if (keySeparator === false || !nsSeparator)
667
- return key;
668
- const firstSepAt = key.indexOf(joiner);
669
- if (firstSepAt < 0)
670
- return key;
671
- const head = key.slice(0, firstSepAt);
672
- // Default mode excludes the primary; strict mode includes it.
673
- if (!strict && head === nsList[0])
674
- return key;
675
- if (!nsList.includes(head))
676
- return key;
677
- return `${head}${nsSeparator}${key.slice(firstSepAt + joiner.length)}`;
678
- }
679
679
  /**
680
680
  * Extracts translation key(s) from selector API arrow function.
681
681
  *
@@ -1048,4 +1048,4 @@ class CallExpressionHandler {
1048
1048
  }
1049
1049
  }
1050
1050
 
1051
- export { CallExpressionHandler };
1051
+ export { CallExpressionHandler, applySelectorNsRewrite };
@@ -11,6 +11,7 @@ const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
11
11
  * @param pluginContext - Context object with helper methods to add found keys
12
12
  * @param config - Configuration object containing extraction settings
13
13
  * @param scopeResolver - Function to resolve scope information for variables (optional)
14
+ * @param keepPatterns - Collects the key patterns of commented template literals (optional)
14
15
  *
15
16
  * @example
16
17
  * ```typescript
@@ -24,7 +25,7 @@ const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
24
25
  * // Extracts: user.name and app.title with their respective settings
25
26
  * ```
26
27
  */
27
- function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
28
+ function extractKeysFromComments(code, pluginContext, config, scopeResolver, keepPatterns) {
28
29
  // Hardcode the function name to 't' to prevent parsing other functions like 'test()'.
29
30
  const functionNameToFind = 't';
30
31
  // Use a reliable word boundary (\b) to match 't(...)' but not 'http.get(...)'.
@@ -61,6 +62,11 @@ function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
61
62
  if (!key || key.trim() === '') {
62
63
  continue; // Skip empty keys
63
64
  }
65
+ // `t(`QUARTER.${q}`)` cannot name its keys: it becomes the pattern `QUARTER.*`,
66
+ // which keeps the existing keys it matches instead of adding a literal `${q}` (#304)
67
+ const isPattern = match[1] === '`' && key.includes('${');
68
+ if (isPattern)
69
+ key = key.replace(/\$\{[^}]*\}/g, '*');
64
70
  // We'll check preservePatterns after namespace resolution below
65
71
  let ns;
66
72
  const remainder = text.slice(match.index + match[0].length);
@@ -120,6 +126,15 @@ function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
120
126
  // 4. Final fallback to configured default namespace
121
127
  if (!ns)
122
128
  ns = config.extract.defaultNS;
129
+ if (isPattern) {
130
+ // ponytail: a pattern without any static segment (`${a}.${b}`) would keep the whole
131
+ // namespace, so it is dropped
132
+ const keySeparator = config.extract.keySeparator ?? '.';
133
+ const staticPart = key.replace(/\*/g, '');
134
+ if (keySeparator === false ? staticPart : staticPart.split(keySeparator).some(Boolean))
135
+ keepPatterns?.push({ key, ns });
136
+ continue;
137
+ }
123
138
  // 5. Handle context and count combinations based on disablePlurals setting
124
139
  if (config.extract.disablePlurals) {
125
140
  // When plurals are disabled, ignore count for key generation. We still
@@ -550,11 +550,12 @@ class ExpressionResolver {
550
550
  map[memberName] = vals;
551
551
  continue;
552
552
  }
553
- // `Bar: { status: '201' | '400' }` → `Bar.status`
553
+ // `Bar: { status: '201' | '400' }` → `Bar.status`, and the element of
554
+ // `items: Item[]` the same way so `props.items.map(({ size }) => …)` binds
554
555
  this.memberDepth++;
555
556
  let nested;
556
557
  try {
557
- nested = this.resolveTypeMembers(tsType);
558
+ nested = this.resolveTypeMembers(tsType) ?? this.resolveArrayElementMembers(tsType);
558
559
  }
559
560
  finally {
560
561
  this.memberDepth--;
@@ -624,6 +625,9 @@ class ExpressionResolver {
624
625
  if (tsType.type === 'TsArrayType') {
625
626
  return this.resolveTypeMembers(tsType.elemType);
626
627
  }
628
+ if (tsType.type === 'TsTypeOperator' && tsType.op === 'readonly') {
629
+ return this.resolveArrayElementMembers(tsType.typeAnnotation);
630
+ }
627
631
  if (tsType.type === 'TsTypeReference' && tsType.typeName?.type === 'Identifier') {
628
632
  const name = tsType.typeName.value;
629
633
  if (name !== 'Array' && name !== 'ReadonlyArray')
@@ -671,8 +675,8 @@ class ExpressionResolver {
671
675
  return Object.keys(members).length > 0 ? members : undefined;
672
676
  }
673
677
  /**
674
- * The values an iterated array holds: a known constant (`QUARTERS.map(…)`) or an
675
- * inline literal (`([1, 2, 3, 4] as const).map(…)`).
678
+ * The values an iterated array holds: a known constant (`QUARTERS.map(…)`), an
679
+ * inline literal (`([1, 2, 3, 4] as const).map(…)`) or a typed member (`props.colors`).
676
680
  */
677
681
  arrayValuesOf(expr) {
678
682
  expr = unwrapExpr(expr);
@@ -680,11 +684,17 @@ class ExpressionResolver {
680
684
  return this.getVariableValues(expr.value);
681
685
  if (expr?.type === 'ArrayExpression')
682
686
  return this.arrayLiteralValues(expr);
687
+ // `props.colors` where `colors: Color[]`
688
+ if (expr?.type === 'MemberExpression') {
689
+ const vals = this.resolvePossibleStringValuesFromExpression(expr);
690
+ return vals.length > 0 ? vals : undefined;
691
+ }
683
692
  return undefined;
684
693
  }
685
694
  /**
686
695
  * The element member map of an iterated array of objects: a typed or constant
687
- * identifier (`items: IProps[]`) or an inline literal (`[{ unit: 'day' }]`).
696
+ * identifier (`items: IProps[]`), an inline literal (`[{ unit: 'day' }]`) or a
697
+ * typed member (`props.items`).
688
698
  */
689
699
  arrayMembersOf(expr) {
690
700
  expr = unwrapExpr(expr);
@@ -692,6 +702,9 @@ class ExpressionResolver {
692
702
  return this.arrayElementMembers.get(expr.value);
693
703
  if (expr?.type === 'ArrayExpression')
694
704
  return this.arrayLiteralMembers(expr);
705
+ // `props.items` where `items: Item[]`
706
+ if (expr?.type === 'MemberExpression')
707
+ return this.objectMembersOf(expr);
695
708
  return undefined;
696
709
  }
697
710
  /**
@@ -1387,4 +1400,4 @@ class ExpressionResolver {
1387
1400
  }
1388
1401
  }
1389
1402
 
1390
- export { ExpressionResolver };
1403
+ export { ExpressionResolver, nestedMembers };
@@ -1,6 +1,7 @@
1
1
  import { safePluralRules } from '../../utils/plural-rules.js';
2
2
  import { extractFromTransComponent } from './jsx-parser.js';
3
- import { lineColumnFromOffset, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
3
+ import { lineColumnFromOffset, unwrapParens, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
4
+ import { applySelectorNsRewrite } from './call-expression-handler.js';
4
5
 
5
6
  // Checks if a string looks like natural language (contains spaces, punctuation, etc.)
6
7
  const naturalLanguageChars = /[ ,?!;]/;
@@ -167,7 +168,22 @@ class JSXHandler {
167
168
  // If ns is not explicitly set on the component, try to find it from the key
168
169
  // or the `t` prop
169
170
  if (!extractedAttributes.ns) {
171
+ const tProp = node.opening.attributes?.find(attr => attr.type === 'JSXAttribute' &&
172
+ attr.name.type === 'Identifier' &&
173
+ attr.name.value === 't');
174
+ // Check if the prop value is an identifier (e.g., t={t})
175
+ const scopeInfo = tProp?.type === 'JSXAttribute' &&
176
+ tProp.value?.type === 'JSXExpressionContainer' &&
177
+ tProp.value.expression.type === 'Identifier'
178
+ ? getScopeInfo(tProp.value.expression.value)
179
+ : undefined;
180
+ // Trans leaves a selector key to the `t` prop, which routes it into the
181
+ // hook's other namespaces like t() does (react-i18next#1933)
182
+ const isSelector = !!extractedAttributes.keyExpression &&
183
+ unwrapParens(extractedAttributes.keyExpression).type === 'ArrowFunctionExpression';
170
184
  extractedKeys = keysToProcess.map(key => {
185
+ if (isSelector)
186
+ key = applySelectorNsRewrite(key, scopeInfo, this.config);
171
187
  const nsSeparator = this.config.extract.nsSeparator ?? ':';
172
188
  let ns;
173
189
  // If the key contains a namespace separator, it takes precedence
@@ -189,16 +205,8 @@ class JSXHandler {
189
205
  locations
190
206
  };
191
207
  });
192
- const tProp = node.opening.attributes?.find(attr => attr.type === 'JSXAttribute' &&
193
- attr.name.type === 'Identifier' &&
194
- attr.name.value === 't');
195
- // Check if the prop value is an identifier (e.g., t={t})
196
- if (tProp?.type === 'JSXAttribute' &&
197
- tProp.value?.type === 'JSXExpressionContainer' &&
198
- tProp.value.expression.type === 'Identifier') {
199
- const tIdentifier = tProp.value.expression.value;
200
- const scopeInfo = getScopeInfo(tIdentifier);
201
- if (scopeInfo?.defaultNs) {
208
+ if (scopeInfo) {
209
+ if (scopeInfo.defaultNs) {
202
210
  // One copy per namespace when the hook's ns was a conditional (#299)
203
211
  const scopeNamespaces = [scopeInfo.defaultNs, ...(scopeInfo.altNs ?? [])];
204
212
  extractedKeys = extractedKeys.flatMap(key => key.ns ? [key] : scopeNamespaces.map(ns => ({ ...key, ns })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.74.6",
3
+ "version": "1.74.8",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -86,7 +86,7 @@
86
86
  "magic-string": "^1.4.2",
87
87
  "minimatch": "^10.2.6",
88
88
  "ora": "^9.4.1",
89
- "react-i18next": "^17.0.15",
89
+ "react-i18next": "^17.0.16",
90
90
  "yaml": "^2.9.1"
91
91
  }
92
92
  }
@@ -1,5 +1,5 @@
1
1
  import type { Module } from '@swc/core';
2
- import type { PluginContext, I18nextToolkitConfig, Logger, ASTVisitorHooks, ScopeInfo } from '../../types.js';
2
+ import type { PluginContext, I18nextToolkitConfig, Logger, ASTVisitorHooks, ScopeInfo, ExtractedKey } from '../../types.js';
3
3
  import { ScopeManager } from '../parsers/scope-manager.js';
4
4
  import { ExpressionResolver } from '../parsers/expression-resolver.js';
5
5
  /**
@@ -30,12 +30,14 @@ export declare class ASTVisitors {
30
30
  private readonly logger;
31
31
  private hooks;
32
32
  get objectKeys(): Set<string>;
33
+ readonly keepPatterns: ExtractedKey[];
33
34
  readonly scopeManager: ScopeManager;
34
35
  private readonly expressionResolver;
35
36
  private readonly callExpressionHandler;
36
37
  private readonly jsxHandler;
37
38
  private currentFile;
38
39
  private currentCode;
40
+ private readonly componentPropsTypes;
39
41
  /**
40
42
  * Creates a new AST visitor instance.
41
43
  *
@@ -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,gBAAgB,CAAA;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAoBtE;;;;;;;;;;;;;;;;;;;;;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,SAAgB,YAAY,EAAE,YAAY,CAAA;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,W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O,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAAC,CAkFxF;AAwDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CAsJf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CA4Df;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,uBAA+B,EAAE,GAAE;IAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAO1K"}
@@ -30,5 +30,6 @@ import type { ExtractedKey, Logger, I18nextToolkitConfig } from '../../types.js'
30
30
  export declare function findKeys(config: I18nextToolkitConfig, logger?: Logger, fileErrors?: string[]): Promise<{
31
31
  allKeys: Map<string, ExtractedKey>;
32
32
  objectKeys: Set<string>;
33
+ keepPatterns: ExtractedKey[];
33
34
  }>;
34
35
  //# sourceMappingURL=key-finder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"key-finder.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/key-finder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAmB,MAAM,gBAAgB,CAAA;AAOjG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CA4F1E"}
1
+ {"version":3,"file":"key-finder.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/key-finder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAmB,MAAM,gBAAgB,CAAA;AAOjG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CA4FxG"}
@@ -28,10 +28,11 @@ import { TranslationResult, ExtractedKey, I18nextToolkitConfig, Logger } from '.
28
28
  * // Results contain update status and new/existing translations for each locale.
29
29
  * ```
30
30
  */
31
- export declare function getTranslations(keys: Map<string, ExtractedKey>, objectKeys: Set<string>, config: I18nextToolkitConfig, { syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, logger }?: {
31
+ export declare function getTranslations(keys: Map<string, ExtractedKey>, objectKeys: Set<string>, config: I18nextToolkitConfig, { syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, logger, keepPatterns }?: {
32
32
  syncPrimaryWithDefaults?: boolean;
33
33
  syncAll?: boolean;
34
34
  trustDerivedDefaults?: boolean;
35
35
  logger?: Logger;
36
+ keepPatterns?: ExtractedKey[];
36
37
  }): Promise<TranslationResult[]>;
37
38
  //# sourceMappingURL=translation-manager.d.ts.map
@@ -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,EAAE,MAAM,gBAAgB,CAAA;AAyuC9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EACf,oBAA4B,EAC5B,MAA4B,EAC7B,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA6K9B"}
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,EAAE,MAAM,gBAAgB,CAAA;AAmvC9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EACf,oBAA4B,EAC5B,MAA4B,EAC5B,YAAiB,EAClB,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA6K9B"}