A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: the Hebrew Budget, Why? and info panel dates name their months in Hebrew (refs #701) (#834)
Beri4349197a02be
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ee9b3f91a..7e6141bf9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB## [Unreleased]### Fixed+- In the Hebrew UI the Budget's "no ministry until" date, the Why? screen's turn span and the info panel's build date+ name their months in Hebrew ("מ־15 במאי 1948 עד 15 ביוני 1948", "באוגוסט 1950") through the `date.*` strings, as+ the top bar does since #696 (refs #701). English is unchanged. `info.built` in Hebrew now says "ב{1}" instead of+ "בשנת {1}", since its value is a month and a year.- The loading screen's boot-failure line wraps inside the screen with a side margin (refs #765). In Hebrew at phone widthit ran past both edges, so the player could not read "reload the page"; `.loading-line` had no `white-space: normal`.`UiLayoutTests.TheBootFailureLineWrapsInsideTheScreen` checks English and Hebrew at 390x844, 960x600 and 1280x720.diff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.csindex 374cc5cf8..53b9e26f6 100644--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs@@ -139,7 +139,7 @@ namespace Statecraft.Game.UIvar o = c.Offices.First(x => x.Id == (Offices.BudgetOwner(c, office, s.Date) ?? office));var share = draft.TryGetValue(office, out var v) ? v : 0;// A budget line can run before its ministry exists (Education from 10 March 1949): say so, not "vacant".- var who = o.From.HasValue && s.Date < o.From.Value ? text.Format("budget.not_established", PlayerText.Date(o.From.Value))+ var who = o.From.HasValue && s.Date < o.From.Value ? text.Format("budget.not_established", Statecraft.Game.Map.Control1948.DateText(o.From.Value, k => text[k])) // PlayerText.Date is always English (#701): Cabinet.Holder(c, s, o.Id)?.Name ?? text["budget.vacant"];((Label)row[0]).text = text.Format("budget.office", o.Title, who);((Label)row[2]).text = text.Format("budget.share", PlayerText.Percent(share));diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex 1525f6cdb..83d458c7d 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -256,7 +256,8 @@ namespace Statecraft.Game.UIvar here = MapActions.At(s, q, r);var queued = bridge.QueuedLike(new MapAction(MapActions.Housing, q, r)) as MapAction;placement.text = queued != null ? text.Format("info.queued", PlayerText.Capitalised(PlayerText.MapAction(c, queued.Action)))- : here != null ? text.Format("info.built", PlayerText.Capitalised(PlayerText.MapAction(c, here.Action)), PlayerText.Month(here.Date)) : "";+ : here != null ? text.Format("info.built", PlayerText.Capitalised(PlayerText.MapAction(c, here.Action)),+ Control1948.LineDateText(here.Date.ToString("yyyy-MM", System.Globalization.CultureInfo.InvariantCulture), k => text[k])) : ""; // PlayerText.Month is always English (#701)var campWhy = MapActions.Check(c, s, MapActions.TransitCamp, q, r);var housingWhy = MapActions.Check(c, s, MapActions.Housing, q, r);// eras.yaml systems.map_actions (#58): an action the era does not allow has no button and no reasondiff --git a/unity/Assets/Scripts/UI/WhyPresenter.cs b/unity/Assets/Scripts/UI/WhyPresenter.csindex 88ca187dd..30b141615 100644--- a/unity/Assets/Scripts/UI/WhyPresenter.cs+++ b/unity/Assets/Scripts/UI/WhyPresenter.cs@@ -37,7 +37,8 @@ namespace Statecraft.Game.UIvar rows = screen.Q<ScrollView>("why-rows");rows.Clear();var prev = bridge.Session.Previous;- screen.Q<Label>("why-turn").text = last == null || prev == null ? "" : text.Format("why.turn", PlayerText.Date(prev.Date), PlayerText.Date(bridge.State.Date));+ screen.Q<Label>("why-turn").text = last == null || prev == null ? "" : text.Format("why.turn",+ Statecraft.Game.Map.Control1948.DateText(prev.Date, k => text[k]), Statecraft.Game.Map.Control1948.DateText(bridge.State.Date, k => text[k])); // PlayerText.Date is always English (#701)if (last == null) { rows.Add(new Label(text["why.empty"]) { name = "why-empty" }); return; }if (last.Why.Count == 0) { rows.Add(new Label(text["why.nothing"]) { name = "why-nothing" }); return; }int i = 0;diff --git a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs b/unity/Assets/Tests/EditMode/BudgetScreenTests.csindex e6089fd9a..d20e9d01f 100644--- a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs+++ b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs@@ -234,6 +234,16 @@ public class BudgetScreenTestsAssert.IsFalse(Cabinet.Lineup(C, g.State).Any(x => x.Office.Id == "education_minister"));}+ /// <summary>#701: in the Hebrew UI the ministry's start date names its month in Hebrew (date.*).</summary>+ [Test]+ public void InHebrewTheMinistrysStartIsAHebrewDate()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ using var ui = new UiTestKit();+ new BudgetPresenter(ui.Root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), he), he);+ StringAssert.EndsWith("(אין משרד עד 10 במרץ 1949)", ui.Q<Label>("budget-education_minister-name").text);+ }+/// <summary>Playtest 1, item 6: a vacant ministry reads "(vacant)", as on the Cabinet screen, never "(-)".</summary>[Test]public void AVacantMinistryReadsVacant()diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex 9610fa13b..f10dc713b 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -445,8 +445,12 @@ public class HebrewUiTests}Assert.LessOrEqual(list.contentContainer.layout.width, room + 0.5f, $"{language} {width}: the rows scroll sideways");// The control: without the wrapping class the long Hebrew row is wider than the screen at 1920 (so this test can fail).+ // Its own text no longer is since its date turned Hebrew (#701, "10 במרץ 1949" is shorter than "10 March 1949"),+ // so the control triples the longest office name: the class, not one string's width, is what is checked.if (language == UiLanguage.Hebrew && width == 1920){+ var longest = (Label)rows.Select(r => r[0]).OrderByDescending(x => ((Label)x).text.Length).First();+ longest.text = string.Join(" ", Enumerable.Repeat(longest.text, 3));foreach (var row in rows) row[0].RemoveFromClassList("budget-office");for (int i = 0; i < 4; i++) yield return null;Assert.IsTrue(rows.Any(r => r.layout.width > room + 0.5f || r.Children().Any(x => x.layout.xMin < -0.5f || x.layout.xMax > r.layout.width + 0.5f)),diff --git a/unity/Assets/Tests/EditMode/MapActionUiTests.cs b/unity/Assets/Tests/EditMode/MapActionUiTests.csindex 98982024b..da2d3b255 100644--- a/unity/Assets/Tests/EditMode/MapActionUiTests.cs+++ b/unity/Assets/Tests/EditMode/MapActionUiTests.cs@@ -84,6 +84,23 @@ public class MapActionUiTestsAssert.AreEqual("A transit camp built here in August 1950", ui.Q<Label>("info-placement").text);}+ /// <summary>#701: in the Hebrew UI the build date names its month in Hebrew (date.month_year), not "August 1950".</summary>+ [Test]+ public void InHebrewTheBuildDateIsAHebrewMonth()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ while (g.State.Date < new DateTime(1950, 8, 1)) g.Step(HistoricalAI.Commands(C, g.State));+ var bridge = new SimBridge(g, he);+ var info = new InfoPanelPresenter(ui.Root, bridge, he, Towns.ToDictionary(t => t.Id, t => t.Name));+ var tlv = C.SettlementHexes.Single(s => s.Id == "tel_aviv");+ info.Show(tlv.Q, tlv.R);+ ui.Press("build-camp");+ bridge.EndTurn();+ StringAssert.EndsWith("נבנה כאן באוגוסט 1950", ui.Q<Label>("info-placement").text);+ }+/// <summary>The minimap's painted relief (tools/minimap_bake.py) is north up over the hex grid's bounds: sea off Tel Aviv/// and in the Gulf of Aqaba, land in the hills and the Negev. Read from the PNG itself (the imported texture is not/// readable on the CPU).</summary>diff --git a/unity/Assets/Tests/EditMode/WhyScreenTests.cs b/unity/Assets/Tests/EditMode/WhyScreenTests.csindex 29972131f..94e7f0438 100644--- a/unity/Assets/Tests/EditMode/WhyScreenTests.cs+++ b/unity/Assets/Tests/EditMode/WhyScreenTests.cs@@ -166,12 +166,25 @@ public class WhyScreenTests}}+ /// <summary>#701: in the Hebrew UI the turn's span names its months in Hebrew (date.*), not "15 May 1948".</summary>+ [Test]+ public void InHebrewTheTurnsSpanIsAHebrewDate()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ using var ui = new UiTestKit();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), he);+ new WhyPresenter(ui.Root, bridge, he);+ bridge.EndTurn();+ Assert.AreEqual("מ־15 במאי 1948 עד 15 ביוני 1948", ui.Q<Label>("why-turn").text);+ }+/// <summary>Playtest 1, item 4: the effects group covers effects that are not policies too.</summary>[Test]public void TheEffectsGroupIsCalledOngoingEffects() => Assert.AreEqual("Ongoing effects", Text["why.effects"]);- /// <summary>Playtest 1, item 5: every date the player sees goes through Statecraft.Sim.PlayerText ("15 May 1948"),- /// so no UI string carries a date format of its own.</summary>+ /// <summary>Playtest 1, item 5: every date the player sees goes through Statecraft.Sim.PlayerText ("15 May 1948") or,+ /// where the UI's language names the month, through the date.* strings (Control1948.DateText, #687, #701), so no UI+ /// string carries a date format of its own.</summary>[Test]public void NoUiStringFormatsADateItself(){diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 94fa9fb01..c82f23c74 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -1,7 +1,8 @@# UI strings (English). Code looks strings up by key (Statecraft.Game.UI.UiText); placeholders are string.Format# arguments ({0}, {1}) formatted with the invariant culture. Static labels live in the UXML files.-# Most dates arrive already formatted by Statecraft.Sim.PlayerText ("15 May 1948"). The map's front-line date is the-# exception: Control1948.LineDateText builds it from the date.* strings below, so each language orders and names it.+# Most dates arrive already formatted by Statecraft.Sim.PlayerText ("15 May 1948"). The map's front-line date, the top+# bar's date, and the Budget, Why? and info panel dates are the exception: Control1948.DateText / LineDateText build+# them from the date.* strings below, so each language orders and names them (#687, #701).# Money arrives formatted by PlayerText.Money / MoneyChange, its currency from content (model.yaml money): "IL 18.6m",# "$41.5m", "+IL 1.2m". Shares and 0..1 indicators arrive on the 0-100 scale (PlayerText.Scale / Percent) and show "%".hud.turn: "Turn {0}"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 51ab7f682..21fd84562 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -1,7 +1,8 @@# UI strings (Hebrew, #12). GameRoot loads them in place of strings.en.yaml only when Hebrew is asked for by hand# ("?lang=he" on the web, "-lang he" on the desktop; UiLanguage, #193); there is no visible switch yet.# Keep logical Hebrew order, never reverse strings. Exact string.Format tokens match strings.en.yaml;-# dates, money, names and content still arrive from the current English content/PlayerText paths.+# money, names, content and most dates still arrive from the current English content/PlayerText paths; the map's line+# date, the top bar's date and the Budget, Why? and info panel dates come from the date.* strings (#687, #701).hud.turn: "תור {0}"hud.date: "{0}"hud.attention: "תשומת לב {0:0.0} מתוך {1:0.0}"@@ -236,7 +237,8 @@ minimap.overview: "התרחקות מרבית"minimap.labels: "הצגה או הסתרה של שמות היישובים"minimap.borders: "הצגה או הסתרה של גבולות האזורים"ui.lang: "he"-info.built: "{0} נבנה כאן בשנת {1}"+# #701: {1} is a month and a year ("אוגוסט 1950"), so "ב{1}" (באוגוסט 1950), not "בשנת {1}". For the native reviewer (#564).+info.built: "{0} נבנה כאן ב{1}"info.queued: "ניתנה פקודה: {0}, בסיום התור"info.build_camp: "הקמת מעברה ({0})"info.build_housing: "בניית דיור ({0})"