From c64779031d8459c44d78916ab6e38e80d2532a1c Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Sun, 20 Sep 2026 21:38:46 +0800 Subject: feat(desktop): localize village presentation labels [Change Nature] - This commit adds the Chinese display layer for the desktop village prototype. [New Capability] - Menu, settings, controls, interaction panels, chronicle entries, trade results, day-night labels, and speed labels now use Chinese copy. [Implementation] - Keep simulation state, commands, and machine-readable status strings unchanged. - Add focused formatter coverage and update affected presentation assertions. [Impact] - Desktop presentation behavior is localized without changing Kernel or simulation logic. - Existing release build and test coverage remain green. --- src/LivingVillage.Desktop.Tests/DesktopTests.fs | 2 +- src/LivingVillage.Desktop.Tests/M6aTests.fs | 8 +-- src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 76 +++++++++++++++++++++++ 3 files changed, 81 insertions(+), 5 deletions(-) (limited to 'src/LivingVillage.Desktop.Tests') diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs index 650f757..1c175ce 100644 --- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs +++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs @@ -22,7 +22,7 @@ type DesktopTests () = Assert.AreEqual(world, next) Assert.AreEqual(DialoguePanel, view.Panel) Assert.AreEqual(6, view.Menu.Value.Options.Length) - Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("SMALLTALK")) + Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("闲聊")) [] member _.SelectingAnIntentUpdatesWorldAndChronicle () = diff --git a/src/LivingVillage.Desktop.Tests/M6aTests.fs b/src/LivingVillage.Desktop.Tests/M6aTests.fs index 1cc29d4..04920d4 100644 --- a/src/LivingVillage.Desktop.Tests/M6aTests.fs +++ b/src/LivingVillage.Desktop.Tests/M6aTests.fs @@ -9,7 +9,7 @@ type M6aDesktopTests () = [] member _.SpeedLabelsExposePauseAndThreeRunningModes () = - Assert.AreEqual("PAUSED", M6Presentation.clockLabel { Paused = true; Speed = OneX }) - Assert.AreEqual("1X", M6Presentation.clockLabel { Paused = false; Speed = OneX }) - Assert.AreEqual("2X", M6Presentation.clockLabel { Paused = false; Speed = TwoX }) - Assert.AreEqual("5X", M6Presentation.clockLabel { Paused = false; Speed = FiveX }) + Assert.AreEqual("暂停", M6Presentation.clockLabel { Paused = true; Speed = OneX }) + Assert.AreEqual("1倍速", M6Presentation.clockLabel { Paused = false; Speed = OneX }) + Assert.AreEqual("2倍速", M6Presentation.clockLabel { Paused = false; Speed = TwoX }) + Assert.AreEqual("5倍速", M6Presentation.clockLabel { Paused = false; Speed = FiveX }) diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index b959d70..3abb064 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -1,7 +1,10 @@ namespace LivingVillage.Desktop.Tests +open System open Microsoft.VisualStudio.TestTools.UnitTesting +open LivingVillage.Kernel open LivingVillage.Kernel.Sim +open LivingVillage.Desktop open LivingVillage.Desktop.VillagePresentation [] @@ -100,3 +103,76 @@ type PrototypeTests () = Assert.AreEqual("需求", stageOneCopy.Needs) Assert.AreEqual("交易", stageOneCopy.Trade) Assert.AreEqual("进入民居", stageOneCopy.EnterHome) + + [] + member _.MenuControlsAndSettingsUseChineseDisplayCopy () = + let state = MenuState.create SimulationControl.initial false + let itemLabels = MenuState.items state |> List.map MenuState.itemLabel + let controlLabels = MenuState.controlRows |> List.map (fun row -> row.Action) + let settingsLabels = MenuState.settings |> List.map MenuState.settingsLabel + + Assert.IsTrue(itemLabels |> List.contains "开始新游戏") + Assert.IsTrue(itemLabels |> List.contains "读取存档") + Assert.IsTrue(itemLabels |> List.contains "设置") + Assert.IsTrue(itemLabels |> List.contains "退出") + Assert.AreEqual( + [ "移动" + "互动" + "对话" + "观察" + "需求" + "年鉴" + "关系" + "暂停" + "速度" + "保存" + "读取" + "菜单或关闭" + "选择" + "确认" ], + controlLabels) + Assert.AreEqual([ "1倍速"; "2倍速"; "5倍速"; "暂停" ], settingsLabels) + + [] + member _.InteractionPanelsUseChineseLabelsAndExplicitTradeResults () = + let world = Sim.initialWorldN 42UL 4 + let nearby = + { world with + Avatar = { world.Avatar with Pos = world.Npcs.[0].Pos } } + let openedWorld, opened = M5Interaction.apply Interact nearby M5Interaction.initial + let title = M5Interaction.titleText opened + let needsWorld, needsView = M5Interaction.apply ToggleNeeds openedWorld opened + let needsText = String.concat "|" (M5Interaction.panelLines needsWorld needsView) + let _, chronicleView = M5Interaction.apply ShowChronicle nearby M5Interaction.initial + let chronicleText = String.concat "|" (M5Interaction.panelLines nearby chronicleView) + let request = + { Buyer = NpcId 0 + Seller = NpcId 1 + Item = Food + Quantity = 1 } + let quote = Sim.quotePrice request nearby + let successText = M5Interaction.tradeResultText request quote (Sim.trade request nearby) + let failureRequest = { request with Quantity = 0 } + let failureText = + M5Interaction.tradeResultText failureRequest (Sim.quotePrice failureRequest nearby) (Sim.trade failureRequest nearby) + + Assert.IsTrue(title.Contains("互动")) + Assert.IsTrue(title.Contains("闲聊")) + Assert.IsFalse(title.Contains("SMALLTALK")) + Assert.IsTrue(needsText.Contains("需求")) + Assert.IsTrue(needsText.Contains("饥饿")) + Assert.IsTrue(chronicleText.Contains("年鉴")) + Assert.IsTrue(chronicleText.Contains("暂无记录")) + Assert.IsTrue(successText.Contains("交易成功")) + Assert.IsTrue(successText.Contains("报价")) + Assert.IsTrue(failureText.Contains("交易失败")) + Assert.IsTrue(failureText.Contains("数量")) + + [] + member _.DayNightAndSpeedUseChineseDisplayCopy () = + Assert.AreEqual("白天", M6Presentation.dayNightLabel Day) + Assert.AreEqual("夜晚", M6Presentation.dayNightLabel Night) + Assert.AreEqual("暂停", M6Presentation.clockLabel { Paused = true; Speed = OneX }) + Assert.AreEqual("1倍速", M6Presentation.clockLabel { Paused = false; Speed = OneX }) + Assert.AreEqual("2倍速", M6Presentation.clockLabel { Paused = false; Speed = TwoX }) + Assert.AreEqual("5倍速", M6Presentation.clockLabel { Paused = false; Speed = FiveX }) -- cgit v1.2.3