diff --git a/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts b/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts index c639b36..1d906c3 100644 --- a/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts +++ b/plugins/examples/scum-server-plugin/features/scum-catalog-zh.ts @@ -32,6 +32,18 @@ const directNames: Record = { Aspirin: "阿司匹林", Animal_Skin: "动物皮", Air_Pump: "打气筒", + Bundle_Of_Rags_Dirty: "脏布条捆", + Bundle_Of_Safety_Pins: "安全别针捆", + Bundle_Of_Stone_Tips: "石箭头捆", + Bundle_Rag_Stripes: "布条捆", + Bundle_Wooden_Plank: "木板捆", + CementBag: "水泥袋", + Charcoal: "木炭", + Christmas_Tree: "圣诞树", + Coal_01: "煤块", + Copper_Strip: "铜条", + Depleted_Uranium: "贫铀", + Donkey_Head: "驴头", Backpack_02_01: "红色背包", "1H_Cleaver": "菜刀", Water_05l: "水", @@ -82,11 +94,6 @@ const phraseNames: Array = [ [/^(.+) Level (\d+)$/i, "$1 $2 级"] ]; -const catalogKindNames: Record = { item: "物品", vehicle: "载具", animal: "动物", zombie: "丧尸", "armed-npc": "非玩家角色", razor: "其他" }; -const fallbackNameGroups: Array = [ - ["/backpacks/", "背包"], ["/head armor/", "头部装备"], ["/weapons/", "武器"], ["/medicals/", "医疗物品"], ["/food/", "食物"], ["/clothes/", "服装"], ["/vehicles/", "载具部件"], ["/fishing/", "钓鱼用品"], ["/farming/", "农业用品"], ["/crafting/", "制作材料"] -]; - export function scumCatalogNameZh(entry: ScumCatalogEntry): string { const direct = directNames[entry.code]; if (direct) return direct; @@ -105,7 +112,7 @@ export function scumCatalogNameZh(entry: ScumCatalogEntry): string { if (!/[A-Za-z]/.test(translated)) return translated; const translatedCode = compactLabel(translateWords(code)); if (!/[A-Za-z]/.test(translatedCode)) return translatedCode; - return catalogFallbackName(entry); + return compactLabel(source || code); } export function scumCatalogDisplayName(entry: ScumCatalogEntry): string { return scumCatalogNameZh(entry); } @@ -131,12 +138,4 @@ function translateWords(value: string): string { return spaced.replace(/[A-Za-z][A-Za-z'-]*/g, (word) => additionalWordNames[word.toLowerCase()] ?? wordNames[word.toLowerCase()] ?? word); } -function catalogFallbackName(entry: ScumCatalogEntry): string { - const icon = entry.icon.toLowerCase(); - const group = fallbackNameGroups.find(([needle]) => icon.includes(needle)); - const prefix = group?.[1] ?? catalogKindNames[entry.kind] ?? "物品"; - const serial = entry.code.match(/\d+/g)?.join("-"); - return serial ? prefix + " " + serial : prefix + "条目"; -} - function compactLabel(value: string): string { return value.replace(/\s+/g, " ").trim(); } diff --git a/plugins/tests/scum-feature-module.test.ts b/plugins/tests/scum-feature-module.test.ts index 23bbd0c..5a5e933 100644 --- a/plugins/tests/scum-feature-module.test.ts +++ b/plugins/tests/scum-feature-module.test.ts @@ -352,6 +352,25 @@ describe("SCUM plugin feature module", () => { expect(scumCatalogDisplayName(aloe)).toBe("芦荟"); expect(scumCatalogDisplayName(vehicle)).toBe("莱卡"); expect(scumCatalogDisplayName(militaryBackpack)).toBe("军用背包 黑色"); + const correctedNames: Record = { + Bundle_Of_Rags_Dirty: "脏布条捆", + Bundle_Of_Safety_Pins: "安全别针捆", + Bundle_Of_Stone_Tips: "石箭头捆", + Bundle_Rag_Stripes: "布条捆", + Bundle_Wooden_Plank: "木板捆", + CementBag: "水泥袋", + Charcoal: "木炭", + Christmas_Tree: "圣诞树", + Coal_01: "煤块", + Copper_Strip: "铜条", + Depleted_Uranium: "贫铀", + Donkey_Head: "驴头" + }; + for (const [code, name] of Object.entries(correctedNames)) { + expect(scumCatalogDisplayName(scumCatalogEntries.find((item) => item.code === code)!)).toBe(name); + } + const untranslated = scumCatalogEntries.find((item) => item.code === "Agaricus_Augustus")!; + expect(scumCatalogDisplayName(untranslated)).toBe("Agaricus Augustus"); expect(scumCatalogSearchText(aloe)).toContain("芦荟"); expect(scumCatalogSearchText(bigBackpack)).toContain("大背包"); expect(scumCatalogSearchText(militaryHelmet)).toContain("军用头盔");