Skip to content

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 Cabinet's candidate refusal reasons in Hebrew (Fixes #901) (#985)

Eyal Golanc495c6f16025
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29b84e9c4..51c827bfb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- Jerusalem's symbolic Haram al-Sharif / Temple Mount runs north-south in its sourced proportions against the Old City's
east and south walls, Al-Aqsa stands across its south end, and the walls have the seven gates open before the 1948 war
on their real sides, the Golden Gate sealed: 7 gates, not one per road gap (13) (#319).
+- Under `?lang=he`, the Cabinet's candidate refusal reasons use Hebrew UI strings and Hebrew person, office, party and
+ date values instead of displaying the simulation's English prose; English is unchanged (refs #901, #564).
## [0.1.0] - 2026-10-18
diff --git a/sim/Statecraft.Sim.Tests/CabinetTests.cs b/sim/Statecraft.Sim.Tests/CabinetTests.cs
index 449424d41..94e01fd26 100644
--- a/sim/Statecraft.Sim.Tests/CabinetTests.cs
+++ b/sim/Statecraft.Sim.Tests/CabinetTests.cs
@@ -76,16 +76,19 @@ public class CabinetTests
}
[Theory]
- [InlineData("prime_minister", "loyalist", "You are the Prime Minister: that office is not yours to fill")]
- [InlineData("finance_minister", "outsider", "Out Sider's party (Beta) is not in the coalition")]
- [InlineData("finance_minister", "gone", "Gone Early died on 1 May 1948")]
- [InlineData("finance_minister", "def_two", "Def Two already holds the office of Minister of Finance")]
- [InlineData("finance_minister", "nobody", "That person is not in this game")]
- [InlineData("treasurer", "loyalist", "That office does not exist in this game")]
- public void IllegalAppointmentsAreRejectedWithAReason(string office, string person, string reason)
+ [InlineData("prime_minister", "loyalist", "prime_minister", "You are the Prime Minister: that office is not yours to fill")]
+ [InlineData("finance_minister", "outsider", "party_not_coalition", "Out Sider's party (Beta) is not in the coalition")]
+ [InlineData("finance_minister", "gone", "died", "Gone Early died on 1 May 1948")]
+ [InlineData("finance_minister", "def_two", "already_holds", "Def Two already holds the office of Minister of Finance")]
+ [InlineData("finance_minister", "nobody", "person_unknown", "That person is not in this game")]
+ [InlineData("treasurer", "loyalist", "office_unknown", "That office does not exist in this game")]
+ public void IllegalAppointmentsAreRejectedWithAStableCodeAndUnchangedEnglish(string office, string person, string kind, string reason)
{
var s = Simulation.NewGame(C, 42, Mode.Historical);
var before = s.Hash();
+ var coded = Cabinet.CheckReason(C, s, office, person)!;
+ Assert.Equal(kind, coded.Kind);
+ Assert.Equal(reason, coded.Text);
Assert.Equal(reason, Cabinet.Appoint(C, s, office, person, new List<Cause>()));
Assert.Equal(before, s.Hash());
}
diff --git a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
index fe76abfdf..dcc86a566 100644
--- a/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
+++ b/sim/Statecraft.Sim.Tests/SliceSmokeTests.cs
@@ -118,7 +118,7 @@ public class SliceSmokeTests
foreach (var seat in Cabinet.Lineup(c, s))
{
yield return (seat.Office.Title + ": " + string.Join(", ", seat.Holders.Select(p => p.Name)), false);
- foreach (var reason in Cabinet.Candidates(c, s, seat.Office.Id).Select(x => x.reason).Where(x => x != null).Distinct())
+ foreach (var reason in Cabinet.Candidates(c, s, seat.Office.Id).Select(x => x.reason?.Text).Where(x => x != null).Distinct())
yield return (reason!, false);
}
// InfoPanelPresenter: why a build is not possible on a hex (a sample of the map).
diff --git a/sim/Statecraft.Sim/Cabinet.cs b/sim/Statecraft.Sim/Cabinet.cs
index 9ec731d68..37bb1ae7d 100644
--- a/sim/Statecraft.Sim/Cabinet.cs
+++ b/sim/Statecraft.Sim/Cabinet.cs
@@ -29,6 +29,18 @@ namespace Statecraft.Sim
}
}
+ /// <summary>A Cabinet refusal's stable UI kind and invariant values, beside the unchanged English text used by commands.</summary>
+ public sealed class CabinetReason
+ {
+ public string Kind { get; }
+ public IReadOnlyList<string> Values { get; }
+ public string Text { get; }
+ public CabinetReason(string kind, string text, params string[] values)
+ {
+ Kind = kind; Text = text; Values = values;
+ }
+ }
+
/// <summary>The cabinet as the game sees it: the historical holders from people.yaml, overridden by the player's
/// appointments until the government changes (a new government takes office with its own, historical, ministers).</summary>
public static class Cabinet
@@ -79,38 +91,47 @@ namespace Statecraft.Sim
/// government is in office; a Chief of Staff must be a career officer (has held the post in people.yaml); a
/// minister's party, if any, must be in the coalition.</summary>
/// <remarks>Holding two portfolios is allowed by design: historically Ben-Gurion was Prime Minister and Defence, and Shapira held three.</remarks>
- public static string? Check(Content c, GameState s, string officeId, string personId)
+ public static string? Check(Content c, GameState s, string officeId, string personId) => CheckReason(c, s, officeId, personId)?.Text;
+
+ /// <summary>Null when the appointment is legal, else a stable kind and invariant values for a UI, plus English text.</summary>
+ public static CabinetReason? CheckReason(Content c, GameState s, string officeId, string personId)
{
var office = c.Offices.FirstOrDefault(o => o.Id == officeId);
- if (office == null) return "That office does not exist in this game";
- if (office.HistoricalOnly) return $"{office.Title} is a historical title, not an appointable office";
+ if (office == null) return new CabinetReason("office_unknown", "That office does not exist in this game");
+ if (office.HistoricalOnly) return new CabinetReason("historical_office", $"{office.Title} is a historical title, not an appointable office", officeId);
if (office.Until.HasValue && s.Date >= office.Until.Value)
- return $"The office of {office.Title} was abolished on {PlayerText.Date(office.Until.Value)}";
+ return new CabinetReason("abolished", $"The office of {office.Title} was abolished on {PlayerText.Date(office.Until.Value)}", officeId,
+ office.Until.Value.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture));
if (office.From.HasValue && s.Date < office.From.Value)
- return $"The office of {office.Title} is not established until {PlayerText.Date(office.From.Value)}";
- if (office.SeveralHolders) return $"{office.Title} can have several holders at once, and appointing to it is not part of the game yet";
- if (officeId == "prime_minister") return "You are the Prime Minister: that office is not yours to fill";
- if (officeId == "president") return "The President is elected by the Knesset, not appointed";
+ return new CabinetReason("not_established", $"The office of {office.Title} is not established until {PlayerText.Date(office.From.Value)}", officeId,
+ office.From.Value.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture));
+ if (office.SeveralHolders) return new CabinetReason("several_holders", $"{office.Title} can have several holders at once, and appointing to it is not part of the game yet", officeId);
+ if (officeId == "prime_minister") return new CabinetReason("prime_minister", "You are the Prime Minister: that office is not yours to fill");
+ if (officeId == "president") return new CabinetReason("president", "The President is elected by the Knesset, not appointed");
var person = c.People.FirstOrDefault(p => p.Id == personId);
- if (person == null) return "That person is not in this game";
+ if (person == null) return new CabinetReason("person_unknown", "That person is not in this game");
if (person.Died.HasValue && s.Date >= person.Died.Value)
- return $"{person.Name} died on {PlayerText.Date(person.Died.Value)}";
- if (Holder(c, s, "president")?.Id == personId) return $"{person.Name} is the President";
- if (officeId != "chief_of_staff" && Holder(c, s, "chief_of_staff")?.Id == personId) return $"{person.Name} is the serving Chief of Staff";
- if (Holder(c, s, officeId)?.Id == personId) return $"{person.Name} already holds the office of {office.Title}";
+ return new CabinetReason("died", $"{person.Name} died on {PlayerText.Date(person.Died.Value)}", personId,
+ person.Died.Value.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture));
+ if (Holder(c, s, "president")?.Id == personId) return new CabinetReason("is_president", $"{person.Name} is the President", personId);
+ if (officeId != "chief_of_staff" && Holder(c, s, "chief_of_staff")?.Id == personId)
+ return new CabinetReason("is_chief_of_staff", $"{person.Name} is the serving Chief of Staff", personId);
+ if (Holder(c, s, officeId)?.Id == personId)
+ return new CabinetReason("already_holds", $"{person.Name} already holds the office of {office.Title}", personId, officeId);
var gov = Offices.Government(c, s.Date);
- if (gov == null) return "No government is in office";
+ if (gov == null) return new CabinetReason("no_government", "No government is in office");
if (officeId == "chief_of_staff")
- return person.Offices.Any(t => t.Office == "chief_of_staff") ? null : $"{person.Name} is not an IDF career officer";
+ return person.Offices.Any(t => t.Office == "chief_of_staff") ? null
+ : new CabinetReason("not_career_officer", $"{person.Name} is not an IDF career officer", personId);
var party = Offices.PartyOf(c, person, s.Date);
if (party != "" && !gov.CoalitionOn(s.Date).Contains(party))
- return $"{person.Name}'s party ({c.Parties.First(p => p.Id == party).Name}) is not in the coalition";
+ return new CabinetReason("party_not_coalition", $"{person.Name}'s party ({c.Parties.First(p => p.Id == party).Name}) is not in the coalition", personId, party);
return null;
}
/// <summary>Every person with the reason they cannot be appointed (null = they can), in people.yaml order.</summary>
- public static IReadOnlyList<(Person person, string? reason)> Candidates(Content c, GameState s, string officeId) =>
- c.People.Select(p => (p, Check(c, s, officeId, p.Id))).ToList();
+ public static IReadOnlyList<(Person person, CabinetReason? reason)> Candidates(Content c, GameState s, string officeId) =>
+ c.People.Select(p => (p, CheckReason(c, s, officeId, p.Id))).ToList();
/// <summary>Returns null and appoints, or the reason (state untouched). Replacing a minister costs coalition
/// stability: rules appoint_stability_cost_other_party when the seat leaves the displaced minister's party (a
diff --git a/tools/tests/test_hebrew_ui.py b/tools/tests/test_hebrew_ui.py
index e5965723c..cdfb85c0e 100644
--- a/tools/tests/test_hebrew_ui.py
+++ b/tools/tests/test_hebrew_ui.py
@@ -123,3 +123,22 @@ def test_hebrew_acronyms_use_the_gershayim_character():
assert values, file
for value in values:
assert not HEBREW_ACRONYM_STRAIGHT_QUOTE.search(value), (file, value)
+
+
+def test_every_cabinet_refusal_has_both_strings_and_the_english_is_the_sims_wording():
+ """#901: every return path of Cabinet.CheckReason names a kind; the Cabinet screen formats it from
+ cabinet.reason.<kind>. Each kind needs a key in both files, and the English key must be the sim's own English text
+ (its interpolations as {0}, {1}, ... in order), so the English player sees what the sim says."""
+ en, he = strings('strings.en.yaml'), strings('strings.he.yaml')
+ src = (ROOT / 'sim/Statecraft.Sim/Cabinet.cs').read_text(encoding='utf-8')
+ paths = re.findall(r'new CabinetReason\("(\w+)",\s*(\$?)"((?:[^"\\]|\\.)*)"', src)
+ assert len(paths) == 15
+ assert len({kind for kind, _, _ in paths}) == len(paths) # one kind per return path
+ for kind, interpolated, english in paths:
+ key = 'cabinet.reason.' + kind
+ assert key in en and key in he, key
+ n = iter(range(10))
+ template = re.sub(r'\{[^{}]+\}', lambda _: '{%d}' % next(n), english) if interpolated else english
+ assert en[key] == template, key
+ assert not re.search('[A-Za-z]', he[key]), key
+ assert sorted(k for k in en if k.startswith('cabinet.reason.')) == sorted('cabinet.reason.' + k for k, _, _ in paths)
diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.cs
index b3761f17e..1f7803bd7 100644
--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs
+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs
@@ -1,5 +1,7 @@
#nullable enable
+using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using Statecraft.Sim;
using UnityEngine;
@@ -256,20 +258,40 @@ namespace Statecraft.Game.UI
var list = Cabinet.Candidates(c, s, Selected);
// A refusal about the office itself (the Prime Minister's or the President's, an abolished one) is the same for
// everyone: it is said once under the heading, not under every name (#215).
- var shared = list.Count > 0 && list.All(x => x.reason != null && x.reason == list[0].reason) ? list[0].reason : null;
+ var shared = list.Count > 0 && list.All(x => x.reason != null && x.reason.Text == list[0].reason!.Text) ? list[0].reason : null;
var common = screen.Q<Label>("cabinet-pick-reason");
- common.text = shared ?? "";
+ common.text = shared == null ? "" : ReasonText(c, shared);
common.style.display = shared == null ? DisplayStyle.None : DisplayStyle.Flex;
foreach (var (person, reason) in list)
{
if (!rows.TryGetValue(person.Id, out var r)) continue;
r.appoint.text = Describe(person);
r.appoint.SetEnabled(reason == null);
- r.reason.text = shared == null ? reason ?? "" : "";
+ r.reason.text = shared == null && reason != null ? ReasonText(c, reason) : "";
r.reason.style.display = reason == null || shared != null ? DisplayStyle.None : DisplayStyle.Flex;
}
}
+ string ReasonText(Content c, CabinetReason reason)
+ {
+ bool he = text["ui.lang"] == UiLanguage.Hebrew;
+ string Person(string id) { var p = c.People.First(x => x.Id == id); return he && p.NameHe != "" ? p.NameHe : p.Name; }
+ string Office(string id) { var o = c.Offices.First(x => x.Id == id); return he && o.TitleHe != "" ? o.TitleHe : o.Title; }
+ string Party(string id) { var p = c.Parties.First(x => x.Id == id); return he && p.NameHe != "" ? p.NameHe : p.Name; }
+ string Date(string iso) => Statecraft.Game.Map.Control1948.DateText(System.DateTime.ParseExact(iso, "yyyy-MM-dd", CultureInfo.InvariantCulture), k => text[k]);
+ var key = "cabinet.reason." + reason.Kind;
+ switch (reason.Kind)
+ {
+ case "historical_office": case "several_holders": return text.Format(key, Office(reason.Values[0]));
+ case "abolished": case "not_established": return text.Format(key, Office(reason.Values[0]), Date(reason.Values[1]));
+ case "died": return text.Format(key, Person(reason.Values[0]), Date(reason.Values[1]));
+ case "is_president": case "is_chief_of_staff": case "not_career_officer": return text.Format(key, Person(reason.Values[0]));
+ case "already_holds": return text.Format(key, Person(reason.Values[0]), Office(reason.Values[1]));
+ case "party_not_coalition": return text.Format(key, Person(reason.Values[0]), Party(reason.Values[1]));
+ default: return text[key];
+ }
+ }
+
/// <summary>The half circle of seats and its legend; the party list is remade only when the body or government changes.</summary>
void RenderHouse(Content c, GameState s, Government? gov, Legislature? leg, int seats, int size)
{
diff --git a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
index 3334f75a7..92e32cfa8 100644
--- a/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/CabinetScreenTests.cs
@@ -13,6 +13,7 @@ public class CabinetScreenTests
{
static readonly Content C = ContentLoader.Load(Paths.Content);
static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
/// <summary>The UI with the Cabinet screen open, as ScreenNav opens it (a hidden screen does not re-render).</summary>
static UiTestKit Shown()
@@ -54,6 +55,18 @@ public class CabinetScreenTests
Assert.IsTrue(ui.Q<Button>("appoint-golda_meir").enabledSelf);
}
+ /// <summary>#901: candidate refusal arguments are content ids from the sim; the Hebrew UI resolves and formats them.</summary>
+ [Test]
+ public void ARefusedCandidateHasAHebrewReasonInTheHebrewUi()
+ {
+ using var ui = Shown();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ while (g.State.Date < new DateTime(1950, 2, 1)) g.Step(HistoricalAI.Commands(C, g.State));
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(g, He), He, null);
+ cabinet.Select("finance_minister");
+ Assert.AreEqual("אהרון ציזלינג ממפלגת מפ״ם, שאינה בקואליציה", ui.Q<Label>("cand-zisling-reason").text);
+ }
+
[Test]
public void AppointingTakesEffectAtEndTurn()
{
@@ -101,17 +114,17 @@ public class CabinetScreenTests
cabinet.Select(office);
var list = Cabinet.Candidates(C, bridge.State, office);
// #215: a refusal shared by every candidate (the office itself) is said once under the heading.
- var shared = list.All(x => x.reason != null && x.reason == list[0].reason) ? list[0].reason : null;
+ var shared = list.All(x => x.reason != null && x.reason.Text == list[0].reason!.Text) ? list[0].reason : null;
Assert.AreEqual(office == "prime_minister" || office == "president", shared != null, office + ": an office-level refusal");
- Assert.AreEqual(shared ?? "", ui.Q<Label>("cabinet-pick-reason").text, office);
+ Assert.AreEqual(shared?.Text ?? "", ui.Q<Label>("cabinet-pick-reason").text, office);
Assert.AreEqual(shared == null ? DisplayStyle.None : DisplayStyle.Flex, ui.Q<Label>("cabinet-pick-reason").style.display.value, office);
foreach (var (person, reason) in list)
{
- Assert.AreEqual(Cabinet.Check(C, bridge.State, office, person.Id), reason, office + " " + person.Id); // Candidates is Check, row by row
+ Assert.AreEqual(Cabinet.Check(C, bridge.State, office, person.Id), reason?.Text, office + " " + person.Id); // Candidates is CheckReason, row by row
Assert.AreEqual(reason == null, ui.Q<Button>("appoint-" + person.Id).enabledSelf, office + " " + person.Id);
var row = ui.Q<Label>("cand-" + person.Id + "-reason");
if (shared != null) Assert.AreEqual(DisplayStyle.None, row.style.display.value, office + " " + person.Id + ": not repeated");
- else if (reason != null) Assert.AreEqual(reason, row.text);
+ else if (reason != null) Assert.AreEqual(reason.Text, row.text);
}
}
}
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 483c35bbf..4532113f2 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -264,6 +264,21 @@ info.map_action_reason.too_far_one: "This hex is more than {0} hex from a settle
info.map_action_reason.too_far_many: "This hex is more than {0} hexes from a settlement"
info.map_action_reason.occupied: "This hex already has {0}"
info.map_action_reason.turn_cap: "No more than {0} map actions in one turn"
+cabinet.reason.office_unknown: "That office does not exist in this game"
+cabinet.reason.historical_office: "{0} is a historical title, not an appointable office"
+cabinet.reason.abolished: "The office of {0} was abolished on {1}"
+cabinet.reason.not_established: "The office of {0} is not established until {1}"
+cabinet.reason.several_holders: "{0} can have several holders at once, and appointing to it is not part of the game yet"
+cabinet.reason.prime_minister: "You are the Prime Minister: that office is not yours to fill"
+cabinet.reason.president: "The President is elected by the Knesset, not appointed"
+cabinet.reason.person_unknown: "That person is not in this game"
+cabinet.reason.died: "{0} died on {1}"
+cabinet.reason.is_president: "{0} is the President"
+cabinet.reason.is_chief_of_staff: "{0} is the serving Chief of Staff"
+cabinet.reason.already_holds: "{0} already holds the office of {1}"
+cabinet.reason.no_government: "No government is in office"
+cabinet.reason.not_career_officer: "{0} is not an IDF career officer"
+cabinet.reason.party_not_coalition: "{0}'s party ({1}) is not in the coalition"
info.biome.sea: "Sea"
info.biome.lake: "Lake"
info.biome.coastal_plain: "Coastal plain"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 47189af42..ff122ba2d 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -264,6 +264,24 @@ info.map_action_reason.too_far_one: "המשושה הזה נמצא במרחק ש
info.map_action_reason.too_far_many: "המשושה הזה נמצא במרחק של יותר מ־{0} משושים מיישוב"
info.map_action_reason.occupied: "במשושה הזה כבר יש {0}"
info.map_action_reason.turn_cap: "אי אפשר לבצע יותר מ־{0} פעולות מפה בתור אחד"
+# Cabinet candidate refusals (#901). The sim supplies content ids and ISO dates; the UI supplies the Hebrew names and
+# wording. No verb agrees with the person's gender ("כבר בתפקיד", not "מכהן"), since a woman can be any candidate.
+# Short, neutral drafts for the native reviewer (#564).
+cabinet.reason.office_unknown: "המשרה הזאת אינה קיימת במשחק"
+cabinet.reason.historical_office: "אי אפשר למנות לתפקיד ההיסטורי {0}"
+cabinet.reason.abolished: "המשרה {0} בוטלה ב־{1}"
+cabinet.reason.not_established: "אפשר למנות למשרת {0} החל מ־{1}"
+cabinet.reason.several_holders: "למשרה {0} כמה מכהנים, ואי אפשר עדיין למנות אליה במשחק"
+cabinet.reason.prime_minister: "אי אפשר למנות לתפקיד ראש הממשלה"
+cabinet.reason.president: "הכנסת בוחרת את הנשיא; אי אפשר למנות לתפקיד"
+cabinet.reason.person_unknown: "האדם הזה אינו קיים במשחק"
+cabinet.reason.died: "אי אפשר למנות את {0}: פטירה ב־{1}"
+cabinet.reason.is_president: "{0} כבר בתפקיד הנשיא"
+cabinet.reason.is_chief_of_staff: "{0} כבר בתפקיד הרמטכ״ל"
+cabinet.reason.already_holds: "{0} כבר בתפקיד {1}"
+cabinet.reason.no_government: "אין ממשלה מכהנת"
+cabinet.reason.not_career_officer: "ל־{0} אין שירות קבע בצה״ל"
+cabinet.reason.party_not_coalition: "{0} ממפלגת {1}, שאינה בקואליציה"
info.biome.sea: "ים"
info.biome.lake: "אגם"
info.biome.coastal_plain: "מישור החוף"