feat(history): track translation and config changes in edit history

Record localized field updates across all translatable entities.
Track sort order modifications and specific config properties.
Support parsing and translating localized field labels in the UI.
This commit is contained in:
2026-05-03 19:09:49 +08:00
parent d80c9325cd
commit fcb9b57aa3
2 changed files with 174 additions and 28 deletions

View File

@@ -12,6 +12,8 @@ const changeLabelKeys: Record<string, string> = {
Name: 'common.name',
名字: 'common.name',
名称: 'common.name',
Title: 'pages.checklist.task',
标题: 'pages.checklist.task',
'Pokemon ID': 'pages.pokemon.id',
'Event item': 'common.eventItem',
Genus: 'pages.pokemon.genus',
@@ -62,7 +64,16 @@ const changeLabelKeys: Record<string, string> = {
Item: 'pages.recipes.item',
物品: 'pages.recipes.item',
Materials: 'pages.recipes.materials',
需要材料: 'pages.recipes.materials'
需要材料: 'pages.recipes.materials',
'Sort order': 'pages.admin.sortOrder',
排序: 'pages.admin.sortOrder',
'Has item drop': 'pages.admin.hasItemDrop',
有掉落物: 'pages.admin.hasItemDrop',
'Default category': 'pages.admin.defaultCategory',
默认分类: 'pages.admin.defaultCategory',
Rateable: 'pages.admin.rateableCategory',
可评分: 'pages.admin.rateableCategory',
ChangeLog: 'pages.admin.changeLog'
};
function displayName(user: UserSummary | null): string {
@@ -78,6 +89,14 @@ function actionMark(action: EditHistoryAction): string {
}
function changeLabel(label: string): string {
const localizedFieldMatch = label.match(/^(.+) \(([^()]+)\)$/);
if (localizedFieldMatch) {
const [, fieldLabel, languageCode] = localizedFieldMatch;
if (fieldLabel && languageCode) {
return `${changeLabel(fieldLabel)} (${languageCode})`;
}
}
const key = changeLabelKeys[label];
return key ? t(key) : label;
}