Files
his/healthlink-his-ui/scripts/merge_pending.cjs
chenqi 24dc16b8d1 refactor(ybmock): 重构医保模拟接口并更新国际化配置
- 将医保模拟接口从通用路由改为具体功能路由
- 新增签到、取消门诊登记、预结算等功能接口
- 统一返回格式为 code/message/result 结构
- 移除旧版医保接口路由兼容处理
- 更新前端国际化配置文件中的医保相关词条
- 删除重复的无数据提示词条并补充新的字段翻译
- 移除药房模块独立词条合并至通用配置中
- 新增住院管理模块的完整国际化词条配置
2026-06-26 16:06:15 +08:00

54 lines
1.9 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const localesDir = path.join(__dirname, '..', 'src', 'i18n', 'locales');
// Load main locale files
const zhCN = JSON.parse(fs.readFileSync(path.join(localesDir, 'zhCN.json'), 'utf8'));
const enUS = JSON.parse(fs.readFileSync(path.join(localesDir, 'enUS.json'), 'utf8'));
const viVN = JSON.parse(fs.readFileSync(path.join(localesDir, 'viVN.json'), 'utf8'));
// Deep merge function
function deepMerge(target, source) {
for (const key in source) {
if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {
if (!target[key]) target[key] = {};
deepMerge(target[key], source[key]);
} else {
if (!target[key]) target[key] = source[key];
}
}
return target;
}
// Process pending files
const pendingFiles = fs.readdirSync(localesDir).filter(f => f.startsWith('_pending') && f.endsWith('.json'));
for (const file of pendingFiles) {
const filePath = path.join(localesDir, file);
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
// Each pending file has zh/en/vi sections
if (data.zh) deepMerge(zhCN, data.zh);
if (data.en) deepMerge(enUS, data.en);
if (data.vi) deepMerge(viVN, data.vi);
console.log('Merged:', file);
}
// Write back
fs.writeFileSync(path.join(localesDir, 'zhCN.json'), JSON.stringify(zhCN, null, 2), 'utf8');
fs.writeFileSync(path.join(localesDir, 'enUS.json'), JSON.stringify(enUS, null, 2), 'utf8');
fs.writeFileSync(path.join(localesDir, 'viVN.json'), JSON.stringify(viVN, null, 2), 'utf8');
// Count keys
function countKeys(obj) { let c=0; for(const k in obj){if(typeof obj[k]==='object'&&obj[k]!==null) c+=countKeys(obj[k]); else c++;} return c; }
console.log('zhCN:', countKeys(zhCN));
console.log('enUS:', countKeys(enUS));
console.log('viVN:', countKeys(viVN));
// Remove pending files
for (const file of pendingFiles) {
fs.unlinkSync(path.join(localesDir, file));
console.log('Removed:', file);
}