i18next-cli 1.41.3 → 1.42.0
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 +31 -1
- package/dist/cjs/cli.js +2 -1
- package/dist/cjs/extractor/core/extractor.js +1 -1
- package/dist/cjs/extractor/parsers/jsx-handler.js +17 -1
- package/dist/cjs/heuristic-config.js +15 -0
- package/dist/cjs/syncer.js +1 -1
- package/dist/cjs/utils/file-utils.js +27 -0
- package/dist/esm/cli.js +2 -1
- package/dist/esm/extractor/core/extractor.js +2 -2
- package/dist/esm/extractor/parsers/jsx-handler.js +17 -1
- package/dist/esm/heuristic-config.js +15 -0
- package/dist/esm/syncer.js +2 -2
- package/dist/esm/utils/file-utils.js +27 -1
- package/package.json +6 -5
- package/types/extractor/parsers/jsx-handler.d.ts.map +1 -1
- package/types/heuristic-config.d.ts.map +1 -1
- package/types/types.d.ts +2 -1
- package/types/types.d.ts.map +1 -1
- package/types/utils/file-utils.d.ts +7 -0
- package/types/utils/file-utils.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -375,7 +375,8 @@ export default defineConfig({
|
|
|
375
375
|
|
|
376
376
|
// Use '.ts' files with `export default` instead of '.json'
|
|
377
377
|
// Or use 'json5' to enable JSON5 features (comments, trailing commas, formatting are tried to be preserved)
|
|
378
|
-
//
|
|
378
|
+
// Or use 'yaml' for YAML format (.yaml or .yml extensions)
|
|
379
|
+
// if the file ending is .json5, .yaml, or .yml it automatically uses the corresponding format
|
|
379
380
|
outputFormat: 'ts',
|
|
380
381
|
|
|
381
382
|
// Combine all namespaces into a single file per language (e.g., locales/en.ts)
|
|
@@ -875,6 +876,34 @@ export default {
|
|
|
875
876
|
} as const;
|
|
876
877
|
```
|
|
877
878
|
|
|
879
|
+
### YAML Translation Files
|
|
880
|
+
|
|
881
|
+
For projects that prefer YAML for better readability and compatibility with other tools, you can configure the CLI to output YAML files instead of JSON.
|
|
882
|
+
|
|
883
|
+
Configuration (`i18next.config.ts`):
|
|
884
|
+
|
|
885
|
+
```typescript
|
|
886
|
+
export default defineConfig({
|
|
887
|
+
extract: {
|
|
888
|
+
output: 'locales/{{language}}/{{namespace}}.yaml', // Use .yaml or .yml
|
|
889
|
+
outputFormat: 'yaml', // Optional - inferred from file extension
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
This will generate files like `locales/en/translation.yaml` with the following content:
|
|
895
|
+
|
|
896
|
+
```yaml
|
|
897
|
+
app:
|
|
898
|
+
title: My Application
|
|
899
|
+
description: Welcome to our app
|
|
900
|
+
button:
|
|
901
|
+
save: Save
|
|
902
|
+
cancel: Cancel
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
> **💡 Note:** Both `.yaml` and `.yml` extensions are supported and preserved. The `outputFormat: 'yaml'` option is optional when using these extensions - the format is automatically inferred from the file extension.
|
|
906
|
+
|
|
878
907
|
### Merging Namespaces
|
|
879
908
|
|
|
880
909
|
You can also combine all namespaces into a single file per language. This is useful for reducing the number of network requests in some application setups.
|
|
@@ -1140,6 +1169,7 @@ This programmatic API gives you the same power as the CLI but with full control
|
|
|
1140
1169
|
|
|
1141
1170
|
- [i18next-cli-plugin-svelte](https://github.com/dreamscached/i18next-cli-plugin-svelte) — a simple plugin to extract translation keys from Svelte components
|
|
1142
1171
|
- [rsbuild-plugin-i18next-extractor](https://github.com/rspack-contrib/rsbuild-plugin-i18next-extractor) — A Rsbuild plugin that leverages the Rspack module graph to extract only the i18n translations that are actually imported and used in your code, preventing unused translations from being bundled.
|
|
1172
|
+
- [i18next-cli-vue](https://github.com/PBK-B/i18next-cli-vue) — i18next-cli plugin for extracting i18n keys from Vue SFC files, applicable to vue2 and vue3
|
|
1143
1173
|
|
|
1144
1174
|
---
|
|
1145
1175
|
|
package/dist/cjs/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ require('node:path');
|
|
|
15
15
|
require('node:fs/promises');
|
|
16
16
|
require('jiti');
|
|
17
17
|
require('@croct/json5-parser');
|
|
18
|
+
require('yaml');
|
|
18
19
|
var typesGenerator = require('./types-generator.js');
|
|
19
20
|
var syncer = require('./syncer.js');
|
|
20
21
|
var migrator = require('./migrator.js');
|
|
@@ -28,7 +29,7 @@ const program = new commander.Command();
|
|
|
28
29
|
program
|
|
29
30
|
.name('i18next-cli')
|
|
30
31
|
.description('A unified, high-performance i18next CLI.')
|
|
31
|
-
.version('1.
|
|
32
|
+
.version('1.42.0'); // This string is replaced with the actual version at build time by rollup
|
|
32
33
|
// new: global config override option
|
|
33
34
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
34
35
|
program
|
|
@@ -63,7 +63,7 @@ async function runExtractor(config, options = {}) {
|
|
|
63
63
|
anyFileUpdated = true;
|
|
64
64
|
if (!options.isDryRun) {
|
|
65
65
|
// prefer explicit outputFormat; otherwise infer from file extension per-file
|
|
66
|
-
const effectiveFormat = config.extract.outputFormat ?? (result.path
|
|
66
|
+
const effectiveFormat = config.extract.outputFormat ?? fileUtils.inferFormatFromPath(result.path);
|
|
67
67
|
const rawContent = effectiveFormat === 'json5'
|
|
68
68
|
? (await fileUtils.loadRawJson5Content(result.path)) ?? undefined
|
|
69
69
|
: undefined;
|
|
@@ -373,7 +373,23 @@ class JSXHandler {
|
|
|
373
373
|
generatePluralKeysForTrans(key, defaultValue, ns, isOrdinal, optionsNode, explicitDefaultFromSource, locations, keyAcceptingContext) {
|
|
374
374
|
try {
|
|
375
375
|
const type = isOrdinal ? 'ordinal' : 'cardinal';
|
|
376
|
-
|
|
376
|
+
// Generate plural forms for ALL target languages to ensure we have all necessary keys
|
|
377
|
+
// This matches the behavior of generatePluralKeys used for t()
|
|
378
|
+
const allPluralCategories = new Set();
|
|
379
|
+
for (const locale of this.config.locales) {
|
|
380
|
+
try {
|
|
381
|
+
const pluralRules = new Intl.PluralRules(locale, { type });
|
|
382
|
+
const categories = pluralRules.resolvedOptions().pluralCategories;
|
|
383
|
+
categories.forEach(cat => allPluralCategories.add(cat));
|
|
384
|
+
}
|
|
385
|
+
catch (e) {
|
|
386
|
+
// If a locale is invalid, fall back to English rules
|
|
387
|
+
const englishRules = new Intl.PluralRules('en', { type });
|
|
388
|
+
const categories = englishRules.resolvedOptions().pluralCategories;
|
|
389
|
+
categories.forEach(cat => allPluralCategories.add(cat));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const pluralCategories = Array.from(allPluralCategories).sort();
|
|
377
393
|
const pluralSeparator = this.config.extract.pluralSeparator ?? '_';
|
|
378
394
|
// Get plural-specific default values from tOptions if available
|
|
379
395
|
let otherDefault;
|
|
@@ -24,6 +24,18 @@ const HEURISTIC_PATTERNS = [
|
|
|
24
24
|
'src/assets/locales/en/*.json5',
|
|
25
25
|
'app/i18n/locales/en/*.json5',
|
|
26
26
|
'src/i18n/locales/en/*.json5',
|
|
27
|
+
'public/locales/en/*.yaml',
|
|
28
|
+
'locales/en/*.yaml',
|
|
29
|
+
'src/locales/en/*.yaml',
|
|
30
|
+
'src/assets/locales/en/*.yaml',
|
|
31
|
+
'app/i18n/locales/en/*.yaml',
|
|
32
|
+
'src/i18n/locales/en/*.yaml',
|
|
33
|
+
'public/locales/en/*.yml',
|
|
34
|
+
'locales/en/*.yml',
|
|
35
|
+
'src/locales/en/*.yml',
|
|
36
|
+
'src/assets/locales/en/*.yml',
|
|
37
|
+
'app/i18n/locales/en/*.yml',
|
|
38
|
+
'src/i18n/locales/en/*.yml',
|
|
27
39
|
'public/locales/en-*/*.json',
|
|
28
40
|
'locales/en-*/*.json',
|
|
29
41
|
'src/locales/en-*/*.json',
|
|
@@ -60,6 +72,9 @@ async function detectConfig() {
|
|
|
60
72
|
else if (extension === '.json5') {
|
|
61
73
|
outputFormat = 'json5';
|
|
62
74
|
}
|
|
75
|
+
else if (extension === '.yaml' || extension === '.yml') {
|
|
76
|
+
outputFormat = 'yaml';
|
|
77
|
+
}
|
|
63
78
|
try {
|
|
64
79
|
const allDirs = await promises.readdir(basePath);
|
|
65
80
|
let locales = allDirs.filter(dir => /^(dev|[a-z]{2}(-[A-Z]{2})?)$/.test(dir));
|
package/dist/cjs/syncer.js
CHANGED
|
@@ -97,7 +97,7 @@ async function runSyncer(config, options = {}) {
|
|
|
97
97
|
const newContent = JSON.stringify(newSecondaryTranslations);
|
|
98
98
|
if (newContent !== oldContent) {
|
|
99
99
|
wasAnythingSynced = true;
|
|
100
|
-
const perFileFormat = config.extract.outputFormat ?? (fullSecondaryPath
|
|
100
|
+
const perFileFormat = config.extract.outputFormat ?? fileUtils.inferFormatFromPath(fullSecondaryPath, outputFormat);
|
|
101
101
|
const raw = perFileFormat === 'json5' ? (await fileUtils.loadRawJson5Content(fullSecondaryPath)) ?? undefined : undefined;
|
|
102
102
|
const serializedContent = fileUtils.serializeTranslationFile(newSecondaryTranslations, perFileFormat, indentation, raw);
|
|
103
103
|
await promises.mkdir(node_path.dirname(fullSecondaryPath), { recursive: true });
|
|
@@ -5,6 +5,7 @@ var node_path = require('node:path');
|
|
|
5
5
|
var jiti = require('jiti');
|
|
6
6
|
var config = require('../config.js');
|
|
7
7
|
var json5Parser = require('@croct/json5-parser');
|
|
8
|
+
var yaml = require('yaml');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Resolve an output template (string or function) into an actual path string.
|
|
@@ -65,6 +66,10 @@ async function loadTranslationFile(filePath) {
|
|
|
65
66
|
const node = json5Parser.JsonParser.parse(content, json5Parser.JsonObjectNode);
|
|
66
67
|
return node.toJSON();
|
|
67
68
|
}
|
|
69
|
+
else if (ext === '.yaml' || ext === '.yml') {
|
|
70
|
+
const content = await promises.readFile(fullPath, 'utf-8');
|
|
71
|
+
return yaml.parse(content);
|
|
72
|
+
}
|
|
68
73
|
else if (ext === '.json') {
|
|
69
74
|
const content = await promises.readFile(fullPath, 'utf-8');
|
|
70
75
|
return JSON.parse(content);
|
|
@@ -116,6 +121,8 @@ function serializeTranslationFile(data, format = 'json', indentation = 2, rawCon
|
|
|
116
121
|
const node = json5Parser.JsonParser.parse(jsonString, json5Parser.JsonObjectNode);
|
|
117
122
|
return node.toString({ object: { indentationSize: Number(indentation) ?? 2 } });
|
|
118
123
|
}
|
|
124
|
+
case 'yaml':
|
|
125
|
+
return yaml.stringify(data, { indent: Number(indentation) || 2, lineWidth: 0 });
|
|
119
126
|
case 'js':
|
|
120
127
|
case 'js-esm':
|
|
121
128
|
return `export default ${jsonString};\n`;
|
|
@@ -129,8 +136,28 @@ function serializeTranslationFile(data, format = 'json', indentation = 2, rawCon
|
|
|
129
136
|
return `${jsonString}\n`;
|
|
130
137
|
}
|
|
131
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Infers the output format from the file path extension.
|
|
141
|
+
* @param filePath - The path to the translation file
|
|
142
|
+
* @param defaultFormat - The default format to return if no match (default: 'json')
|
|
143
|
+
* @returns The inferred output format
|
|
144
|
+
*/
|
|
145
|
+
function inferFormatFromPath(filePath, defaultFormat = 'json') {
|
|
146
|
+
if (filePath.endsWith('.json5'))
|
|
147
|
+
return 'json5';
|
|
148
|
+
if (filePath.endsWith('.yaml') || filePath.endsWith('.yml'))
|
|
149
|
+
return 'yaml';
|
|
150
|
+
if (filePath.endsWith('.ts'))
|
|
151
|
+
return 'ts';
|
|
152
|
+
if (filePath.endsWith('.js'))
|
|
153
|
+
return 'js';
|
|
154
|
+
if (filePath.endsWith('.json'))
|
|
155
|
+
return 'json';
|
|
156
|
+
return defaultFormat || 'json';
|
|
157
|
+
}
|
|
132
158
|
|
|
133
159
|
exports.getOutputPath = getOutputPath;
|
|
160
|
+
exports.inferFormatFromPath = inferFormatFromPath;
|
|
134
161
|
exports.loadRawJson5Content = loadRawJson5Content;
|
|
135
162
|
exports.loadTranslationFile = loadTranslationFile;
|
|
136
163
|
exports.serializeTranslationFile = serializeTranslationFile;
|
package/dist/esm/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import 'node:path';
|
|
|
13
13
|
import 'node:fs/promises';
|
|
14
14
|
import 'jiti';
|
|
15
15
|
import '@croct/json5-parser';
|
|
16
|
+
import 'yaml';
|
|
16
17
|
import { runTypesGenerator } from './types-generator.js';
|
|
17
18
|
import { runSyncer } from './syncer.js';
|
|
18
19
|
import { runMigrator } from './migrator.js';
|
|
@@ -26,7 +27,7 @@ const program = new Command();
|
|
|
26
27
|
program
|
|
27
28
|
.name('i18next-cli')
|
|
28
29
|
.description('A unified, high-performance i18next CLI.')
|
|
29
|
-
.version('1.
|
|
30
|
+
.version('1.42.0'); // This string is replaced with the actual version at build time by rollup
|
|
30
31
|
// new: global config override option
|
|
31
32
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
32
33
|
program
|
|
@@ -8,7 +8,7 @@ import { getTranslations } from './translation-manager.js';
|
|
|
8
8
|
import { validateExtractorConfig, ExtractorError } from '../../utils/validation.js';
|
|
9
9
|
import { extractKeysFromComments } from '../parsers/comment-parser.js';
|
|
10
10
|
import { ConsoleLogger } from '../../utils/logger.js';
|
|
11
|
-
import { loadRawJson5Content, serializeTranslationFile } from '../../utils/file-utils.js';
|
|
11
|
+
import { inferFormatFromPath, loadRawJson5Content, serializeTranslationFile } from '../../utils/file-utils.js';
|
|
12
12
|
import { shouldShowFunnel, recordFunnelShown } from '../../utils/funnel-msg-tracker.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -61,7 +61,7 @@ async function runExtractor(config, options = {}) {
|
|
|
61
61
|
anyFileUpdated = true;
|
|
62
62
|
if (!options.isDryRun) {
|
|
63
63
|
// prefer explicit outputFormat; otherwise infer from file extension per-file
|
|
64
|
-
const effectiveFormat = config.extract.outputFormat ?? (result.path
|
|
64
|
+
const effectiveFormat = config.extract.outputFormat ?? inferFormatFromPath(result.path);
|
|
65
65
|
const rawContent = effectiveFormat === 'json5'
|
|
66
66
|
? (await loadRawJson5Content(result.path)) ?? undefined
|
|
67
67
|
: undefined;
|
|
@@ -371,7 +371,23 @@ class JSXHandler {
|
|
|
371
371
|
generatePluralKeysForTrans(key, defaultValue, ns, isOrdinal, optionsNode, explicitDefaultFromSource, locations, keyAcceptingContext) {
|
|
372
372
|
try {
|
|
373
373
|
const type = isOrdinal ? 'ordinal' : 'cardinal';
|
|
374
|
-
|
|
374
|
+
// Generate plural forms for ALL target languages to ensure we have all necessary keys
|
|
375
|
+
// This matches the behavior of generatePluralKeys used for t()
|
|
376
|
+
const allPluralCategories = new Set();
|
|
377
|
+
for (const locale of this.config.locales) {
|
|
378
|
+
try {
|
|
379
|
+
const pluralRules = new Intl.PluralRules(locale, { type });
|
|
380
|
+
const categories = pluralRules.resolvedOptions().pluralCategories;
|
|
381
|
+
categories.forEach(cat => allPluralCategories.add(cat));
|
|
382
|
+
}
|
|
383
|
+
catch (e) {
|
|
384
|
+
// If a locale is invalid, fall back to English rules
|
|
385
|
+
const englishRules = new Intl.PluralRules('en', { type });
|
|
386
|
+
const categories = englishRules.resolvedOptions().pluralCategories;
|
|
387
|
+
categories.forEach(cat => allPluralCategories.add(cat));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const pluralCategories = Array.from(allPluralCategories).sort();
|
|
375
391
|
const pluralSeparator = this.config.extract.pluralSeparator ?? '_';
|
|
376
392
|
// Get plural-specific default values from tOptions if available
|
|
377
393
|
let otherDefault;
|
|
@@ -22,6 +22,18 @@ const HEURISTIC_PATTERNS = [
|
|
|
22
22
|
'src/assets/locales/en/*.json5',
|
|
23
23
|
'app/i18n/locales/en/*.json5',
|
|
24
24
|
'src/i18n/locales/en/*.json5',
|
|
25
|
+
'public/locales/en/*.yaml',
|
|
26
|
+
'locales/en/*.yaml',
|
|
27
|
+
'src/locales/en/*.yaml',
|
|
28
|
+
'src/assets/locales/en/*.yaml',
|
|
29
|
+
'app/i18n/locales/en/*.yaml',
|
|
30
|
+
'src/i18n/locales/en/*.yaml',
|
|
31
|
+
'public/locales/en/*.yml',
|
|
32
|
+
'locales/en/*.yml',
|
|
33
|
+
'src/locales/en/*.yml',
|
|
34
|
+
'src/assets/locales/en/*.yml',
|
|
35
|
+
'app/i18n/locales/en/*.yml',
|
|
36
|
+
'src/i18n/locales/en/*.yml',
|
|
25
37
|
'public/locales/en-*/*.json',
|
|
26
38
|
'locales/en-*/*.json',
|
|
27
39
|
'src/locales/en-*/*.json',
|
|
@@ -58,6 +70,9 @@ async function detectConfig() {
|
|
|
58
70
|
else if (extension === '.json5') {
|
|
59
71
|
outputFormat = 'json5';
|
|
60
72
|
}
|
|
73
|
+
else if (extension === '.yaml' || extension === '.yml') {
|
|
74
|
+
outputFormat = 'yaml';
|
|
75
|
+
}
|
|
61
76
|
try {
|
|
62
77
|
const allDirs = await readdir(basePath);
|
|
63
78
|
let locales = allDirs.filter(dir => /^(dev|[a-z]{2}(-[A-Z]{2})?)$/.test(dir));
|
package/dist/esm/syncer.js
CHANGED
|
@@ -5,7 +5,7 @@ import { basename, resolve, dirname } from 'node:path';
|
|
|
5
5
|
import { createSpinnerLike } from './utils/wrap-ora.js';
|
|
6
6
|
import { ConsoleLogger } from './utils/logger.js';
|
|
7
7
|
import { resolveDefaultValue } from './utils/default-value.js';
|
|
8
|
-
import { getOutputPath, loadTranslationFile, loadRawJson5Content, serializeTranslationFile } from './utils/file-utils.js';
|
|
8
|
+
import { getOutputPath, loadTranslationFile, inferFormatFromPath, loadRawJson5Content, serializeTranslationFile } from './utils/file-utils.js';
|
|
9
9
|
import { shouldShowFunnel, recordFunnelShown } from './utils/funnel-msg-tracker.js';
|
|
10
10
|
import { getNestedKeys, getNestedValue, setNestedValue } from './utils/nested-object.js';
|
|
11
11
|
|
|
@@ -95,7 +95,7 @@ async function runSyncer(config, options = {}) {
|
|
|
95
95
|
const newContent = JSON.stringify(newSecondaryTranslations);
|
|
96
96
|
if (newContent !== oldContent) {
|
|
97
97
|
wasAnythingSynced = true;
|
|
98
|
-
const perFileFormat = config.extract.outputFormat ?? (fullSecondaryPath
|
|
98
|
+
const perFileFormat = config.extract.outputFormat ?? inferFormatFromPath(fullSecondaryPath, outputFormat);
|
|
99
99
|
const raw = perFileFormat === 'json5' ? (await loadRawJson5Content(fullSecondaryPath)) ?? undefined : undefined;
|
|
100
100
|
const serializedContent = serializeTranslationFile(newSecondaryTranslations, perFileFormat, indentation, raw);
|
|
101
101
|
await mkdir(dirname(fullSecondaryPath), { recursive: true });
|
|
@@ -3,6 +3,7 @@ import { resolve, normalize, extname } from 'node:path';
|
|
|
3
3
|
import { createJiti } from 'jiti';
|
|
4
4
|
import { getTsConfigAliases } from '../config.js';
|
|
5
5
|
import { JsonParser, JsonObjectNode } from '@croct/json5-parser';
|
|
6
|
+
import yaml from 'yaml';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Resolve an output template (string or function) into an actual path string.
|
|
@@ -63,6 +64,10 @@ async function loadTranslationFile(filePath) {
|
|
|
63
64
|
const node = JsonParser.parse(content, JsonObjectNode);
|
|
64
65
|
return node.toJSON();
|
|
65
66
|
}
|
|
67
|
+
else if (ext === '.yaml' || ext === '.yml') {
|
|
68
|
+
const content = await readFile(fullPath, 'utf-8');
|
|
69
|
+
return yaml.parse(content);
|
|
70
|
+
}
|
|
66
71
|
else if (ext === '.json') {
|
|
67
72
|
const content = await readFile(fullPath, 'utf-8');
|
|
68
73
|
return JSON.parse(content);
|
|
@@ -114,6 +119,8 @@ function serializeTranslationFile(data, format = 'json', indentation = 2, rawCon
|
|
|
114
119
|
const node = JsonParser.parse(jsonString, JsonObjectNode);
|
|
115
120
|
return node.toString({ object: { indentationSize: Number(indentation) ?? 2 } });
|
|
116
121
|
}
|
|
122
|
+
case 'yaml':
|
|
123
|
+
return yaml.stringify(data, { indent: Number(indentation) || 2, lineWidth: 0 });
|
|
117
124
|
case 'js':
|
|
118
125
|
case 'js-esm':
|
|
119
126
|
return `export default ${jsonString};\n`;
|
|
@@ -127,5 +134,24 @@ function serializeTranslationFile(data, format = 'json', indentation = 2, rawCon
|
|
|
127
134
|
return `${jsonString}\n`;
|
|
128
135
|
}
|
|
129
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Infers the output format from the file path extension.
|
|
139
|
+
* @param filePath - The path to the translation file
|
|
140
|
+
* @param defaultFormat - The default format to return if no match (default: 'json')
|
|
141
|
+
* @returns The inferred output format
|
|
142
|
+
*/
|
|
143
|
+
function inferFormatFromPath(filePath, defaultFormat = 'json') {
|
|
144
|
+
if (filePath.endsWith('.json5'))
|
|
145
|
+
return 'json5';
|
|
146
|
+
if (filePath.endsWith('.yaml') || filePath.endsWith('.yml'))
|
|
147
|
+
return 'yaml';
|
|
148
|
+
if (filePath.endsWith('.ts'))
|
|
149
|
+
return 'ts';
|
|
150
|
+
if (filePath.endsWith('.js'))
|
|
151
|
+
return 'js';
|
|
152
|
+
if (filePath.endsWith('.json'))
|
|
153
|
+
return 'json';
|
|
154
|
+
return defaultFormat || 'json';
|
|
155
|
+
}
|
|
130
156
|
|
|
131
|
-
export { getOutputPath, loadRawJson5Content, loadTranslationFile, serializeTranslationFile };
|
|
157
|
+
export { getOutputPath, inferFormatFromPath, loadRawJson5Content, loadTranslationFile, serializeTranslationFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "A unified, high-performance i18next CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@rollup/plugin-terser": "0.4.4",
|
|
57
57
|
"@types/inquirer": "9.0.9",
|
|
58
58
|
"@types/node": "25.2.0",
|
|
59
|
-
"@types/react": "19.2.
|
|
59
|
+
"@types/react": "19.2.11",
|
|
60
60
|
"@vitest/coverage-v8": "4.0.18",
|
|
61
61
|
"eslint": "9.39.2",
|
|
62
62
|
"eslint-plugin-import": "2.32.0",
|
|
@@ -71,17 +71,18 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@croct/json5-parser": "0.2.2",
|
|
73
73
|
"@swc/core": "1.15.11",
|
|
74
|
+
"yaml": "2.8.2",
|
|
74
75
|
"chalk": "5.6.2",
|
|
75
76
|
"chokidar": "5.0.0",
|
|
76
77
|
"commander": "14.0.3",
|
|
77
78
|
"execa": "9.6.1",
|
|
78
|
-
"glob": "13.0.
|
|
79
|
+
"glob": "13.0.1",
|
|
79
80
|
"i18next-resources-for-ts": "2.0.0",
|
|
80
81
|
"inquirer": "13.2.2",
|
|
81
82
|
"jiti": "2.6.1",
|
|
82
83
|
"jsonc-parser": "3.3.1",
|
|
83
|
-
"minimatch": "10.1.
|
|
84
|
-
"ora": "9.
|
|
84
|
+
"minimatch": "10.1.2",
|
|
85
|
+
"ora": "9.3.0",
|
|
85
86
|
"react": "^19.2.4",
|
|
86
87
|
"react-i18next": "^16.5.4",
|
|
87
88
|
"swc-walk": "1.0.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/jsx-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAgB,MAAM,aAAa,CAAA;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAI1D,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,eAAe,CAAY;gBAGjC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,MAAM,MAAM,EAC5B,cAAc,EAAE,MAAM,MAAM;IAS9B;;OAEG;IACI,gBAAgB,IAAK,IAAI;IAI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AS,GAAG,IAAI;IAwUjI;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,0BAA0B;IAuHlC;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;CAevB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heuristic-config.d.ts","sourceRoot":"","sources":["../src/heuristic-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"heuristic-config.d.ts","sourceRoot":"","sources":["../src/heuristic-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA+CnD;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAK,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,CA6DnF"}
|
package/types/types.d.ts
CHANGED
|
@@ -104,12 +104,13 @@ export interface I18nextToolkitConfig {
|
|
|
104
104
|
* The format of the output translation files.
|
|
105
105
|
* 'json': Standard JSON file (default)
|
|
106
106
|
* 'json5': JSON5 file
|
|
107
|
+
* 'yaml': YAML file
|
|
107
108
|
* 'js': JavaScript file with ES Module syntax (export default)
|
|
108
109
|
* 'js-esm': JavaScript file with ES Module syntax (export default)
|
|
109
110
|
* 'js-cjs': JavaScript file with CommonJS syntax (module.exports)
|
|
110
111
|
* 'ts': TypeScript file with ES Module syntax and `as const` for type safety
|
|
111
112
|
*/
|
|
112
|
-
outputFormat?: 'json' | 'json5' | 'js' | 'ts' | 'js-esm' | 'js-cjs' | 'ts';
|
|
113
|
+
outputFormat?: 'json' | 'json5' | 'yaml' | 'js' | 'ts' | 'js-esm' | 'js-cjs' | 'ts';
|
|
113
114
|
/**
|
|
114
115
|
* If true, all namespaces will be merged into a single file per language.
|
|
115
116
|
* The `output` path should not contain the `{{namespace}}` placeholder.
|
package/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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E,UAAU,EAAE,kBAAkB,CAAC,EAAE,OAAO,KAAK,MAAM,EAAE,CAAA;CACpG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAExD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACrD,gBAAgB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -60,4 +60,11 @@ export declare function loadRawJson5Content(filePath: string): Promise<string |
|
|
|
60
60
|
* For JSON5, preserves comments and formatting using JsonObjectNode.update().
|
|
61
61
|
*/
|
|
62
62
|
export declare function serializeTranslationFile(data: Record<string, any>, format?: I18nextToolkitConfig['extract']['outputFormat'], indentation?: number | string, rawContent?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Infers the output format from the file path extension.
|
|
65
|
+
* @param filePath - The path to the translation file
|
|
66
|
+
* @param defaultFormat - The default format to return if no match (default: 'json')
|
|
67
|
+
* @returns The inferred output format
|
|
68
|
+
*/
|
|
69
|
+
export declare function inferFormatFromPath(filePath: string, defaultFormat?: I18nextToolkitConfig['extract']['outputFormat']): NonNullable<I18nextToolkitConfig['extract']['outputFormat']>;
|
|
63
70
|
//# sourceMappingURL=file-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;
|
|
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