Files
MyGoNavi/frontend/src/components/QueryEditorToolbar.i18n.test.ts
tianqijiuyun-latiao 9364c48ef0 feat(i18n): 完善多模块多语言适配与发版验证
扩展前后端多语言文案与共享词典。增加多模块 i18n 回归测试与 guard。收口外部 SQL 菜单和弹窗多语言文案。
2026-06-17 13:17:33 +08:00

73 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const source = readFileSync(new URL('./QueryEditorToolbar.tsx', import.meta.url), 'utf8');
const legacyLiterals = [
'隐藏结果区',
'显示结果区',
'生成 SQL',
'解释 SQL',
'优化 SQL',
'Schema 分析',
'选择连接',
'选择数据库',
'最大返回行数',
'最大行数500',
'最大行数1000',
'最大行数5000',
'最大行数20000',
'最大行数:不限',
'运行',
'停止',
'保存',
'更多',
'美化 SQL',
'美化',
'结果',
];
const requiredKeys = [
'query_editor.placeholder.connection',
'query_editor.placeholder.database',
'query_editor.max_rows.tooltip',
'query_editor.max_rows.option_500',
'query_editor.max_rows.option_1000',
'query_editor.max_rows.option_5000',
'query_editor.max_rows.option_20000',
'query_editor.max_rows.option_unlimited',
'query_editor.action.run',
'query_editor.action.run_with_shortcut',
'query_editor.action.stop',
'query_editor.action.save',
'query_editor.action.save_with_shortcut',
'query_editor.action.more',
'query_editor.action.format',
'query_editor.action.format_sql',
'query_editor.action.ai_generate_sql_menu',
'query_editor.action.ai_explain_sql_menu',
'query_editor.action.ai_optimize_sql_menu',
'query_editor.action.ai_schema_analysis',
'query_editor.action.show_results_panel',
'query_editor.action.hide_results_panel',
'query_editor.action.show_results_panel_with_shortcut',
'query_editor.action.hide_results_panel_with_shortcut',
'query_editor.action.results',
];
describe('QueryEditorToolbar i18n', () => {
it('uses localized keys for toolbar chrome', () => {
expect(source).toContain("import { useOptionalI18n } from '../i18n/provider';");
expect(source).toContain('const i18n = useOptionalI18n();');
expect(source).toContain('const t = i18n?.t ?? defaultTranslate;');
for (const key of requiredKeys) {
expect(source).toContain(key);
}
for (const literal of legacyLiterals) {
expect(source).not.toContain(literal);
}
});
});