forked from boos/BoosAPI
fix: restore frontend source code (src/web/) that was accidentally deleted
Frontend source is needed for development/building the SPA. Only Node.js runtime server code should be removed.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { translateText } from './i18n.js';
|
||||
|
||||
describe('translateText', () => {
|
||||
it('keeps zh text unchanged in zh mode', () => {
|
||||
expect(translateText('模型广场', 'zh')).toBe('模型广场');
|
||||
});
|
||||
|
||||
it('translates exact key in en mode', () => {
|
||||
expect(translateText('模型广场', 'en')).toBe('Model Marketplace');
|
||||
});
|
||||
|
||||
it('supports phrase replacement for mixed text', () => {
|
||||
expect(translateText('覆盖槽位 3', 'en')).toBe('Coverage Slots 3');
|
||||
expect(translateText('共 12 个模型', 'en')).toBe('Total 12 models');
|
||||
});
|
||||
|
||||
it('never returns Chinese characters in strict en mode', () => {
|
||||
const samples = [
|
||||
'站点已禁用',
|
||||
'缓存清理后重建失败:unknown error',
|
||||
'签到任务执行中,请稍后查看签到日志',
|
||||
];
|
||||
|
||||
for (const sample of samples) {
|
||||
expect(translateText(sample, 'en')).not.toMatch(/[\u3400-\u9fff]/);
|
||||
}
|
||||
});
|
||||
|
||||
it('uses concrete english translations instead of fallback for common runtime text', () => {
|
||||
expect(translateText('切换到中文', 'en')).toBe('Switch to Chinese');
|
||||
expect(translateText('中', 'en')).toBe('ZH');
|
||||
|
||||
const samples = [
|
||||
'站点已禁用',
|
||||
'签到任务执行中,请稍后查看签到日志',
|
||||
'下游访问令牌至少 6 位(含 sk-)',
|
||||
'路由重建任务执行中,请稍后查看程序日志',
|
||||
];
|
||||
|
||||
for (const sample of samples) {
|
||||
const translated = translateText(sample, 'en');
|
||||
expect(translated).not.toBe('Untranslated');
|
||||
expect(translated).not.toMatch(/[\u3400-\u9fff]/);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user