mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-09 16:23:27 +08:00
✨ feat(i18n): 完善多模块多语言适配与发版验证
扩展前后端多语言文案与共享词典。增加多模块 i18n 回归测试与 guard。收口外部 SQL 菜单和弹窗多语言文案。
This commit is contained in:
36
frontend/src/components/SidebarV2GroupFallback.i18n.test.ts
Normal file
36
frontend/src/components/SidebarV2GroupFallback.i18n.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const sidebarSource = readFileSync(new URL('./Sidebar.tsx', import.meta.url), 'utf8');
|
||||
const sidebarV2UtilsSource = readFileSync(new URL('./sidebarV2Utils.ts', import.meta.url), 'utf8');
|
||||
|
||||
const locales = ['zh-CN', 'zh-TW', 'en-US', 'ja-JP', 'de-DE', 'ru-RU'] as const;
|
||||
const requiredKeys = [
|
||||
'connection.sidebar.group.untitled',
|
||||
'connection.sidebar.group.badge',
|
||||
];
|
||||
|
||||
describe('Sidebar v2 connection group fallback i18n', () => {
|
||||
it('localizes v2 connection group fallback names and badges', () => {
|
||||
[
|
||||
"name: tag.name || '未命名分组'",
|
||||
"fallback = '组'",
|
||||
].forEach((snippet) => {
|
||||
expect(sidebarSource).not.toContain(snippet);
|
||||
expect(sidebarV2UtilsSource).not.toContain(snippet);
|
||||
});
|
||||
|
||||
expect(sidebarSource).toContain("tag.name || t('connection.sidebar.group.untitled')");
|
||||
expect(sidebarSource).toContain("fallback = t('connection.sidebar.group.badge')");
|
||||
expect(sidebarV2UtilsSource).toContain("fallback = t('connection.sidebar.group.badge')");
|
||||
});
|
||||
|
||||
it('keeps v2 connection group fallback keys available in every locale', () => {
|
||||
locales.forEach((locale) => {
|
||||
const catalog = JSON.parse(readFileSync(new URL(`../../../shared/i18n/${locale}.json`, import.meta.url), 'utf8')) as Record<string, string>;
|
||||
requiredKeys.forEach((key) => {
|
||||
expect(catalog[key], `${locale}:${key}`).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user