locale-sync-cli 1.0.0 → 1.0.1
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.
|
@@ -49,8 +49,8 @@ async function scanLocales(localesDirs, ignore = []) {
|
|
|
49
49
|
|
|
50
50
|
for (const file of files) {
|
|
51
51
|
// locale 检测策略(优先级):
|
|
52
|
-
// 1.
|
|
53
|
-
// 2.
|
|
52
|
+
// 1. 任意目录层级名称是合法 locale 代码 → 使用目录名(如 en-US/common.js → 'enus')
|
|
53
|
+
// 2. 文件名是合法 locale 代码且不在 locale 目录下 → 使用文件名(如 en-US.js → 'enus')
|
|
54
54
|
// 3. 都不是 → 使用规范化后的文件名(多 locale 文件由 multi-locale 检测覆盖)
|
|
55
55
|
const relPath = path.relative(resolvedDir, file);
|
|
56
56
|
const relParts = relPath.split(path.sep);
|
|
@@ -59,9 +59,7 @@ async function scanLocales(localesDirs, ignore = []) {
|
|
|
59
59
|
const dirParts = relParts.slice(0, -1); // 所有目录层级,不含文件名
|
|
60
60
|
const rawLocaleDir = dirParts.find(p => LOCALE_RE.test(p)) ?? null;
|
|
61
61
|
const localeDirNorm = rawLocaleDir ? rawLocaleDir.toLowerCase().replace(/[-_]/g, '') : null;
|
|
62
|
-
const locale =
|
|
63
|
-
? fileBase
|
|
64
|
-
: (rawLocaleDir ? localeDirNorm : fileBase);
|
|
62
|
+
const locale = rawLocaleDir ? localeDirNorm : fileBase;
|
|
65
63
|
|
|
66
64
|
const ext = path.extname(file).toLowerCase();
|
|
67
65
|
const entry = { filePath: file, keyMap: {}, values: {} };
|