import test from 'node:test'; import assert from 'node:assert/strict'; import i18n from '../src/locale/index'; import { routes, IRoute } from '../src/routes'; // 递归收集 routes.ts 中所有的菜单 key (name) function extractRouteNames(list: IRoute[]): string[] { const names: string[] = []; for (const item of list) { if (item.name) { names.push(item.name); } if (item.children && item.children.length > 0) { names.push(...extractRouteNames(item.children)); } } return names; } test('1. 所有路由中的菜单项必须在 en-US 和 zh-CN 字典中有完整定义', () => { const routeNames = extractRouteNames(routes); const enMessages = i18n['en-US']; const zhMessages = i18n['zh-CN']; for (const name of routeNames) { assert.ok( typeof enMessages[name] === 'string' && enMessages[name].length > 0, `en-US 缺少菜单项翻译: ${name}` ); assert.ok( typeof zhMessages[name] === 'string' && zhMessages[name].length > 0, `zh-CN 缺少菜单项翻译: ${name}` ); } }); test('2. 英文菜单文案必须简练原生,长度不可超过 15 个字符以杜绝截断', () => { const routeNames = extractRouteNames(routes); const enMessages = i18n['en-US']; for (const name of routeNames) { const text = enMessages[name]; assert.ok( text.length <= 15, `菜单项 [${name}] 英文文案 "${text}" 过长 (${text.length} 字符),超过了 15 字符上限,容易在 220px 侧边栏下被截断!` ); } }); test('3. 关键菜单英文必须采用原生简洁的地道 SaaS 表达', () => { const en = i18n['en-US']; // 平台总控必须为 Platform,杜绝 Platform Operations assert.equal(en['menu.platform'], 'Platform'); // 财务统计必须为 Finance,杜绝 Financial & Operations assert.equal(en['menu.dashboard.financial'], 'Finance'); // 全球雷达必须为 Radar Map,杜绝 Global Radar Heatmap assert.equal(en['menu.dashboard.radarMap'], 'Radar Map'); // 术语库必须为 Glossary,杜绝 AI Translation & Glossary assert.equal(en['menu.ai.translation'], 'Glossary'); // 组织成员必须为 Members,杜绝 Members & Structure assert.equal(en['menu.team.members'], 'Members'); // 订阅套餐必须为 Plans,杜绝 Subscription Plans assert.equal(en['menu.platform.subscriptions'], 'Plans'); // 文章动态必须为 Articles,杜绝 Articles & Posts assert.equal(en['menu.card.articles'], 'Articles'); // 案例作品集必须为 Portfolio,杜绝 Case Studies assert.equal(en['menu.card.cases'], 'Portfolio'); // 名片列表必须为 All Cards,杜绝 Card Library assert.equal(en['menu.card.list'], 'All Cards'); // 设备池必须为 Devices,杜绝 Device Pool assert.equal(en['menu.nfc.devices'], 'Devices'); });