i18next-cli 1.42.7 → 1.42.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/translation-manager.js +16 -8
- package/dist/cjs/linter.js +19 -0
- package/dist/cjs/utils/file-utils.js +0 -38
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/translation-manager.js +18 -10
- package/dist/esm/linter.js +19 -0
- package/dist/esm/utils/file-utils.js +1 -38
- package/package.json +1 -1
- package/types/extractor/core/translation-manager.d.ts.map +1 -1
- package/types/linter.d.ts.map +1 -1
- package/types/utils/file-utils.d.ts +0 -16
- package/types/utils/file-utils.d.ts.map +1 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ const program = new commander.Command();
|
|
|
28
28
|
program
|
|
29
29
|
.name('i18next-cli')
|
|
30
30
|
.description('A unified, high-performance i18next CLI.')
|
|
31
|
-
.version('1.42.
|
|
31
|
+
.version('1.42.9'); // This string is replaced with the actual version at build time by rollup
|
|
32
32
|
// new: global config override option
|
|
33
33
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
34
34
|
program
|
|
@@ -796,6 +796,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
796
796
|
const namespacesToProcess = existingIsNamespaced
|
|
797
797
|
? new Set([...keysByNS.keys(), ...existingKeys])
|
|
798
798
|
: new Set([...keysByNS.keys(), NO_NS_TOKEN]);
|
|
799
|
+
// Remove ignored namespaces so their section is never modified
|
|
800
|
+
for (const ns of ignoreNamespaces) {
|
|
801
|
+
namespacesToProcess.delete(ns);
|
|
802
|
+
}
|
|
799
803
|
for (const nsKey of namespacesToProcess) {
|
|
800
804
|
const nsKeys = keysByNS.get(nsKey) || [];
|
|
801
805
|
if (nsKey === NO_NS_TOKEN) {
|
|
@@ -808,6 +812,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
808
812
|
newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults);
|
|
809
813
|
}
|
|
810
814
|
}
|
|
815
|
+
// Preserve ignored namespaces as-is from the existing merged file
|
|
816
|
+
for (const ns of ignoreNamespaces) {
|
|
817
|
+
if (ns in existingMergedFile) {
|
|
818
|
+
newMergedTranslations[ns] = existingMergedFile[ns];
|
|
819
|
+
}
|
|
820
|
+
}
|
|
811
821
|
const oldContent = JSON.stringify(existingMergedFile, null, indentation);
|
|
812
822
|
const newContent = JSON.stringify(newMergedTranslations, null, indentation);
|
|
813
823
|
// Push a single result for the merged file
|
|
@@ -816,23 +826,21 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
816
826
|
}
|
|
817
827
|
else {
|
|
818
828
|
// Find all namespaces that exist on disk for this locale.
|
|
819
|
-
// Use '**' so the glob crosses directory boundaries — namespaces
|
|
820
|
-
// can contain '/' and span multiple directory levels.
|
|
821
829
|
const namespacesToProcess = new Set(keysByNS.keys());
|
|
822
|
-
const existingNsPattern = fileUtils.getOutputPath(config.extract.output, locale, '
|
|
830
|
+
const existingNsPattern = fileUtils.getOutputPath(config.extract.output, locale, '*');
|
|
823
831
|
// Ensure glob receives POSIX-style separators so pattern matching works cross-platform (Windows -> backslashes)
|
|
824
832
|
const existingNsGlobPattern = existingNsPattern.replace(/\\/g, '/');
|
|
825
833
|
const existingNsFiles = await glob.glob(existingNsGlobPattern, { ignore: userIgnore });
|
|
826
834
|
for (const file of existingNsFiles) {
|
|
827
|
-
|
|
828
|
-
// by matching it against the output template.
|
|
829
|
-
const ns = typeof config.extract.output === 'string'
|
|
830
|
-
? fileUtils.extractNamespaceFromPath(config.extract.output, locale, file)
|
|
831
|
-
: undefined;
|
|
835
|
+
const ns = node_path.basename(file, node_path.extname(file));
|
|
832
836
|
if (ns) {
|
|
833
837
|
namespacesToProcess.add(ns);
|
|
834
838
|
}
|
|
835
839
|
}
|
|
840
|
+
// Remove ignored namespaces so their files are never modified
|
|
841
|
+
for (const ns of ignoreNamespaces) {
|
|
842
|
+
namespacesToProcess.delete(ns);
|
|
843
|
+
}
|
|
836
844
|
// Process each namespace individually and create a result for each one
|
|
837
845
|
for (const ns of namespacesToProcess) {
|
|
838
846
|
const nsKeys = keysByNS.get(ns) || [];
|
package/dist/cjs/linter.js
CHANGED
|
@@ -23,6 +23,22 @@ function extractInterpolationKeys(str, config) {
|
|
|
23
23
|
}
|
|
24
24
|
return keys;
|
|
25
25
|
}
|
|
26
|
+
// Known i18next t() option keys that are NOT interpolation parameters.
|
|
27
|
+
// These should not be flagged as "unused" in the translation string.
|
|
28
|
+
const i18nextOptionKeys = new Set([
|
|
29
|
+
'defaultValue', 'count', 'context', 'ns', 'lng', 'lngs',
|
|
30
|
+
'fallbackLng', 'returnDetails', 'returnObjects', 'joinArrays',
|
|
31
|
+
'postProcess', 'interpolation', 'skipInterpolation', 'replace',
|
|
32
|
+
'ordinal', 'keySeparator', 'nsSeparator', 'tDescription',
|
|
33
|
+
]);
|
|
34
|
+
function isI18nextOptionKey(key) {
|
|
35
|
+
if (i18nextOptionKeys.has(key))
|
|
36
|
+
return true;
|
|
37
|
+
// defaultValue_one, defaultValue_other, defaultValue_many, etc.
|
|
38
|
+
if (key.startsWith('defaultValue_'))
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
26
42
|
// Helper to lint interpolation parameter errors in t() calls
|
|
27
43
|
function lintInterpolationParams(ast, code, config) {
|
|
28
44
|
const issues = [];
|
|
@@ -132,7 +148,10 @@ function lintInterpolationParams(ast, code, config) {
|
|
|
132
148
|
}
|
|
133
149
|
}
|
|
134
150
|
// For each provided param, check if it is used either directly or as the root of a dotted key.
|
|
151
|
+
// Skip known i18next t() option keys that are not interpolation parameters.
|
|
135
152
|
for (const pk of paramKeys) {
|
|
153
|
+
if (isI18nextOptionKey(pk))
|
|
154
|
+
continue;
|
|
136
155
|
const isUsed = keys.some(k => k === pk || k.split('.')[0] === pk);
|
|
137
156
|
if (!isUsed) {
|
|
138
157
|
issues.push({
|
|
@@ -45,43 +45,6 @@ function getOutputPath(outputTemplate, language, namespace) {
|
|
|
45
45
|
out = out.replace(/\/\/+/g, '/');
|
|
46
46
|
return node_path.normalize(out);
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Extracts the namespace value from a concrete file path by matching it against
|
|
50
|
-
* the output template.
|
|
51
|
-
*
|
|
52
|
-
* Given a template like `src/{{namespace}}/locales/{{language}}.json` and a file
|
|
53
|
-
* path like `src/widgets/component/locales/en.json`, this returns `widgets/component`.
|
|
54
|
-
*
|
|
55
|
-
* This handles multi-segment namespaces (namespaces containing `/`) which
|
|
56
|
-
* `basename()` cannot recover.
|
|
57
|
-
*
|
|
58
|
-
* @param outputTemplate - The output path template string (must contain `{{namespace}}`)
|
|
59
|
-
* @param language - The language value used when the file was generated
|
|
60
|
-
* @param filePath - The concrete file path to extract the namespace from
|
|
61
|
-
* @returns The namespace string, or `undefined` if the path doesn't match the template
|
|
62
|
-
*/
|
|
63
|
-
function extractNamespaceFromPath(outputTemplate, language, filePath) {
|
|
64
|
-
// Build a regex from the template by escaping everything except the placeholders.
|
|
65
|
-
// Replace {{language}}/{{lng}} with the literal language value and
|
|
66
|
-
// {{namespace}} with a named capture group that matches one or more path segments.
|
|
67
|
-
const pattern = outputTemplate
|
|
68
|
-
// Normalise to forward slashes for matching
|
|
69
|
-
.replace(/\\/g, '/');
|
|
70
|
-
// Escape regex-special characters (but keep our placeholders intact first)
|
|
71
|
-
const nsPlaceholder = '{{namespace}}';
|
|
72
|
-
const parts = pattern.split(nsPlaceholder);
|
|
73
|
-
// Escape each part individually then rejoin with the capture group
|
|
74
|
-
const escaped = parts.map(p => p
|
|
75
|
-
.replace(/\{\{language\}\}|\{\{lng\}\}/g, () => escapeForRegex(language))
|
|
76
|
-
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
77
|
-
// Don't anchor the start — the glob may return absolute or prefixed paths.
|
|
78
|
-
// Anchor only the end so that the namespace capture is unambiguous.
|
|
79
|
-
const regexStr = escaped.join('(.+)') + '$';
|
|
80
|
-
const normalized = filePath.replace(/\\/g, '/');
|
|
81
|
-
const m = new RegExp(regexStr).exec(normalized);
|
|
82
|
-
return m?.[1];
|
|
83
|
-
}
|
|
84
|
-
const escapeForRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
85
48
|
/**
|
|
86
49
|
* Dynamically loads a translation file, supporting .json, .js, and .ts formats.
|
|
87
50
|
* @param filePath - The path to the translation file.
|
|
@@ -193,7 +156,6 @@ function inferFormatFromPath(filePath, defaultFormat = 'json') {
|
|
|
193
156
|
return defaultFormat || 'json';
|
|
194
157
|
}
|
|
195
158
|
|
|
196
|
-
exports.extractNamespaceFromPath = extractNamespaceFromPath;
|
|
197
159
|
exports.getOutputPath = getOutputPath;
|
|
198
160
|
exports.inferFormatFromPath = inferFormatFromPath;
|
|
199
161
|
exports.loadRawJson5Content = loadRawJson5Content;
|
package/dist/esm/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ const program = new Command();
|
|
|
26
26
|
program
|
|
27
27
|
.name('i18next-cli')
|
|
28
28
|
.description('A unified, high-performance i18next CLI.')
|
|
29
|
-
.version('1.42.
|
|
29
|
+
.version('1.42.9'); // This string is replaced with the actual version at build time by rollup
|
|
30
30
|
// new: global config override option
|
|
31
31
|
program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
|
|
32
32
|
program
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
1
|
+
import { resolve, basename, extname } from 'node:path';
|
|
2
2
|
import { glob } from 'glob';
|
|
3
3
|
import { getNestedKeys, getNestedValue, setNestedValue } from '../../utils/nested-object.js';
|
|
4
|
-
import { getOutputPath, loadTranslationFile
|
|
4
|
+
import { getOutputPath, loadTranslationFile } from '../../utils/file-utils.js';
|
|
5
5
|
import { resolveDefaultValue } from '../../utils/default-value.js';
|
|
6
6
|
|
|
7
7
|
// used for natural language check
|
|
@@ -794,6 +794,10 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
794
794
|
const namespacesToProcess = existingIsNamespaced
|
|
795
795
|
? new Set([...keysByNS.keys(), ...existingKeys])
|
|
796
796
|
: new Set([...keysByNS.keys(), NO_NS_TOKEN]);
|
|
797
|
+
// Remove ignored namespaces so their section is never modified
|
|
798
|
+
for (const ns of ignoreNamespaces) {
|
|
799
|
+
namespacesToProcess.delete(ns);
|
|
800
|
+
}
|
|
797
801
|
for (const nsKey of namespacesToProcess) {
|
|
798
802
|
const nsKeys = keysByNS.get(nsKey) || [];
|
|
799
803
|
if (nsKey === NO_NS_TOKEN) {
|
|
@@ -806,6 +810,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
806
810
|
newMergedTranslations[nsKey] = buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale, nsKey, preservePatterns, objectKeys, syncPrimaryWithDefaults);
|
|
807
811
|
}
|
|
808
812
|
}
|
|
813
|
+
// Preserve ignored namespaces as-is from the existing merged file
|
|
814
|
+
for (const ns of ignoreNamespaces) {
|
|
815
|
+
if (ns in existingMergedFile) {
|
|
816
|
+
newMergedTranslations[ns] = existingMergedFile[ns];
|
|
817
|
+
}
|
|
818
|
+
}
|
|
809
819
|
const oldContent = JSON.stringify(existingMergedFile, null, indentation);
|
|
810
820
|
const newContent = JSON.stringify(newMergedTranslations, null, indentation);
|
|
811
821
|
// Push a single result for the merged file
|
|
@@ -814,23 +824,21 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
814
824
|
}
|
|
815
825
|
else {
|
|
816
826
|
// Find all namespaces that exist on disk for this locale.
|
|
817
|
-
// Use '**' so the glob crosses directory boundaries — namespaces
|
|
818
|
-
// can contain '/' and span multiple directory levels.
|
|
819
827
|
const namespacesToProcess = new Set(keysByNS.keys());
|
|
820
|
-
const existingNsPattern = getOutputPath(config.extract.output, locale, '
|
|
828
|
+
const existingNsPattern = getOutputPath(config.extract.output, locale, '*');
|
|
821
829
|
// Ensure glob receives POSIX-style separators so pattern matching works cross-platform (Windows -> backslashes)
|
|
822
830
|
const existingNsGlobPattern = existingNsPattern.replace(/\\/g, '/');
|
|
823
831
|
const existingNsFiles = await glob(existingNsGlobPattern, { ignore: userIgnore });
|
|
824
832
|
for (const file of existingNsFiles) {
|
|
825
|
-
|
|
826
|
-
// by matching it against the output template.
|
|
827
|
-
const ns = typeof config.extract.output === 'string'
|
|
828
|
-
? extractNamespaceFromPath(config.extract.output, locale, file)
|
|
829
|
-
: undefined;
|
|
833
|
+
const ns = basename(file, extname(file));
|
|
830
834
|
if (ns) {
|
|
831
835
|
namespacesToProcess.add(ns);
|
|
832
836
|
}
|
|
833
837
|
}
|
|
838
|
+
// Remove ignored namespaces so their files are never modified
|
|
839
|
+
for (const ns of ignoreNamespaces) {
|
|
840
|
+
namespacesToProcess.delete(ns);
|
|
841
|
+
}
|
|
834
842
|
// Process each namespace individually and create a result for each one
|
|
835
843
|
for (const ns of namespacesToProcess) {
|
|
836
844
|
const nsKeys = keysByNS.get(ns) || [];
|
package/dist/esm/linter.js
CHANGED
|
@@ -21,6 +21,22 @@ function extractInterpolationKeys(str, config) {
|
|
|
21
21
|
}
|
|
22
22
|
return keys;
|
|
23
23
|
}
|
|
24
|
+
// Known i18next t() option keys that are NOT interpolation parameters.
|
|
25
|
+
// These should not be flagged as "unused" in the translation string.
|
|
26
|
+
const i18nextOptionKeys = new Set([
|
|
27
|
+
'defaultValue', 'count', 'context', 'ns', 'lng', 'lngs',
|
|
28
|
+
'fallbackLng', 'returnDetails', 'returnObjects', 'joinArrays',
|
|
29
|
+
'postProcess', 'interpolation', 'skipInterpolation', 'replace',
|
|
30
|
+
'ordinal', 'keySeparator', 'nsSeparator', 'tDescription',
|
|
31
|
+
]);
|
|
32
|
+
function isI18nextOptionKey(key) {
|
|
33
|
+
if (i18nextOptionKeys.has(key))
|
|
34
|
+
return true;
|
|
35
|
+
// defaultValue_one, defaultValue_other, defaultValue_many, etc.
|
|
36
|
+
if (key.startsWith('defaultValue_'))
|
|
37
|
+
return true;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
24
40
|
// Helper to lint interpolation parameter errors in t() calls
|
|
25
41
|
function lintInterpolationParams(ast, code, config) {
|
|
26
42
|
const issues = [];
|
|
@@ -130,7 +146,10 @@ function lintInterpolationParams(ast, code, config) {
|
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
148
|
// For each provided param, check if it is used either directly or as the root of a dotted key.
|
|
149
|
+
// Skip known i18next t() option keys that are not interpolation parameters.
|
|
133
150
|
for (const pk of paramKeys) {
|
|
151
|
+
if (isI18nextOptionKey(pk))
|
|
152
|
+
continue;
|
|
134
153
|
const isUsed = keys.some(k => k === pk || k.split('.')[0] === pk);
|
|
135
154
|
if (!isUsed) {
|
|
136
155
|
issues.push({
|
|
@@ -43,43 +43,6 @@ function getOutputPath(outputTemplate, language, namespace) {
|
|
|
43
43
|
out = out.replace(/\/\/+/g, '/');
|
|
44
44
|
return normalize(out);
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Extracts the namespace value from a concrete file path by matching it against
|
|
48
|
-
* the output template.
|
|
49
|
-
*
|
|
50
|
-
* Given a template like `src/{{namespace}}/locales/{{language}}.json` and a file
|
|
51
|
-
* path like `src/widgets/component/locales/en.json`, this returns `widgets/component`.
|
|
52
|
-
*
|
|
53
|
-
* This handles multi-segment namespaces (namespaces containing `/`) which
|
|
54
|
-
* `basename()` cannot recover.
|
|
55
|
-
*
|
|
56
|
-
* @param outputTemplate - The output path template string (must contain `{{namespace}}`)
|
|
57
|
-
* @param language - The language value used when the file was generated
|
|
58
|
-
* @param filePath - The concrete file path to extract the namespace from
|
|
59
|
-
* @returns The namespace string, or `undefined` if the path doesn't match the template
|
|
60
|
-
*/
|
|
61
|
-
function extractNamespaceFromPath(outputTemplate, language, filePath) {
|
|
62
|
-
// Build a regex from the template by escaping everything except the placeholders.
|
|
63
|
-
// Replace {{language}}/{{lng}} with the literal language value and
|
|
64
|
-
// {{namespace}} with a named capture group that matches one or more path segments.
|
|
65
|
-
const pattern = outputTemplate
|
|
66
|
-
// Normalise to forward slashes for matching
|
|
67
|
-
.replace(/\\/g, '/');
|
|
68
|
-
// Escape regex-special characters (but keep our placeholders intact first)
|
|
69
|
-
const nsPlaceholder = '{{namespace}}';
|
|
70
|
-
const parts = pattern.split(nsPlaceholder);
|
|
71
|
-
// Escape each part individually then rejoin with the capture group
|
|
72
|
-
const escaped = parts.map(p => p
|
|
73
|
-
.replace(/\{\{language\}\}|\{\{lng\}\}/g, () => escapeForRegex(language))
|
|
74
|
-
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
75
|
-
// Don't anchor the start — the glob may return absolute or prefixed paths.
|
|
76
|
-
// Anchor only the end so that the namespace capture is unambiguous.
|
|
77
|
-
const regexStr = escaped.join('(.+)') + '$';
|
|
78
|
-
const normalized = filePath.replace(/\\/g, '/');
|
|
79
|
-
const m = new RegExp(regexStr).exec(normalized);
|
|
80
|
-
return m?.[1];
|
|
81
|
-
}
|
|
82
|
-
const escapeForRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
83
46
|
/**
|
|
84
47
|
* Dynamically loads a translation file, supporting .json, .js, and .ts formats.
|
|
85
48
|
* @param filePath - The path to the translation file.
|
|
@@ -191,4 +154,4 @@ function inferFormatFromPath(filePath, defaultFormat = 'json') {
|
|
|
191
154
|
return defaultFormat || 'json';
|
|
192
155
|
}
|
|
193
156
|
|
|
194
|
-
export {
|
|
157
|
+
export { getOutputPath, inferFormatFromPath, loadRawJson5Content, loadTranslationFile, serializeTranslationFile };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAgyBnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EAChB,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CACb,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAgyBnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EAChB,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CACb,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA8J9B"}
|
package/types/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,S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|
|
@@ -48,22 +48,6 @@ export declare function writeFileAsync(filePath: string, data: string): Promise<
|
|
|
48
48
|
* - Normalizes duplicate slashes and returns a platform-correct path.
|
|
49
49
|
*/
|
|
50
50
|
export declare function getOutputPath(outputTemplate: string | ((language: string, namespace?: string) => string) | undefined, language: string, namespace?: string): string;
|
|
51
|
-
/**
|
|
52
|
-
* Extracts the namespace value from a concrete file path by matching it against
|
|
53
|
-
* the output template.
|
|
54
|
-
*
|
|
55
|
-
* Given a template like `src/{{namespace}}/locales/{{language}}.json` and a file
|
|
56
|
-
* path like `src/widgets/component/locales/en.json`, this returns `widgets/component`.
|
|
57
|
-
*
|
|
58
|
-
* This handles multi-segment namespaces (namespaces containing `/`) which
|
|
59
|
-
* `basename()` cannot recover.
|
|
60
|
-
*
|
|
61
|
-
* @param outputTemplate - The output path template string (must contain `{{namespace}}`)
|
|
62
|
-
* @param language - The language value used when the file was generated
|
|
63
|
-
* @param filePath - The concrete file path to extract the namespace from
|
|
64
|
-
* @returns The namespace string, or `undefined` if the path doesn't match the template
|
|
65
|
-
*/
|
|
66
|
-
export declare function extractNamespaceFromPath(outputTemplate: string, language: string, filePath: string): string | undefined;
|
|
67
51
|
/**
|
|
68
52
|
* Dynamically loads a translation file, supporting .json, .js, and .ts formats.
|
|
69
53
|
* @param filePath - The path to the translation file.
|
|
@@ -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;AAKpD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAs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