i18next-cli 1.74.7 → 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.
- package/README.md +5 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/ast-visitors.js +2 -0
- package/dist/cjs/extractor/core/extractor.js +5 -4
- package/dist/cjs/extractor/core/key-finder.js +1 -1
- package/dist/cjs/extractor/core/translation-manager.js +13 -5
- package/dist/cjs/extractor/parsers/comment-parser.js +16 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/ast-visitors.js +2 -0
- package/dist/esm/extractor/core/extractor.js +5 -4
- package/dist/esm/extractor/core/key-finder.js +1 -1
- package/dist/esm/extractor/core/translation-manager.js +13 -5
- package/dist/esm/extractor/parsers/comment-parser.js +16 -1
- package/package.json +1 -1
- package/types/extractor/core/ast-visitors.d.ts +2 -1
- package/types/extractor/core/ast-visitors.d.ts.map +1 -1
- package/types/extractor/core/extractor.d.ts.map +1 -1
- package/types/extractor/core/key-finder.d.ts +1 -0
- package/types/extractor/core/key-finder.d.ts.map +1 -1
- package/types/extractor/core/translation-manager.d.ts +2 -1
- package/types/extractor/core/translation-manager.d.ts.map +1 -1
- package/types/extractor/parsers/comment-parser.d.ts +3 -2
- package/types/extractor/parsers/comment-parser.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1575,6 +1575,11 @@ Extract keys from comments for documentation or edge cases:
|
|
|
1575
1575
|
// t('user.greeting', { defaultValue: 'Hello!', ns: 'common' })
|
|
1576
1576
|
```
|
|
1577
1577
|
|
|
1578
|
+
A commented template literal cannot name its keys, so it is not extracted. Instead it keeps the
|
|
1579
|
+
existing keys it matches, even with `removeUnusedKeys`: `` // t(`QUARTER.${q}`) `` keeps `QUARTER.1`,
|
|
1580
|
+
`QUARTER.2` and so on, while code can still add new `QUARTER.*` keys. Unlike `preservePatterns`, it
|
|
1581
|
+
does not stop matching keys from being extracted.
|
|
1582
|
+
|
|
1578
1583
|
### JavaScript & TypeScript Translation Files
|
|
1579
1584
|
|
|
1580
1585
|
For projects that prefer to keep everything in a single module type, you can configure the CLI to output JavaScript or TypeScript files instead of JSON.
|
package/dist/cjs/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ const program = new commander.Command();
|
|
|
37
37
|
program
|
|
38
38
|
.name('i18next-cli')
|
|
39
39
|
.description('A unified, high-performance i18next CLI.')
|
|
40
|
-
.version('1.74.
|
|
40
|
+
.version('1.74.8') // This string is replaced with the actual version at build time by rollup
|
|
41
41
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
42
42
|
// new: global config override option
|
|
43
43
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -69,6 +69,8 @@ class ASTVisitors {
|
|
|
69
69
|
get objectKeys() {
|
|
70
70
|
return this.callExpressionHandler.objectKeys;
|
|
71
71
|
}
|
|
72
|
+
// Key patterns of commented template literals, `// t(`QUARTER.${q}`)` → `QUARTER.*`
|
|
73
|
+
keepPatterns = [];
|
|
72
74
|
scopeManager;
|
|
73
75
|
expressionResolver;
|
|
74
76
|
callExpressionHandler;
|
|
@@ -56,9 +56,10 @@ async function runExtractor(config, options = {}) {
|
|
|
56
56
|
const spinner = wrapOra.createSpinnerLike('Running i18next key extractor...\n', { quiet: !!options.quiet, logger: options.logger });
|
|
57
57
|
try {
|
|
58
58
|
const fileErrors = [];
|
|
59
|
-
const { allKeys, objectKeys } = await keyFinder.findKeys(config, internalLogger, fileErrors);
|
|
59
|
+
const { allKeys, objectKeys, keepPatterns } = await keyFinder.findKeys(config, internalLogger, fileErrors);
|
|
60
60
|
spinner.text = `Found ${allKeys.size} unique keys. Updating translation files...`;
|
|
61
61
|
const results = await translationManager.getTranslations(allKeys, objectKeys, config, {
|
|
62
|
+
keepPatterns,
|
|
62
63
|
syncPrimaryWithDefaults: options.syncPrimaryWithDefaults,
|
|
63
64
|
syncAll: options.syncAll,
|
|
64
65
|
trustDerivedDefaults: options.trustDerivedDefaults,
|
|
@@ -304,7 +305,7 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
|
|
|
304
305
|
astVisitors.visit(ast);
|
|
305
306
|
// 4. THEN: Extract keys from comments with scope resolution (now scope info is available)
|
|
306
307
|
if (config.extract.extractFromComments !== false) {
|
|
307
|
-
commentParser.extractKeysFromComments(code, pluginContext, config, astVisitors.getVarFromScope.bind(astVisitors));
|
|
308
|
+
commentParser.extractKeysFromComments(code, pluginContext, config, astVisitors.getVarFromScope.bind(astVisitors), astVisitors.keepPatterns);
|
|
308
309
|
}
|
|
309
310
|
}
|
|
310
311
|
catch (error) {
|
|
@@ -428,8 +429,8 @@ async function extract(config, { syncPrimaryWithDefaults = false } = {}) {
|
|
|
428
429
|
config.extract.secondaryLanguages ||= config.locales.filter((l) => l !== config?.extract?.primaryLanguage);
|
|
429
430
|
config.extract.functions ||= ['t', '*.t'];
|
|
430
431
|
config.extract.transComponents ||= ['Trans'];
|
|
431
|
-
const { allKeys, objectKeys } = await keyFinder.findKeys(config);
|
|
432
|
-
return translationManager.getTranslations(allKeys, objectKeys, config, { syncPrimaryWithDefaults });
|
|
432
|
+
const { allKeys, objectKeys, keepPatterns } = await keyFinder.findKeys(config);
|
|
433
|
+
return translationManager.getTranslations(allKeys, objectKeys, config, { syncPrimaryWithDefaults, keepPatterns });
|
|
433
434
|
}
|
|
434
435
|
|
|
435
436
|
exports.extract = extract;
|
|
@@ -118,7 +118,7 @@ async function findKeys(config, logger$1 = new logger.ConsoleLogger(), fileError
|
|
|
118
118
|
ek.isExpandedPlural = true;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
return { allKeys, objectKeys: astVisitors$1.objectKeys };
|
|
121
|
+
return { allKeys, objectKeys: astVisitors$1.objectKeys, keepPatterns: astVisitors$1.keepPatterns };
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Processes source files using glob patterns from configuration.
|
|
@@ -166,7 +166,7 @@ function sortObjectCodeUnit(obj) {
|
|
|
166
166
|
* A helper function to build a new translation object for a single namespace.
|
|
167
167
|
* This centralizes the core logic of merging keys.
|
|
168
168
|
*/
|
|
169
|
-
function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, namespace, preservePatterns = [], objectKeys = new Set(), syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, primaryExistingTranslations = {}, logger$1 = new logger.ConsoleLogger()) {
|
|
169
|
+
function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, namespace, preservePatterns = [], objectKeys = new Set(), syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, primaryExistingTranslations = {}, logger$1 = new logger.ConsoleLogger(), keepPatterns = []) {
|
|
170
170
|
const { keySeparator = '.', sort = true, removeUnusedKeys = true, defaultValue: emptyDefaultValue = '', pluralSeparator = '_', contextSeparator = '_', preserveContextVariants = false, } = config.extract;
|
|
171
171
|
const primaryLanguage = config.extract.primaryLanguage || config.locales[0] || 'en';
|
|
172
172
|
const nsSep = typeof config.extract.nsSeparator === 'string' ? config.extract.nsSeparator : ':';
|
|
@@ -381,12 +381,20 @@ function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale,
|
|
|
381
381
|
}
|
|
382
382
|
return false;
|
|
383
383
|
};
|
|
384
|
+
// Patterns of commented template literals in this namespace, `// t(`QUARTER.${q}`)` (#304).
|
|
385
|
+
// Unlike preservePatterns they only keep existing keys, so code still extracts matching keys.
|
|
386
|
+
const keepRegexes = keepPatterns
|
|
387
|
+
.filter(p => !namespace || !p.ns || p.ns === '*' || p.ns === namespace)
|
|
388
|
+
.map(p => globToRegex(p.key));
|
|
384
389
|
// Helper to check if an existing key should be preserved
|
|
385
390
|
const shouldPreserveExistingKey = (key) => {
|
|
386
391
|
// 1) keys nested under a returnObjects / selector-API base key
|
|
387
392
|
if (isUnderObjectKey(key)) {
|
|
388
393
|
return true;
|
|
389
394
|
}
|
|
395
|
+
if (keepRegexes.some(re => re.test(key))) {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
390
398
|
// 2) regex-style patterns
|
|
391
399
|
if (preservePatterns.some(re => re.test(key))) {
|
|
392
400
|
return true;
|
|
@@ -1138,7 +1146,7 @@ async function reattributeFallbackNsKeys(keysByNS, noNsToken, config, primaryLan
|
|
|
1138
1146
|
* // Results contain update status and new/existing translations for each locale.
|
|
1139
1147
|
* ```
|
|
1140
1148
|
*/
|
|
1141
|
-
async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, logger: logger$1 = new logger.ConsoleLogger() } = {}) {
|
|
1149
|
+
async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaults = false, syncAll = false, trustDerivedDefaults = false, logger: logger$1 = new logger.ConsoleLogger(), keepPatterns = [] } = {}) {
|
|
1142
1150
|
config.extract.primaryLanguage ||= config.locales[0] || 'en';
|
|
1143
1151
|
const primaryLanguage = config.extract.primaryLanguage || config.locales[0] || 'en';
|
|
1144
1152
|
config.extract.secondaryLanguages ||= config.locales.filter((l) => l !== primaryLanguage);
|
|
@@ -1235,13 +1243,13 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
1235
1243
|
const nsKeys = keysByNS.get(nsKey) || [];
|
|
1236
1244
|
if (isTopLevel(nsKey)) {
|
|
1237
1245
|
// keys without namespace -> merged into top-level of the merged file
|
|
1238
|
-
const built = buildNewTranslationsForNs(nsKeys, existingMergedFile, config, locale, undefined, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryMergedFile, logger$1);
|
|
1246
|
+
const built = buildNewTranslationsForNs(nsKeys, existingMergedFile, config, locale, undefined, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryMergedFile, logger$1, keepPatterns);
|
|
1239
1247
|
Object.assign(newMergedTranslations, built);
|
|
1240
1248
|
}
|
|
1241
1249
|
else {
|
|
1242
1250
|
const existingTranslations = existingMergedFile[nsKey] || {};
|
|
1243
1251
|
const primaryExistingTranslations = primaryMergedFile[nsKey] || {};
|
|
1244
|
-
newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger$1);
|
|
1252
|
+
newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger$1, keepPatterns);
|
|
1245
1253
|
}
|
|
1246
1254
|
}
|
|
1247
1255
|
// Preserve ignored namespaces as-is from the existing merged file
|
|
@@ -1283,7 +1291,7 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
1283
1291
|
const primaryExistingTranslations = locale === primaryLanguage
|
|
1284
1292
|
? existingTranslations
|
|
1285
1293
|
: (await fileUtils.loadTranslationFile(primaryOutputPath) || {});
|
|
1286
|
-
const newTranslations = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, ns, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger$1);
|
|
1294
|
+
const newTranslations = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, ns, preservePatterns, objectKeys, syncPrimaryWithDefaults, syncAll, trustDerivedDefaults, primaryExistingTranslations, logger$1, keepPatterns);
|
|
1287
1295
|
const oldContent = JSON.stringify(existingTranslations, null, indentation);
|
|
1288
1296
|
const newContent = JSON.stringify(newTranslations, null, indentation);
|
|
1289
1297
|
// Push one result per namespace file
|
|
@@ -13,6 +13,7 @@ const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
|
|
|
13
13
|
* @param pluginContext - Context object with helper methods to add found keys
|
|
14
14
|
* @param config - Configuration object containing extraction settings
|
|
15
15
|
* @param scopeResolver - Function to resolve scope information for variables (optional)
|
|
16
|
+
* @param keepPatterns - Collects the key patterns of commented template literals (optional)
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```typescript
|
|
@@ -26,7 +27,7 @@ const looksLikeNaturalLanguage = (s) => naturalLanguageChars.test(s);
|
|
|
26
27
|
* // Extracts: user.name and app.title with their respective settings
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
29
|
-
function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
|
|
30
|
+
function extractKeysFromComments(code, pluginContext, config, scopeResolver, keepPatterns) {
|
|
30
31
|
// Hardcode the function name to 't' to prevent parsing other functions like 'test()'.
|
|
31
32
|
const functionNameToFind = 't';
|
|
32
33
|
// Use a reliable word boundary (\b) to match 't(...)' but not 'http.get(...)'.
|
|
@@ -63,6 +64,11 @@ function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
|
|
|
63
64
|
if (!key || key.trim() === '') {
|
|
64
65
|
continue; // Skip empty keys
|
|
65
66
|
}
|
|
67
|
+
// `t(`QUARTER.${q}`)` cannot name its keys: it becomes the pattern `QUARTER.*`,
|
|
68
|
+
// which keeps the existing keys it matches instead of adding a literal `${q}` (#304)
|
|
69
|
+
const isPattern = match[1] === '`' && key.includes('${');
|
|
70
|
+
if (isPattern)
|
|
71
|
+
key = key.replace(/\$\{[^}]*\}/g, '*');
|
|
66
72
|
// We'll check preservePatterns after namespace resolution below
|
|
67
73
|
let ns;
|
|
68
74
|
const remainder = text.slice(match.index + match[0].length);
|
|
@@ -122,6 +128,15 @@ function extractKeysFromComments(code, pluginContext, config, scopeResolver) {
|
|
|
122
128
|
// 4. Final fallback to configured default namespace
|
|
123
129
|
if (!ns)
|
|
124
130
|
ns = config.extract.defaultNS;
|
|
131
|
+
if (isPattern) {
|
|
132
|
+
// ponytail: a pattern without any static segment (`${a}.${b}`) would keep the whole
|
|
133
|
+
// namespace, so it is dropped
|
|
134
|
+
const keySeparator = config.extract.keySeparator ?? '.';
|
|
135
|
+
const staticPart = key.replace(/\*/g, '');
|
|
136
|
+
if (keySeparator === false ? staticPart : staticPart.split(keySeparator).some(Boolean))
|
|
137
|
+
keepPatterns?.push({ key, ns });
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
125
140
|
// 5. Handle context and count combinations based on disablePlurals setting
|
|
126
141
|
if (config.extract.disablePlurals) {
|
|
127
142
|
// When plurals are disabled, ignore count for key generation. We still
|
package/dist/esm/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const program = new Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name('i18next-cli')
|
|
33
33
|
.description('A unified, high-performance i18next CLI.')
|
|
34
|
-
.version('1.74.
|
|
34
|
+
.version('1.74.8') // This string is replaced with the actual version at build time by rollup
|
|
35
35
|
.addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
|
|
36
36
|
// new: global config override option
|
|
37
37
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
@@ -67,6 +67,8 @@ class ASTVisitors {
|
|
|
67
67
|
get objectKeys() {
|
|
68
68
|
return this.callExpressionHandler.objectKeys;
|
|
69
69
|
}
|
|
70
|
+
// Key patterns of commented template literals, `// t(`QUARTER.${q}`)` → `QUARTER.*`
|
|
71
|
+
keepPatterns = [];
|
|
70
72
|
scopeManager;
|
|
71
73
|
expressionResolver;
|
|
72
74
|
callExpressionHandler;
|
|
@@ -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
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -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,6 +30,7 @@ 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;
|
|
@@ -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;
|
|
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,OA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,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,
|
|
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;
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginContext, I18nextToolkitConfig } from '../../types.js';
|
|
1
|
+
import type { PluginContext, I18nextToolkitConfig, ExtractedKey } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Extracts translation keys from comments in source code using regex patterns.
|
|
4
4
|
* Supports extraction from single-line (//) and multi-line comments.
|
|
@@ -7,6 +7,7 @@ import type { PluginContext, I18nextToolkitConfig } from '../../types.js';
|
|
|
7
7
|
* @param pluginContext - Context object with helper methods to add found keys
|
|
8
8
|
* @param config - Configuration object containing extraction settings
|
|
9
9
|
* @param scopeResolver - Function to resolve scope information for variables (optional)
|
|
10
|
+
* @param keepPatterns - Collects the key patterns of commented template literals (optional)
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```typescript
|
|
@@ -23,5 +24,5 @@ import type { PluginContext, I18nextToolkitConfig } from '../../types.js';
|
|
|
23
24
|
export declare function extractKeysFromComments(code: string, pluginContext: PluginContext, config: I18nextToolkitConfig, scopeResolver?: (varName: string) => {
|
|
24
25
|
defaultNs?: string;
|
|
25
26
|
keyPrefix?: string;
|
|
26
|
-
} | undefined): void;
|
|
27
|
+
} | undefined, keepPatterns?: ExtractedKey[]): void;
|
|
27
28
|
//# sourceMappingURL=comment-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/comment-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"comment-parser.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/comment-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAOvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,oBAAoB,EAC5B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,EAC3F,YAAY,CAAC,EAAE,YAAY,EAAE,GAC5B,IAAI,CAuKN"}
|