Files
lucky_shop/scripts/audit_lang_bundle.js
ZF sun 2d7d7f731c fix(remote lang tree): 修复命名空间被基本类型值覆盖的bug
修复remote-only模式下语言包归一化的历史bug:当页面leaf顶层存在与命名空间同名的字符串键时,会覆盖整个namespace导致子key失效。通过对齐normalizePageLangPack的两层合并逻辑来修复:
1. 先将页面语言包按路径段转为命名空间结构再合并
2. 额外平铺leaf的基本类型键到根节点以兼容短key调用
2026-07-04 09:25:01 +08:00

25 lines
751 B
JavaScript

// Node script: load all lang files via require and dump as JSON for Python to consume.
const fs = require('fs');
const path = require('path');
const langDir = path.resolve(process.cwd(), 'lang', process.argv[2]);
function walk(dir) {
const out = {};
if (!fs.existsSync(dir)) return out;
for (const f of fs.readdirSync(dir)) {
const full = path.join(dir, f);
const stat = fs.statSync(full);
if (stat.isDirectory()) {
Object.assign(out, walk(full));
} else if (f.endsWith('.js')) {
try {
const m = require(full);
if (m && m.lang && typeof m.lang === 'object') {
out[full] = m.lang;
}
} catch (e) {}
}
}
return out;
}
console.log(JSON.stringify(walk(langDir), null, 2));