import {readFileSync} from 'node:fs';
import {fileURLToPath} from 'node:url';
import {resolve} from 'node:path';
const root = resolve(fileURLToPath(new URL('../..', import.meta.url)));
const appSource = readFileSync(resolve(root, 'frontend/src/App.tsx'), 'utf8');
const mainSource = readFileSync(resolve(root, 'main.go'), 'utf8');
const appOptionsSource = readFileSync(resolve(root, 'app_options.go'), 'utf8');
const backendEntrySource = `${mainSource}\n${appOptionsSource}`;
const forbiddenUiText = [
/
Skill Manager<\/h1>/,
/>\s*Config\s*,
/>\s*Remote\s*,
/>\s*Local\s*,
/>\s*Check Updates\s*,
/Gitea Base URL<\/span>/,
/Organization<\/span>/,
/Auth Type<\/span>/,
/>\s*Password\s*,
/Username<\/span>/,
/Credential Key<\/span>/,
/Auto update<\/span>/,
/Check on startup<\/span>/,
/Interval Minutes<\/span>/,
/>\s*Save\s*,
/>\s*Test\s*,
/placeholder="Search repositories"/,
/>\s*Refresh\s*,
/| Description<\/th>/,
/ | Branch<\/th>/,
/ | Status<\/th>/,
/ | Action<\/th>/,
/ | Actions<\/th>/,
/>\s*Update\s*,
/>\s*Download\s*,
/title="Open folder"/,
/>No remote skills,
/>No local skills,
/return 'Remote Market';/,
/return 'Local Skills';/,
/return 'Configuration';/,
/Delete local skill/,
/title="Delete local"/,
/Remote list refreshed/,
/Config saved/,
/Connected as/,
/installed to/,
/uninstalled from/,
/>not installed,
];
const requiredChineseText = [
'技能管理器',
'配置',
'远程市场',
'本地技能',
'检查更新',
'保存',
'测试连接',
'搜索仓库',
'刷新',
'下载',
'更新',
'操作',
'暂无远程技能',
'暂无本地技能',
'已下载',
'已安装',
'未安装',
];
const failures = [];
for (const pattern of forbiddenUiText) {
if (pattern.test(appSource)) {
failures.push(`App.tsx still matches English UI pattern: ${pattern}`);
}
}
for (const text of requiredChineseText) {
if (!appSource.includes(text)) {
failures.push(`App.tsx is missing Chinese UI text: ${text}`);
}
}
if (!backendEntrySource.includes('SGG AI 技能管理器')) {
failures.push('window title is not Chinese');
}
if (failures.length > 0) {
console.error(failures.join('\n'));
process.exit(1);
}
|