mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-23 05:37:11 +08:00
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const source = readFileSync(new URL('./Sidebar.tsx', import.meta.url), 'utf8');
|
|
|
|
const locales = ['zh-CN', 'zh-TW', 'en-US', 'ja-JP', 'de-DE', 'ru-RU'] as const;
|
|
const requiredKeys = [
|
|
'sidebar.tree.default_schema',
|
|
'sidebar.object_group.tables',
|
|
'sidebar.object_group.views',
|
|
'sidebar.object_group.materialized_views',
|
|
'sidebar.object_group.routines',
|
|
'sidebar.object_group.triggers',
|
|
'sidebar.object_group.events',
|
|
];
|
|
|
|
describe('Sidebar object group i18n', () => {
|
|
it('localizes database object group titles and default schema fallback', () => {
|
|
[
|
|
"const schemaTitle = bucket.schemaName || '默认模式'",
|
|
"buildObjectGroup(schemaNodeKey, 'tables', '表'",
|
|
"buildObjectGroup(schemaNodeKey, 'views', '视图'",
|
|
"buildObjectGroup(schemaNodeKey, 'materializedViews', '物化视图'",
|
|
"buildObjectGroup(schemaNodeKey, 'routines', '函数'",
|
|
"buildObjectGroup(schemaNodeKey, 'triggers', '触发器'",
|
|
"buildObjectGroup(schemaNodeKey, 'events', '事件'",
|
|
"buildObjectGroup(key as string, 'tables', '表'",
|
|
"buildObjectGroup(key as string, 'views', '视图'",
|
|
"buildObjectGroup(key as string, 'materializedViews', '物化视图'",
|
|
"buildObjectGroup(key as string, 'routines', '函数'",
|
|
"buildObjectGroup(key as string, 'triggers', '触发器'",
|
|
"buildObjectGroup(key as string, 'events', '事件'",
|
|
].forEach((snippet) => {
|
|
expect(source).not.toContain(snippet);
|
|
});
|
|
|
|
requiredKeys.forEach((key) => {
|
|
expect(source).toContain(`t('${key}'`);
|
|
});
|
|
});
|
|
|
|
it('keeps database object group 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();
|
|
});
|
|
});
|
|
});
|
|
});
|