A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
ui: Hebrew for the static Game.uxml texts, the seat unit by body, the agreed wordings (refs #193) (#550)
Eyal Golan89a73e0992c2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7b151e530..98156f427 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -61,6 +61,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBbars, the hemicycle, the option signs and End Turn's hourglass. English stays the default and has no visible switch.A long Budget office name now wraps in its column, so no row is wider than the screen.- Map: boats and a calmer open sea (refs #388). Promo 03's white-sailed boats: 10 sailing boats off Jaffa, Tel Aviv, Bat Yam, Haifa, Acre and Gaza, and 7 craft moored in or off the harbours of Jaffa, Tel Aviv and Haifa (a small coastal steamer at anchor off Haifa), kept off the breakwaters and moles. Jaffa's 5 stub-sail hulls are gone and its houses are unchanged. At the gameplay zoom the open sea calms far from the shore (edge density 0.048 to 0.020; promo 0.012) and keeps broad light and dark swells, and #402's surf, shallows and near-coast chop are unchanged. At the overview a lighter teal shelf runs along the coast and tints the shallows' outer edge a little. The effects follow the camera's distance, not the pixel size, under a new `seacalm` toggle. Presentation only: no golden moves.+- The Hebrew UI preview translates the texts `Game.uxml` wrote in English (refs #193): the top bar's captions (the same+ words as their tooltips), screen buttons, New Game and End Turn; the screen titles; the Budget and Defence buttons; the+ draft mark; the loading line; and the start screen's source line, recording credit and buttons. The game's name and the+ Declaration's official English stay as they are. A seat count says "חברים" for the appointed Provisional State Council+ and "מנדטים" for the Knesset. "כישורים" for competence and "המצב הביטחוני" for the ladder. English is unchanged.- Decision videos, phase 2 (#434 follow-up). On 11 decision cards an Illustration switch over the photograph plays ashort, silent AI-generated loop. It is labelled "AI-generated illustration" in place of the credit and carries a smallburned-in bilingual label. The photograph always shows first; nothing plays until the player asks, and the choice holdsdiff --git a/tools/tests/test_hebrew_ui.py b/tools/tests/test_hebrew_ui.pyindex 425b912a3..8166cd324 100644--- a/tools/tests/test_hebrew_ui.py+++ b/tools/tests/test_hebrew_ui.py@@ -41,7 +41,12 @@ def test_hebrew_is_not_enabled_without_runtime_review():def test_hebrew_review_wording_is_count_neutral_and_uses_knesset_terms():he = strings('strings.he.yaml')assert he['event.more'] == 'החלטות ממתינות נוספות: {0}'- assert 'מנדטים' in he['budget.vote_needed']- assert 'מנדטים' in he['cabinet.coalition']+ # A seat count's unit is its own string, by the body (CabinetPresenter.SeatUnit): the Knesset's seats are+ # "מנדטים", the appointed Provisional State Council's members "חברים"; no template hard-codes either.+ assert he['cabinet.seats'] == 'מנדטים'+ assert he['cabinet.seats_appointed'] == 'חברים'+ for key in ('budget.vote_needed', 'budget.vote_advisory', 'cabinet.coalition', 'cabinet.opposition',+ 'cabinet.majority', 'cabinet.largest'):+ assert 'מנדטים' not in he[key] and 'חברים' not in he[key], keyassert he['order.no_attention'] == 'אין מספיק תשומת לב (נדרש {0:0.0}, יש {1:0.0})'assert he['defence.rung5'] == '5 מלחמה כוללת'diff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.csindex 996dde850..374cc5cf8 100644--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs@@ -22,6 +22,8 @@ namespace Statecraft.Game.UI{screen = root.Q<VisualElement>("screen-budget"); this.bridge = bridge; this.text = text;reset = screen.Q<Button>("budget-reset"); submit = screen.Q<Button>("budget-submit");+ screen.Q<Label>("budget-screen-title").text = text["budget.title"];+ reset.text = text["budget.reset"]; submit.text = text["budget.submit"];reset.clicked += Reset; submit.clicked += Submit;session = bridge.Session;draft = Current();@@ -148,7 +150,7 @@ namespace Statecraft.Game.UI// eras.yaml systems.legislature: an assembly's vote is held but does not bind (#58)var advisory = c.SystemsAt(s.Date).Legislature == EraSystems.Assembly;screen.Q<Label>("budget-vote").text = leg == null ? "" : !leg.BudgetApproval ? text.Format("budget.no_vote", leg.Body)- : text.Format(advisory ? "budget.vote_advisory" : "budget.vote_needed", leg.Body, seats, size);+ : text.Format(advisory ? "budget.vote_advisory" : "budget.vote_needed", leg.Body, seats, size, CabinetPresenter.SeatUnit(text, leg));screen.Q<Label>("budget-money").text = text.Format("budget.money", PlayerText.Money(c, "treasury", s.Treasury), PlayerText.Money(c, "debt", s.Debt), PlayerText.Money(c, "fx_reserves", s.FxReserves));var flows = EconomySystem.Flows(c, s, 1.0); // the sim's own arithmetic, for a yearscreen.Q<Label>("budget-flow").text = text.Format("budget.flow", PlayerText.Money(c, "treasury", flows.Tax), PlayerText.Money(c, "treasury", flows.Spending), PlayerText.Money(c, "treasury", flows.Mobilization));diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.csindex 41b4dca28..dd7ac05a4 100644--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs@@ -105,6 +105,13 @@ namespace Statecraft.Game.UIreturn blocks;}+ /// <summary>The unit of a seat count in <paramref name="leg"/>: cabinet.seats for an elected body (legislatures.yaml gives+ /// its election date, Legislature.Elected), cabinet.seats_appointed for one that was not elected (the Provisional+ /// State Council). The same "seats" in English; Hebrew says "מנדטים" for the Knesset and "חברים" for the council (#193).+ /// No legislature (no count is shown then) counts as elected.</summary>+ public static string SeatUnit(UiText text, Legislature? leg) =>+ text[leg == null || leg.Elected.HasValue ? "cabinet.seats" : "cabinet.seats_appointed"];+public void Render(){dirty = false; Renders++;@@ -267,16 +274,17 @@ namespace Statecraft.Game.UIvoid RenderHouse(Content c, GameState s, Government? gov, Legislature? leg, int seats, int size){screen.Q<VisualElement>("cabinet-house").style.display = leg == null ? DisplayStyle.None : DisplayStyle.Flex;- screen.Q<Label>("cabinet-coalition").text = text.Format("cabinet.coalition", seats, size, PlayerText.Percent(s.CoalitionStability));+ var unit = SeatUnit(text, leg);+ screen.Q<Label>("cabinet-coalition").text = text.Format("cabinet.coalition", seats, size, PlayerText.Percent(s.CoalitionStability), unit);screen.Q<UiBar>("cabinet-stability").Value = (float)s.CoalitionStability;if (leg == null) { hemicycle.Set(new Hemicycle.Group[0], 0); chips.Clear(); chipsFor = ""; return; }var blocks = Blocks(c, leg, gov, s.Date);hemicycle.Set(blocks, leg.Size);screen.Q<Label>("cabinet-house-size").text = leg.Size.ToString(System.Globalization.CultureInfo.InvariantCulture);- screen.Q<Label>("cabinet-opposition").text = text.Format("cabinet.opposition", blocks.Where(b => !b.Coalition).Sum(b => b.Seats));- screen.Q<Label>("cabinet-majority").text = text.Format("cabinet.majority", hemicycle.Majority);+ screen.Q<Label>("cabinet-opposition").text = text.Format("cabinet.opposition", blocks.Where(b => !b.Coalition).Sum(b => b.Seats), unit);+ screen.Q<Label>("cabinet-majority").text = text.Format("cabinet.majority", hemicycle.Majority, unit);var largest = blocks.OrderByDescending(b => b.Seats).FirstOrDefault();- screen.Q<Label>("cabinet-largest").text = largest.Seats > 0 ? text.Format("cabinet.largest", c.Parties.First(p => p.Id == largest.Party).Name, largest.Seats) : "";+ screen.Q<Label>("cabinet-largest").text = largest.Seats > 0 ? text.Format("cabinet.largest", c.Parties.First(p => p.Id == largest.Party).Name, largest.Seats, unit) : "";var key = leg.Id + "/" + (gov?.Id ?? "");if (key == chipsFor) return;chipsFor = key;diff --git a/unity/Assets/Scripts/UI/DeclarationRecording.cs b/unity/Assets/Scripts/UI/DeclarationRecording.csindex c318aef51..69b21529b 100644--- a/unity/Assets/Scripts/UI/DeclarationRecording.cs+++ b/unity/Assets/Scripts/UI/DeclarationRecording.cs@@ -80,6 +80,7 @@ namespace Statecraft.Game.UIbutton = root.Q<Button>("start-listen");caption = root.Q<VisualElement>("start-caption");button.text = text["start.listen"];+ row.Q<Label>("start-recording-credit").text = text["start.recording_credit"];onPress = Toggle;button.clicked += onPress;row.style.display = DisplayStyle.Flex;diff --git a/unity/Assets/Scripts/UI/DefencePresenter.cs b/unity/Assets/Scripts/UI/DefencePresenter.csindex daf7f8d09..652b5f17e 100644--- a/unity/Assets/Scripts/UI/DefencePresenter.cs+++ b/unity/Assets/Scripts/UI/DefencePresenter.cs@@ -34,6 +34,8 @@ namespace Statecraft.Game.UIonMobUp = () => Mobilize(+MobilizationStep); onMobDown = () => Mobilize(-MobilizationStep);escalate.clicked += onEscalate; deEscalate.clicked += onDeEscalate; mobUp.clicked += onMobUp; mobDown.clicked += onMobDown;foreach (var (name, key) in Sections) screen.Q<Label>(name).text = text[key].ToUpperInvariant(); // the promo's capitals; a caseless script is unchanged+ screen.Q<Label>("defence-screen-title").text = text["defence.title"];+ deEscalate.text = text["defence.lower"]; escalate.text = text["defence.raise"];bridge.Changed += OnChanged;ScreenNav.OnOpened(screen, () => { if (dirty) Render(); });Render();diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.csindex 3a4fc25a3..4d6798110 100644--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs@@ -72,6 +72,7 @@ namespace Statecraft.Game.UIlayer = card.parent; hudRoot = root.Q("root") ?? root;hide = card.Q<Button>("event-hide"); reopen = layer.Q<Button>("event-reopen");hide.text = text["event.hide"]; reopen.text = text["event.reopen"];+ card.Q<Label>("event-draft").text = text["event.draft"];onHide = Collapse; onReopen = Reopen;onUncovered = () => { focusedFor = null; if (Shown != null && !Collapsed) FocusCard(Shown.Id, force: true); };onHidePointer = _ => hideByPointer = true;diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex b125f61d5..d87e6b66b 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -73,13 +73,47 @@ namespace Statecraft.Game.UIvoid OnEnable() { if (boot != null) { boot.Ready += Begin; boot.Failed += OnBootFailed; } }+ /// <summary>The loading line in the UI's language from the first frame (Start runs after every OnEnable, so the+ /// document's tree exists).</summary>+ void Start() { if (Application.isPlaying) Started(); }++ /// <summary>Start's work: the loading line in the UI's language (ShowLoading), unless the boot has already failed or+ /// the game has already begun. GameBoot and GameRoot set no execution order, and on the desktop the load reads from+ /// disk, so a failure can land inside GameBoot.Start before this runs: its reason must stay (M3 final review I5).</summary>+ internal void Started()+ {+ if ((boot == null || boot.Error == null) && Bridge == null) ShowLoading();+ }+/// <summary>A boot failure replaces the loading line with the reason; the loading state stays, so no half-built panel/// shows (M3 final review I5).</summary>internal void OnBootFailed(string reason){- if (document == null || strings == null || stringsHe == null) return;- var line = document.rootVisualElement.Q<Label>("loading");- if (line != null) line.text = Strings().Format("boot.failed", GameBoot.ForPlayer(reason).TrimEnd('.'));+ var text = ShowLoading();+ var line = text == null ? null : document.rootVisualElement.Q<Label>("loading");+ if (line != null) Say(line, text!.Format("boot.failed", GameBoot.ForPlayer(reason).TrimEnd('.')), text["ui.lang"] == UiLanguage.Hebrew);+ }++ /// <summary>Puts the loading line in the UI's language (boot.loading, #193). In Hebrew the root also gets its mark+ /// (UiLanguage.HebrewClass) now, before Begin, so the line and a boot failure are set in the Hebrew face. Returns+ /// the strings, or null before the scene's fields are set.</summary>+ internal UiText? ShowLoading()+ {+ if (document == null || strings == null || stringsHe == null || document.rootVisualElement == null) return null;+ var text = Strings();+ var root = document.rootVisualElement;+ bool hebrew = text["ui.lang"] == UiLanguage.Hebrew;+ (root.Q("root") ?? root).EnableInClassList(UiLanguage.HebrewClass, hebrew);+ var line = root.Q<Label>("loading");+ if (line != null) Say(line, text["boot.loading"], hebrew);+ return text;+ }++ /// <summary>A loading-line text, with its own direction in Hebrew (UiDirection is not running yet) and none in English.</summary>+ static void Say(Label line, string words, bool hebrew)+ {+ line.text = words;+ line.languageDirection = !hebrew ? LanguageDirection.Inherit : UiDirection.RightToLeft(words) ? LanguageDirection.RTL : LanguageDirection.LTR;}/// <summary>The strings of the UI's language (UiLanguage): strings.he.yaml when Hebrew is asked for, else English.</summary>@@ -149,6 +183,8 @@ namespace Statecraft.Game.UI// Hebrew: the Hebrew face, the advanced text generator and the mirrored rows (.lang-he); each text's paragraph// direction comes from its own text (UiDirection, made below once the presenters have rendered).(root.Q("root") ?? root).EnableInClassList(UiLanguage.HebrewClass, hebrew); // on .root, whose face it replaces+ var loading = root.Q<Label>("loading");+ if (loading != null) Say(loading, text["boot.loading"], hebrew); // hidden from here on; set for a restart in the other language// The toast first: the autosave (below) must report a failed write after the toast has shown the turn's refusals.var toast = Own(new ToastPresenter(root, bridge, text));@@ -271,7 +307,7 @@ namespace Statecraft.Game.UI{var cam = cameraController;var recording = Own(new DeclarationRecording(root, text, toast.Show)); // never built in automated runs (Skipped)- start = Own(new StartScreenPresenter(root, newGame, resumed, shown => { if (cam != null) cam.enabled = !shown; }, recording));+ start = Own(new StartScreenPresenter(root, newGame, resumed, shown => { if (cam != null) cam.enabled = !shown; }, recording, text));start.Show();}if (hebrew) Own(new UiDirection(root, bridge));diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.csindex d8e854e8b..cd2dcfe2b 100644--- a/unity/Assets/Scripts/UI/HudPresenter.cs+++ b/unity/Assets/Scripts/UI/HudPresenter.cs@@ -54,6 +54,14 @@ namespace Statecraft.Game.UI/// each wrapped caption back to its one-line width (<paramref name="captionGrowth"/>).</summary>public static float RoomyGrowth(float valueWidths, float captionGrowth = 0f) => 6 * 8f + 0.14f * valueWidths + captionGrowth;+ /// <summary>The top bar's static texts and their strings (#193): the screen buttons, New Game and End Turn. The+ /// meters' captions are hud.caption.*, the same words their tooltips say.</summary>+ static readonly (string name, string key)[] Texts =+ {+ ("nav-cabinet", "hud.nav.cabinet"), ("nav-budget", "hud.nav.budget"), ("nav-defence", "hud.nav.defence"),+ ("nav-why", "hud.nav.why"), ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),+ };+public HudPresenter(VisualElement root, SimBridge bridge, UiText text){this.root = root; this.bridge = bridge; this.text = text;@@ -67,8 +75,13 @@ namespace Statecraft.Game.UImeters = root.Q<VisualElement>("meters").Children().ToList();nav = root.Q<VisualElement>("nav");foreach (var m in meters) m.RegisterCallback<GeometryChangedEvent>(OnMeterGeometry);+ foreach (var (name, key) in Texts) root.Q<TextElement>(name).text = text[key];foreach (var id in new[] { "treasury", "immigration", "security", "support", "standing", "fx" })- said[id] = (root.Q<VisualElement>("meter-" + id), text["hud.caption." + id]);+ {+ var meter = root.Q<VisualElement>("meter-" + id); var caption = text["hud.caption." + id];+ meter.Q<Label>(className: "meter-name").text = caption; // the bar shows the words its tooltip says+ said[id] = (meter, caption);+ }SetCompact(bar.layout.width); // the bar may already be laid out (the loading screen shows it) and never resizebridge.Changed += Render;Render();diff --git a/unity/Assets/Scripts/UI/StartScreenPresenter.cs b/unity/Assets/Scripts/UI/StartScreenPresenter.csindex d3d609a6c..6d388142c 100644--- a/unity/Assets/Scripts/UI/StartScreenPresenter.cs+++ b/unity/Assets/Scripts/UI/StartScreenPresenter.cs@@ -59,8 +59,11 @@ namespace Statecraft.Game.UI/// <param name="recording">The "Play the recording" button's player (null in tests that do not need it); the screen/// stops it when it closes.</param>+ /// <param name="text">The UI's strings for the source line and the two buttons (#193); null keeps Game.uxml's English+ /// (tests). The title is the game's name and the English lines are the Declaration's official translation: neither+ /// is translated.</param>public StartScreenPresenter(VisualElement root, NewGamePresenter newGame, bool resumed, Action<bool>? shownChanged = null,- DeclarationRecording? recording = null)+ DeclarationRecording? recording = null, UiText? text = null){this.recording = recording;this.newGame = newGame; this.shownChanged = shownChanged; Resumed = resumed;@@ -71,6 +74,11 @@ namespace Statecraft.Game.UIpanel = screen.Q<VisualElement>("start-panel");continueButton = screen.Q<Button>("start-continue");newGameButton = screen.Q<Button>("start-new-game");+ if (text != null)+ {+ screen.Q<Label>("start-source").text = text["start.source"];+ continueButton.text = text["start.continue"]; newGameButton.text = text["start.new_game"];+ }onContinue = Continue; onNewGame = NewGame; onStarted = Started;continueButton.clicked += onContinue;newGameButton.clicked += onNewGame;diff --git a/unity/Assets/Scripts/UI/WhyPresenter.cs b/unity/Assets/Scripts/UI/WhyPresenter.csindex 9f540d302..88ca187dd 100644--- a/unity/Assets/Scripts/UI/WhyPresenter.cs+++ b/unity/Assets/Scripts/UI/WhyPresenter.cs@@ -15,6 +15,7 @@ namespace Statecraft.Game.UIpublic WhyPresenter(VisualElement root, SimBridge bridge, UiText text){screen = root.Q<VisualElement>("screen-why"); this.bridge = bridge; this.text = text;+ screen.Q<Label>("why-screen-title").text = text["why.title"];bridge.Changed += Render;Render();}diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex da0153ee5..353a31592 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -206,6 +206,181 @@ public class HebrewUiTestsreturn () => { doc.panelSettings = AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt); };}+ // --- The static texts ---------------------------------------------------------------------------------------------++ /// <summary>Every text Game.uxml writes itself that a player reads, and its string (#193). "a/b" is the element of class b+ /// inside the element named a. The presenter that owns each element sets it from the UI's strings at bind time.</summary>+ static readonly (string where, string key)[] StaticTexts =+ {+ ("loading", "boot.loading"),+ ("meter-treasury/meter-name", "hud.caption.treasury"), ("meter-immigration/meter-name", "hud.caption.immigration"),+ ("meter-security/meter-name", "hud.caption.security"), ("meter-support/meter-name", "hud.caption.support"),+ ("meter-standing/meter-name", "hud.caption.standing"), ("meter-fx/meter-name", "hud.caption.fx"),+ ("nav-cabinet", "hud.nav.cabinet"), ("nav-budget", "hud.nav.budget"), ("nav-defence", "hud.nav.defence"),+ ("nav-why", "hud.nav.why"), ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),+ ("event-draft", "event.draft"),+ ("budget-screen-title", "budget.title"), ("budget-reset", "budget.reset"), ("budget-submit", "budget.submit"),+ ("defence-screen-title", "defence.title"), ("de-escalate", "defence.lower"), ("escalate", "defence.raise"),+ ("why-screen-title", "why.title"),+ ("start-source", "start.source"), ("start-recording-credit", "start.recording_credit"),+ ("start-continue", "start.continue"), ("start-new-game", "start.new_game"),+ };++ /// <summary>Static texts that stay as Game.uxml writes them in every language: the game's name, and the Declaration's+ /// official English translation under each Hebrew line. ("-5%" and "+5%" have no letters and need no string.)</summary>+ static readonly string[] NotTranslated = { "start-title", "start-en-proclamation", "start-en-date", "start-caption-en" };++ /// <summary>Names a Hebrew static text keeps in Latin letters: the recording's engineer (names stay as the sources+ /// spell them until #55).</summary>+ static readonly string[] LatinNames = { "Ralph Hellinger" };++ static TextElement Static(VisualElement ui, string where)+ {+ var parts = where.Split('/');+ var e = parts.Length == 1 ? ui.Q<TextElement>(where) : ui.Q(parts[0])?.Q<TextElement>(className: parts[1]);+ Assert.IsNotNull(e, where);+ return e!;+ }++ /// <summary>English shows what it always showed: each English string is the text Game.uxml writes, and every text in+ /// Game.uxml with a letter in it is either one of StaticTexts, deliberately not translated, or a start line in Hebrew+ /// (an English text with the start-he class is not exempt). Game.uxml writes no tooltip: one with a letter would need+ /// a string too. Texts C# writes itself are not read here.</summary>+ [Test]+ public void EachEnglishStaticTextIsTheUxmlsOwnText()+ {+ using var ui = new UiTestKit();+ var listed = new HashSet<TextElement>();+ foreach (var (where, key) in StaticTexts)+ {+ var e = Static(ui.Root, where);+ Assert.AreEqual(e.text, En[key], $"{where}: {key}");+ listed.Add(e);+ }+ foreach (var name in NotTranslated) listed.Add(ui.Q<TextElement>(name));+ var unlisted = ui.Root.Query<TextElement>().ToList()+ .Where(t => !listed.Contains(t) && !(t.ClassListContains("start-he") && UiDirection.RightToLeft(t.text)) && (t.text ?? "").Any(char.IsLetter))+ .Select(t => $"'{t.name}' ({string.Join(" ", t.GetClasses())}): {t.text}").ToList();+ Assert.IsEmpty(unlisted, "a text Game.uxml writes that no string sets");+ var tooltips = ui.Root.Query<VisualElement>().ToList().Where(v => (v.tooltip ?? "").Any(char.IsLetter))+ .Select(v => $"'{v.name}': tooltip {v.tooltip}").ToList();+ Assert.IsEmpty(tooltips, "a tooltip Game.uxml writes that no string sets");+ }++ /// <summary>In Hebrew every static text shows its strings.he.yaml words, with no Latin letter but a listed name, and takes+ /// its direction like any other text; an English restart puts the English back.</summary>+ [Test]+ public void InHebrewEveryStaticTextIsTheHebrewString()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ Object.FindFirstObjectByType<MapScene>().Build(Inputs.Map);+ var game = Object.FindFirstObjectByType<GameRoot>();+ game.Store = new SaveStore(saveDir);+ game.Language = UiLanguage.Hebrew;+ game.Begin(Inputs, 0, startScreen: true); // the start screen sets its own texts+ var latin = new Regex("[A-Za-z]");+ foreach (var (where, key) in StaticTexts)+ {+ var e = Static(Ui, where);+ Assert.AreEqual(He[key], e.text, $"{where}: {key}");+ var rest = LatinNames.Aggregate(e.text, (s, n) => s.Replace(n, ""));+ Assert.IsFalse(latin.IsMatch(rest), $"{where}: Latin letters in '{e.text}'");+ Assert.AreEqual(LanguageDirection.RTL, e.languageDirection, $"{where}: {e.text}");+ }+ foreach (var name in NotTranslated) Assert.AreEqual(LanguageDirection.LTR, Ui.Q<TextElement>(name).languageDirection, name);++ game.Language = UiLanguage.English;+ game.Begin(Inputs, 0, startScreen: true);+ foreach (var (where, key) in StaticTexts)+ {+ var e = Static(Ui, where);+ Assert.AreEqual(En[key], e.text, $"after an English restart: {where}");+ Assert.AreEqual(LanguageDirection.Inherit, e.languageDirection, $"after an English restart: {where}");+ }+ }++ /// <summary>The loading line is in the UI's language from the first frame, before Begin, in the Hebrew face and right to+ /// left; a boot failure keeps both. English keeps its line, its face and no direction.</summary>+ [Test]+ public void TheLoadingLineIsInTheUisLanguageBeforeTheGameStarts()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var game = Object.FindFirstObjectByType<GameRoot>();+ var line = Ui.Q<Label>("loading");+ game.Language = UiLanguage.Hebrew;+ Assert.IsNotNull(game.ShowLoading());+ Assert.AreEqual(He["boot.loading"], line.text);+ Assert.IsTrue(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass), "the Hebrew face before Begin");+ Assert.AreEqual(LanguageDirection.RTL, line.languageDirection);+ LogAssert.Expect(LogType.Error, "BOOT FAIL people.yaml: people[x].name: required");+ Object.FindFirstObjectByType<GameBoot>().Fail("people.yaml: people[x].name: required");+ StringAssert.StartsWith("לא ניתן היה להפעיל", line.text);+ Assert.IsTrue(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass));+ Assert.AreEqual(LanguageDirection.RTL, line.languageDirection);++ game.Language = UiLanguage.English;+ game.ShowLoading();+ Assert.AreEqual(En["boot.loading"], line.text);+ Assert.AreEqual("Loading the map of 1948…", line.text);+ Assert.IsFalse(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass));+ Assert.AreEqual(LanguageDirection.Inherit, line.languageDirection);+ }++ /// <summary>A boot failure stays on the loading line whichever of GameBoot.Start and GameRoot.Start runs first (neither+ /// sets an execution order). On the desktop the load reads from disk, so its failure lands inside GameBoot.Start+ /// (GameSceneTests.AFailingLoadIsCaughtAndShownWithoutLocalPaths drives the same throw); GameRoot's Start must not+ /// write the loading line over it (M3 final review I5).</summary>+ [Test]+ public void ABootFailureStaysOnTheLoadingLineInEitherStartOrder([Values(UiLanguage.English, UiLanguage.Hebrew)] string language)+ {+ foreach (var failFirst in new[] { true, false })+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var game = Object.FindFirstObjectByType<GameRoot>();+ var boot = Object.FindFirstObjectByType<GameBoot>();+ game.Language = language;+ var order = failFirst ? "GameBoot.Start first" : "GameRoot.Start first";+ if (!failFirst) game.Started();+ LogAssert.Expect(LogType.Error, new Regex("BOOT FAIL Could not find file"));+ LogAssert.Expect(LogType.Exception, new Regex("Could not find file"));+ _ = boot.BootAsync(() => throw new IOException("Could not find file '/Users/someone/Statecraft Israel.app/Contents/Resources/Data/StreamingAssets/map/heightmap.json'."));+ if (failFirst) game.Started();+ var t = language == UiLanguage.Hebrew ? He : En;+ Assert.AreEqual(t.Format("boot.failed", "Could not find file 'heightmap.json'"), Ui.Q<Label>("loading").text, $"{language}, {order}");+ Assert.AreEqual(language == UiLanguage.Hebrew, Ui.Q("root").ClassListContains(UiLanguage.HebrewClass), $"{language}, {order}: the face");+ }+ }++ /// <summary>A seat count's unit follows the body (#193, from the #209 review): the Knesset, which was elected+ /// (legislatures.yaml "elected", Legislature.Elected), counts "מנדטים"; the Provisional State Council, which was+ /// appointed, counts its "חברים". English says "seats" for both, as before.</summary>+ [Test]+ public void ASeatCountsUnitIsTheBodysOwnInHebrew()+ {+ var c = Inputs.Content;+ // Only the appointed council may lack its election date: a Knesset row without "elected" would otherwise count+ // its seats as "חברים" with nothing failing.+ CollectionAssert.AreEqual(new[] { "provisional_state_council" }, c.Legislatures.Where(l => !l.Elected.HasValue).Select(l => l.Id),+ "legislatures.yaml: every body but the appointed council has its \"elected\" date");+ Assert.IsTrue(c.Legislatures.Any(l => l.Elected.HasValue), "elected bodies in content");+ foreach (var leg in c.Legislatures)+ {+ Assert.AreEqual(leg.Elected.HasValue ? "מנדטים" : "חברים", CabinetPresenter.SeatUnit(He, leg), leg.Id);+ Assert.AreEqual("seats", CabinetPresenter.SeatUnit(En, leg), leg.Id);+ }+ Assert.AreEqual("seats", CabinetPresenter.SeatUnit(En, null));++ // The game opens under the council (15 May 1948 to 14 February 1949): the house and the budget count its members.+ Boot(UiLanguage.Hebrew);+ Assert.IsFalse(c.Legislatures.First(l => l.Id == "provisional_state_council").Elected.HasValue);+ foreach (var name in new[] { "cabinet-coalition", "cabinet-opposition", "cabinet-majority", "cabinet-largest", "budget-vote" })+ {+ var t = Ui.Q<Label>(name).text;+ StringAssert.Contains("חברים", t, name);+ StringAssert.DoesNotContain("מנדטים", t, name);+ }+ }+// --- The house ---------------------------------------------------------------------------------------------------/// <summary>In Hebrew the half circle is the same picture mirrored (#199): the first seat, the coalition's, is at thediff --git a/unity/Assets/Tests/EditMode/HudTests.cs b/unity/Assets/Tests/EditMode/HudTests.csindex e084d23f6..20534ad2f 100644--- a/unity/Assets/Tests/EditMode/HudTests.cs+++ b/unity/Assets/Tests/EditMode/HudTests.cs@@ -503,13 +503,26 @@ public class HudTests}/// <summary>#398 review S3: the spoken captions are strings (so a Hebrew UI says Hebrew captions), and the English ones- /// are the captions the bar shows, so the two cannot drift apart.</summary>+ /// are the captions the bar shows, so the two cannot drift apart. #193: in each language the bar's visible caption is+ /// the caption its tooltip says (HudPresenter sets both from hud.caption.*), so a Hebrew bar no longer shows "Treasury"+ /// over a tooltip that says "אוצר".</summary>[Test]public void TheSpokenCaptionsAreTheBarsCaptions(){using var ui = new UiTestKit();foreach (var id in MeterIds)Assert.AreEqual(ui.Q<VisualElement>("meter-" + id).Q<Label>(className: "meter-name").text, Text["hud.caption." + id], id);+ foreach (var (language, text) in new[] { ("he", He), ("en", Text) })+ {+ using var hud = new HudPresenter(ui.Root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text), text);+ foreach (var id in MeterIds)+ {+ var meter = ui.Q<VisualElement>("meter-" + id);+ var shown = meter.Q<Label>(className: "meter-name").text;+ Assert.AreEqual(text["hud.caption." + id], shown, $"{language}: {id}");+ StringAssert.StartsWith(shown + ":", meter.tooltip, $"{language}: {id}'s tooltip says the caption it shows");+ }+ }}/// <summary>#398: a negative net position, a people count and a Hebrew UI, each through the real path (thediff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex 5388f5a65..f70c5efd3 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -186,7 +186,7 @@<Statecraft.Game.UI.UiFrame /></ui:VisualElement><ui:VisualElement name="screen-budget" class="panel screen">- <ui:VisualElement class="screen-header"><ui:Label text="Budget" class="title" /><ui:Label name="budget-vote" class="muted" /></ui:VisualElement>+ <ui:VisualElement class="screen-header"><ui:Label name="budget-screen-title" text="Budget" class="title" /><ui:Label name="budget-vote" class="muted" /></ui:VisualElement><ui:Label name="budget-money" /><ui:Label name="budget-flow" class="muted" /><ui:ScrollView name="budget-rows" class="grow" />@@ -200,7 +200,7 @@<!-- Defence as promo/final/08 (DefencePresenter): leadership, the escalation ladder and the reserve call-up side byside (wrapping in a narrow window), then the defence share of the budget. Only what the sim models. --><ui:VisualElement name="screen-defence" class="panel screen screen-wide">- <ui:VisualElement class="screen-header"><ui:Label text="Defence" class="title" /><ui:Label name="defence-command" class="muted" /></ui:VisualElement>+ <ui:VisualElement class="screen-header"><ui:Label name="defence-screen-title" text="Defence" class="title" /><ui:Label name="defence-command" class="muted" /></ui:VisualElement><ui:ScrollView name="defence-body" class="grow"><ui:VisualElement class="defence-row"><ui:VisualElement name="defence-leadership" class="defence-panel defence-leadership">@@ -252,7 +252,7 @@<Statecraft.Game.UI.UiFrame /></ui:VisualElement><ui:VisualElement name="screen-why" class="panel screen">- <ui:VisualElement class="screen-header"><ui:Label text="Why did this happen?" class="title" /><ui:Label name="why-turn" class="muted" /></ui:VisualElement>+ <ui:VisualElement class="screen-header"><ui:Label name="why-screen-title" text="Why did this happen?" class="title" /><ui:Label name="why-turn" class="muted" /></ui:VisualElement><ui:ScrollView name="why-rows" class="grow" /><Statecraft.Game.UI.UiFrame /></ui:VisualElement>diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 17e0b7cee..d6381985c 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -25,6 +25,29 @@ hud.caption.security: "Security"hud.caption.support: "Public Support"hud.caption.standing: "International Standing"hud.caption.fx: "Foreign Currency"+# The other static texts of Game.uxml, each set by the presenter that owns its element (#193). Each English string is+# the UXML's own text (HebrewUiTests.EachEnglishStaticTextIsTheUxmlsOwnText), so English shows what it always showed.+# The top bar (HudPresenter):+hud.nav.cabinet: "Cabinet"+hud.nav.budget: "Budget"+hud.nav.defence: "Defence"+hud.nav.why: "Why?"+hud.new_game: "New Game"+hud.end_turn: "End Turn"+# The screens' titles and buttons, the decision card's draft mark, the start screen and the loading line (GameRoot).+budget.title: "Budget"+budget.reset: "Reset"+budget.submit: "Submit the budget"+defence.title: "Defence"+defence.lower: "Lower the level"+defence.raise: "Raise the level"+why.title: "Why did this happen?"+event.draft: "DRAFT"+start.source: "From the Declaration of the Establishment of the State of Israel (Official Gazette No. 1, 14 May 1948) and its official English translation. Painting: AI-generated."+start.recording_credit: "Recording: Ralph Hellinger, Israel State Archives"+start.continue: "Continue"+start.new_game: "New Game"+boot.loading: "Loading the map of 1948…"toast.refused: "Not done: {0}"event.office: "{0}: {1}"event.more: "{0} more decision(s) waiting"@@ -64,9 +87,9 @@ budget.office: "{0} ({1})"budget.vacant: "vacant"budget.not_established: "no ministry until {0}"budget.factor: "spending effect {0}"-budget.vote_needed: "The {0} must approve it: the coalition holds {1} of {2} seats"+budget.vote_needed: "The {0} must approve it: the coalition holds {1} of {2} {3}"budget.no_vote: "The {0} does not vote on the budget"-budget.vote_advisory: "The {0} votes on it, but its vote does not bind: the coalition holds {1} of {2} seats"+budget.vote_advisory: "The {0} votes on it, but its vote does not bind: the coalition holds {1} of {2} {3}"budget.money: "Treasury {0} · debt {1} · foreign currency {2}"budget.flow: "Taxes {0}, spending {1} and reserve call-up {2} a year"budget.queued: "Submitted: takes effect at End Turn"@@ -87,7 +110,7 @@ why.effects: "Ongoing effects"why.situations: "Situations"why.other: "Other"why.nothing: "Nothing notable happened this turn."-cabinet.coalition: "Coalition: {0} of {1} seats · stability {2}"+cabinet.coalition: "Coalition: {0} of {1} {3} · stability {2}"cabinet.vacant: "(vacant)"cabinet.person: "{0} · {1} · competence {2}, loyalty {3}"cabinet.no_party: "no party"@@ -96,12 +119,17 @@ cabinet.queued: "Ordered: {0} to {1}, at End Turn"# Cabinet (promo 04): the body the government answers to, the half circle's legend and its party chips.cabinet.legislature: "Answerable to the {0} · {1} members"cabinet.legislature_advisory: "Consults the {0} · {1} members · its votes do not bind"-cabinet.opposition: "Opposition: {0} seats"-cabinet.majority: "Majority: {0} seats"-cabinet.largest: "Largest party: {0}, {1} seats"+cabinet.opposition: "Opposition: {0} {1}"+cabinet.majority: "Majority: {0} {1}"+cabinet.largest: "Largest party: {0}, {1} {2}"cabinet.party_seats: "{0} {1}"cabinet.unrecorded: "Not recorded"cabinet.members_unit: "members"+# The unit of a seat count above ({3}, {1} or {2}), by the body (CabinetPresenter.SeatUnit): an elected body's+# (legislatures.yaml has its "elected" date) or the appointed Provisional State Council's. One word in English; Hebrew+# says "מנדטים" for the Knesset and "חברים" for the council (#193).+cabinet.seats: "seats"+cabinet.seats_appointed: "seats"cabinet.select_office: "{0}"# Person cards (Cabinet and Defence): the two bars' captions, the PM card's party line, and the joint between offices.card.competence: "Competence"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex d807c9682..4ec290adf 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -20,6 +20,25 @@ hud.caption.security: "ביטחון"hud.caption.support: "תמיכה ציבורית"hud.caption.standing: "מעמד בינלאומי"hud.caption.fx: "מטבע חוץ"+hud.nav.cabinet: "ממשלה"+hud.nav.budget: "תקציב"+hud.nav.defence: "ביטחון"+hud.nav.why: "למה?"+hud.new_game: "משחק חדש"+hud.end_turn: "סיום התור"+budget.title: "תקציב"+budget.reset: "איפוס"+budget.submit: "הגשת התקציב"+defence.title: "ביטחון"+defence.lower: "הורדת הדרגה"+defence.raise: "העלאת הדרגה"+why.title: "למה זה קרה?"+event.draft: "טיוטה"+start.source: "מתוך ההכרזה על הקמת מדינת ישראל (עיתון רשמי מס׳ 1, 14 במאי 1948) ותרגומה הרשמי לאנגלית. הציור נוצר בבינה מלאכותית."+start.recording_credit: "הקלטה: Ralph Hellinger, ארכיון המדינה"+start.continue: "המשך"+start.new_game: "משחק חדש"+boot.loading: "טוען את מפת 1948…"toast.refused: "לא בוצע: {0}"event.office: "{0}: {1}"event.more: "החלטות ממתינות נוספות: {0}"@@ -57,7 +76,7 @@ defence.ceasefire_starts: "הפסקת אש של האו״ם: {0} שבועות מdefence.budget_share: "{0} מהוצאות התקציב"defence.budget_none: "אין בתקציב סעיף ביטחון"defence.section_leadership: "הנהגה"-defence.section_ladder: "דרגת ביטחון"+defence.section_ladder: "המצב הביטחוני"defence.section_callup: "גיוס מילואים"defence.section_budget: "חלקו של הביטחון בתקציב"budget.share: "{0}"@@ -65,9 +84,9 @@ budget.office: "{0} ({1})"budget.vacant: "פנוי"budget.not_established: "אין משרד עד {0}"budget.factor: "השפעת ההוצאה {0}"-budget.vote_needed: "נדרש אישור של {0}: לקואליציה יש {1} מתוך {2} מנדטים"+budget.vote_needed: "נדרש אישור של {0}: לקואליציה יש {1} מתוך {2} {3}"budget.no_vote: "{0} אינו מצביע על התקציב"-budget.vote_advisory: "{0} מצביע עליו, אך הצבעתו אינה מחייבת: לקואליציה יש {1} מתוך {2} מנדטים"+budget.vote_advisory: "{0} מצביע עליו, אך הצבעתו אינה מחייבת: לקואליציה יש {1} מתוך {2} {3}"budget.money: "אוצר {0} · חוב {1} · מטבע חוץ {2}"budget.flow: "מסים {0}, הוצאות {1} וגיוס מילואים {2} בשנה"budget.queued: "הוגש: ייכנס לתוקף בסיום התור"@@ -88,22 +107,24 @@ why.effects: "השפעות מתמשכות"why.situations: "מצבים"why.other: "אחר"why.nothing: "לא קרה דבר ראוי לציון בתור הזה."-cabinet.coalition: "קואליציה: {0} מתוך {1} מנדטים · יציבות {2}"+cabinet.coalition: "קואליציה: {0} מתוך {1} {3} · יציבות {2}"cabinet.vacant: "(פנוי)"-cabinet.person: "{0} · {1} · כשירות {2}, נאמנות {3}"+cabinet.person: "{0} · {1} · כישורים {2}, נאמנות {3}"cabinet.no_party: "ללא מפלגה"cabinet.pick: "מינוי לתפקיד {0}"cabinet.queued: "ניתנה פקודה: {0} לתפקיד {1}, בסיום התור"cabinet.legislature: "אחראית בפני {0} · {1} חברים"cabinet.legislature_advisory: "מתייעצת עם {0} · {1} חברים · הצבעותיו אינן מחייבות"-cabinet.opposition: "אופוזיציה: {0} מנדטים"-cabinet.majority: "רוב: {0} מנדטים"-cabinet.largest: "המפלגה הגדולה: {0}, {1} מנדטים"+cabinet.opposition: "אופוזיציה: {0} {1}"+cabinet.majority: "רוב: {0} {1}"+cabinet.largest: "המפלגה הגדולה: {0}, {1} {2}"cabinet.party_seats: "{0} {1}"cabinet.unrecorded: "לא תועד"cabinet.members_unit: "חברים"+cabinet.seats: "מנדטים"+cabinet.seats_appointed: "חברים"cabinet.select_office: "{0}"-card.competence: "כשירות"+card.competence: "כישורים"card.loyalty: "נאמנות"card.party: "מפלגה: {0}"card.appointed_name: "{0} (מינוי שלך)"