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

70 lines
3.0 KiB
TypeScript

export type DataSyncEntryMode = 'sync' | 'schemaCompare' | 'dataCompare';
export type DataSyncEntryModePresentation = {
title: string;
description: string;
heroTitle: string;
heroDescription: string;
optionTitle: string;
tableSelectLabel: string;
analyzeButtonText: string;
closeButtonText: string;
badgeText: string;
resultTitle: string;
readOnly: boolean;
};
type DataSyncEntryModeTranslator = (key: string) => string;
const text = (key: string, t?: DataSyncEntryModeTranslator) => (t ? t(key) : key);
export const resolveDataSyncEntryModePresentation = (
entryMode: DataSyncEntryMode,
t?: DataSyncEntryModeTranslator,
): DataSyncEntryModePresentation => {
switch (entryMode) {
case 'schemaCompare':
return {
title: text('data_sync.entry_mode.schema_compare.title', t),
description: text('data_sync.entry_mode.schema_compare.description', t),
heroTitle: text('data_sync.entry_mode.schema_compare.title', t),
heroDescription: text('data_sync.entry_mode.schema_compare.hero_description', t),
optionTitle: text('data_sync.entry_mode.compare.option_title', t),
tableSelectLabel: text('data_sync.entry_mode.schema_compare.table_select_label', t),
analyzeButtonText: text('data_sync.entry_mode.compare.action.start', t),
closeButtonText: text('data_sync.action.close', t),
badgeText: text('data_sync.entry_mode.schema_compare.badge', t),
resultTitle: text('data_sync.entry_mode.compare.result_title', t),
readOnly: true,
};
case 'dataCompare':
return {
title: text('data_sync.entry_mode.data_compare.title', t),
description: text('data_sync.entry_mode.data_compare.description', t),
heroTitle: text('data_sync.entry_mode.data_compare.title', t),
heroDescription: text('data_sync.entry_mode.data_compare.hero_description', t),
optionTitle: text('data_sync.entry_mode.compare.option_title', t),
tableSelectLabel: text('data_sync.entry_mode.data_compare.table_select_label', t),
analyzeButtonText: text('data_sync.entry_mode.compare.action.start', t),
closeButtonText: text('data_sync.action.close', t),
badgeText: text('data_sync.entry_mode.data_compare.badge', t),
resultTitle: text('data_sync.entry_mode.compare.result_title', t),
readOnly: true,
};
default:
return {
title: text('data_sync.title.sync_workbench', t),
description: text('data_sync.title.sync_description', t),
heroTitle: text('data_sync.title.sync', t),
heroDescription: text('data_sync.entry_mode.sync.hero_description', t),
optionTitle: text('data_sync.title.sync_options', t),
tableSelectLabel: text('data_sync.help.select_tables', t),
analyzeButtonText: text('data_sync.action.analyze_diff', t),
closeButtonText: text('data_sync.action.close', t),
badgeText: text('data_sync.badge.sync_mode', t),
resultTitle: text('data_sync.step.result', t),
readOnly: false,
};
}
};