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.

Unit cards: optional Hebrew place, first commander and sector, with English fallback (refs #558) (#1145)

Beri006068ffac91
diff --git a/changelog.d/558.md b/changelog.d/558.md
new file mode 100644
index 000000000..5c47cd22e
--- /dev/null
+++ b/changelog.d/558.md
@@ -0,0 +1,4 @@
+- Unit cards can show the place, first commander and sector in Hebrew: optional `place_he`, `first_commander_he` and
+ `sector_he` in `units_1948.yaml`, each with its sources and `*_review: agent-checked`, shown only in the Hebrew UI,
+ each falling back to its own English. The loader refuses a Hebrew text without its English, blank keys, and sources
+ or review flags without the text. No shipped row carries them yet, so no card changes (refs #558).
diff --git a/docs/units.md b/docs/units.md
index 4173ed811..ca501cd37 100644
--- a/docs/units.md
+++ b/docs/units.md
@@ -335,6 +335,16 @@ checks every anchor and logs each spot and its distance.
- A second click shows the hex and its map actions. A hidden layer (the `units` toggle off) selects nothing.
- The card gives the name, the number and the service, where the unit stands (with "since" only from a sourced start),
its formation and first commander where sourced, and the sector in the source's words.
+- In the Hebrew UI the place, the first commander and the sector each show their optional Hebrew counterpart in
+ `units_1948.yaml` (#558): `place_he` on an anchor, `first_commander_he` and `sector_he` on the row, each with its
+ `*_he_sources` (the sources of its proper names) and `*_he_review: agent-checked` until a native speaker has read it
+ (#564). A field without one shows its English, independently of the other two; the English card never changes.
+ `UnitData.Parse` refuses a Hebrew text without its English (so a Hebrew commander never adds a line), a present but
+ blank key, sources or a review flag without the text, and text without Hebrew letters; an unknown key such as
+ `formed_he` fails as every unknown key does. Their sources join the card's source hosts but, like `name_he_sources`,
+ never clear `wikipedia_only` (#902). The shipped rows carry none yet; the translations in `research_notes/Map/unit-card-hebrew-harel-givati-negev.md` wait for its
+ person's source checks. Tests: `UnitsInPlayTests` (`TheHebrewProseShows...`, `EachHebrewFieldFallsBack...`,
+ `AHebrewCommanderWithoutTheEnglishAddsNoLine`, `BadHebrewProseNamesTheProblem`), on test-only fixtures.
- It also gives the national values the token reflects ("Reserve call-up 80% · security level 5 of 5") and the source
hosts, with a draft note that says "Wikipedia only" when the position's own sources are.
- It has no orders; a button opens the Defence screen.
diff --git a/unity/Assets/Scripts/Map/Units/UnitData.cs b/unity/Assets/Scripts/Map/Units/UnitData.cs
index f2480ff20..4ccc263a9 100644
--- a/unity/Assets/Scripts/Map/Units/UnitData.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitData.cs
@@ -17,10 +17,31 @@ namespace Statecraft.Game.Map.Units
public string Checked { get; set; } = "";
}
+ /// <summary>The optional Hebrew counterpart of one English card text (#558): the Hebrew, the sources of its proper
+ /// names, and "agent-checked" until a native Hebrew speaker reviews it (#564). Each key records that it was given, so
+ /// a present-but-blank key is an error rather than read as left out (<see cref="UnitData.Parse"/>).</summary>
+ public sealed class UnitHebrewText
+ {
+ public string? Text { get => text; set { text = value; TextGiven = true; } }
+ public bool TextGiven { get; private set; }
+ string? text;
+ public List<UnitSource>? Sources { get => sources; set { sources = value; SourcesGiven = true; } }
+ public bool SourcesGiven { get; private set; }
+ List<UnitSource>? sources;
+ public string? Review { get => review; set { review = value; ReviewGiven = true; } }
+ public bool ReviewGiven { get; private set; }
+ string? review;
+ }
+
/// <summary>Where a unit stood: a named place for a dated window [From, To).</summary>
public sealed class UnitAnchor
{
public string Place { get; set; } = "";
+ /// <summary>The place in Hebrew (#558), shown only in the Hebrew card; the English <see cref="Place"/> where absent.</summary>
+ [YamlIgnore] public UnitHebrewText PlaceHebrew { get; } = new UnitHebrewText();
+ public string? PlaceHe { get => PlaceHebrew.Text; set => PlaceHebrew.Text = value; }
+ public List<UnitSource>? PlaceHeSources { get => PlaceHebrew.Sources; set => PlaceHebrew.Sources = value; }
+ public string? PlaceHeReview { get => PlaceHebrew.Review; set => PlaceHebrew.Review = value; }
public double Lon { get; set; }
public double Lat { get; set; }
public string From { get; set; } = "";
@@ -116,7 +137,17 @@ namespace Statecraft.Game.Map.Units
public UnitStrength? Strength { get; set; }
public string? Formed { get; set; }
public string? FirstCommander { get; set; }
+ /// <summary>The first commander in Hebrew (#558), only beside an English <see cref="FirstCommander"/>.</summary>
+ [YamlIgnore] public UnitHebrewText FirstCommanderHebrew { get; } = new UnitHebrewText();
+ public string? FirstCommanderHe { get => FirstCommanderHebrew.Text; set => FirstCommanderHebrew.Text = value; }
+ public List<UnitSource>? FirstCommanderHeSources { get => FirstCommanderHebrew.Sources; set => FirstCommanderHebrew.Sources = value; }
+ public string? FirstCommanderHeReview { get => FirstCommanderHebrew.Review; set => FirstCommanderHebrew.Review = value; }
public string Sector { get; set; } = "";
+ /// <summary>The sector in Hebrew (#558), shown only in the Hebrew card; the English <see cref="Sector"/> where absent.</summary>
+ [YamlIgnore] public UnitHebrewText SectorHebrew { get; } = new UnitHebrewText();
+ public string? SectorHe { get => SectorHebrew.Text; set => SectorHebrew.Text = value; }
+ public List<UnitSource>? SectorHeSources { get => SectorHebrew.Sources; set => SectorHebrew.Sources = value; }
+ public string? SectorHeReview { get => SectorHebrew.Review; set => SectorHebrew.Review = value; }
public bool WikipediaOnly { get; set; }
public string Status { get; set; } = "";
/// <summary>A person's sign-off beside the status (#375, "humans only"): both or neither, a GitHub handle and a day;
@@ -140,13 +171,23 @@ namespace Statecraft.Game.Map.Units
public List<UnitAircraft>? Aircraft { get; set; }
public List<UnitSource>? Sources { get; set; }
- /// <summary>Every source of the row: its Hebrew name's and its facts' (<see cref="FactSources"/>).</summary>
+ /// <summary>Every source of the row: its Hebrew name's, its Hebrew card texts' (#558) and its facts'
+ /// (<see cref="FactSources"/>).</summary>
public IEnumerable<UnitSource> AllSources()
{
foreach (var s in NameHeSources) yield return s;
+ foreach (var h in HebrewTexts()) if (h.Sources != null) foreach (var s in h.Sources) yield return s;
foreach (var s in FactSources()) yield return s;
}
+ /// <summary>The row's Hebrew card texts: its anchors' places, its first commander and its sector (#558).</summary>
+ IEnumerable<UnitHebrewText> HebrewTexts()
+ {
+ foreach (var a in Anchors) yield return a.PlaceHebrew;
+ yield return FirstCommanderHebrew;
+ yield return SectorHebrew;
+ }
+
/// <summary>The sources of the row's facts: its own, its anchors', its aircraft's, its headgear's, its vehicles',
/// its disbandment's and its strength's. A Hebrew name's source is not one: it does not check a fact, so it never clears
/// wikipedia_only (#902).</summary>
@@ -227,7 +268,8 @@ namespace Statecraft.Game.Map.Units
/// <summary>Parses and checks the file. Every problem throws InvalidDataException naming the file and the unit: YAML
/// syntax, unknown or duplicate keys, a bad or duplicate id, an unknown service, side or aircraft type, a missing name or
/// sector, a bad date or an empty window, an anchor off the globe or without a source, a source without url or
- /// check date, a drawn unit with no anchors, or an air unit without aircraft.</summary>
+ /// check date, a drawn unit with no anchors, an air unit without aircraft, or a bad Hebrew card text (#558,
+ /// <see cref="ValidateHebrewText"/>).</summary>
public static List<UnitEntry> Parse(string yaml, string file = DefaultFileName)
{
UnitFile doc;
@@ -249,6 +291,8 @@ namespace Statecraft.Game.Map.Units
if (!((IList<string>)Sides).Contains(u.Side)) throw new InvalidDataException($"{at} has unknown side '{u.Side}' ({string.Join(", ", Sides)})");
if (string.IsNullOrWhiteSpace(u.Name) || string.IsNullOrWhiteSpace(u.Sector)) throw new InvalidDataException($"{at} needs a name and a sector");
ValidateHebrewName(u, at);
+ ValidateHebrewText(u.FirstCommanderHebrew, "first_commander", u.FirstCommander, at);
+ ValidateHebrewText(u.SectorHebrew, "sector", u.Sector, at);
if (u.Echelon != null && !((IList<string>)Echelons).Contains(u.Echelon)) throw new InvalidDataException($"{at} has unknown echelon '{u.Echelon}' ({string.Join(", ", Echelons)})");
if (u.Side != Israel && (u.Echelon == null || u.Strength == null)) throw new InvalidDataException($"{at} is a row of {u.Side}, so it needs an echelon and a strength (#570)");
if (u.Strength != null)
@@ -273,6 +317,7 @@ namespace Statecraft.Game.Map.Units
{
if (a == null || string.IsNullOrWhiteSpace(a.Place)) throw new InvalidDataException($"{at} an anchor has no place");
var where = $"{at} anchor '{a.Place}'";
+ ValidateHebrewText(a.PlaceHebrew, "place", a.Place, where);
Window(where, a.From, a.To, toRequired: true);
if (!(a.Lon >= -180 && a.Lon <= 180 && a.Lat >= -90 && a.Lat <= 90)) throw new InvalidDataException($"{where} has bad coordinates");
if (a.Precision != null && a.Precision != "month") throw new InvalidDataException($"{where} precision must be 'month' or left out");
@@ -352,6 +397,26 @@ namespace Statecraft.Game.Map.Units
if (u.NameHeSources.Count == 0) throw new InvalidDataException($"{at} name_he_sources is empty");
}
+ /// <summary>A Hebrew card text (#558) beside its English <paramref name="field"/>: never without the English (a
+ /// Hebrew text adds no line the English row lacks), in Hebrew letters, with its sources, and agent-checked or no
+ /// review line; a key that is present but blank, and sources or a review flag without the text, are errors.</summary>
+ static void ValidateHebrewText(UnitHebrewText h, string field, string? english, string at)
+ {
+ var he = field + "_he";
+ if (h.ReviewGiven && h.Review != "agent-checked")
+ throw new InvalidDataException($"{at} {he}_review must be agent-checked, or left out once reviewed");
+ if (!h.TextGiven)
+ {
+ if (h.SourcesGiven) throw new InvalidDataException($"{at} {he}_sources is set without {he}");
+ if (h.ReviewGiven) throw new InvalidDataException($"{at} {he}_review is set without {he}");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(h.Text)) throw new InvalidDataException($"{at} {he} is blank (give the Hebrew, or leave the key out)");
+ if (string.IsNullOrWhiteSpace(english)) throw new InvalidDataException($"{at} {he} is set without {field}");
+ if (!Regex.IsMatch(h.Text, "[א-ת]")) throw new InvalidDataException($"{at} {he} must contain Hebrew letters");
+ if (h.Sources == null || h.Sources.Count == 0) throw new InvalidDataException($"{at} {he}_sources is empty");
+ }
+
static void Window(string where, string? from, string? to, bool toRequired)
{
if (toRequired && string.IsNullOrEmpty(to)) throw new InvalidDataException($"{where}: to is empty (give the window's end)");
diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.cs
index fc13aad14..72d070078 100644
--- a/unity/Assets/Scripts/UI/UnitCard.cs
+++ b/unity/Assets/Scripts/UI/UnitCard.cs
@@ -20,16 +20,21 @@ namespace Statecraft.Game.UI
public static UnitCard For(PlacedToken placed, GameState state, UiText text)
{
var t = placed.Token; var u = t.Unit; var a = t.Anchor;
+ bool hebrew = text["ui.lang"] == UiLanguage.Hebrew;
+ // In Hebrew each prose text shows its Hebrew counterpart where the row has one, else its English (#558).
+ string Local(string english, string? he) => hebrew && !string.IsNullOrEmpty(he) ? he! : english;
var lines = new List<string>();
if (u.Service == UnitData.Air)
{
var aircraft = text[t.ArtType == UnitShowcase.SpitfireType ? "unit.aircraft.spitfire" : "unit.aircraft.s199"];
lines.Add(text.Format(t.Flying ? "unit.flying" : "unit.parked", aircraft));
}
- lines.Add(string.IsNullOrWhiteSpace(a.Since) ? text.Format("unit.position_plain", a.Place) : text.Format("unit.position", a.Place, a.Since!));
+ var place = Local(a.Place, a.PlaceHe);
+ lines.Add(string.IsNullOrWhiteSpace(a.Since) ? text.Format("unit.position_plain", place) : text.Format("unit.position", place, a.Since!));
if (!string.IsNullOrEmpty(u.Formed)) lines.Add(text.Format("unit.formed", u.Formed!));
- if (!string.IsNullOrEmpty(u.FirstCommander)) lines.Add(text.Format("unit.commander", u.FirstCommander!));
- lines.Add(u.Sector);
+ // The English decides whether the line exists: a Hebrew commander never adds one (owner, #558).
+ if (!string.IsNullOrEmpty(u.FirstCommander)) lines.Add(text.Format("unit.commander", Local(u.FirstCommander!, u.FirstCommanderHe)));
+ lines.Add(Local(u.Sector, u.SectorHe));
var hosts = u.AllSources().Select(s => new Uri(s.Url).Host).Distinct(StringComparer.Ordinal).OrderBy(h => h, StringComparer.Ordinal);
return new UnitCard
{
diff --git a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
index 0d8d9a0ad..122fe9c60 100644
--- a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
@@ -841,6 +841,103 @@ public class UnitsInPlayTests
Assert.AreEqual(u.Name, UnitCard.For(placed, state, he).Title);
}
+ // ---- Optional Hebrew card prose (#558) -------------------------------------------------------------------------
+ // Test-only fixtures: the Hebrew below is placeholder text ("test place", "test commander", "test sector"), not a
+ // translation of any real row and not a historical source. content/map/units_1948.yaml carries none of these keys yet.
+
+ const string HeSource = "[{url: 'https://he.example.org/a', checked: '2026-10-19'}]";
+ const string PlaceHe = "place_he: מקום בדיקה, place_he_sources: " + HeSource + ", place_he_review: agent-checked, ";
+ const string CommanderHe = "first_commander_he: מפקד בדיקה, first_commander_he_sources: " + HeSource + ", first_commander_he_review: agent-checked, ";
+ const string SectorHe = "sector_he: גזרת בדיקה, sector_he_sources: " + HeSource + ", sector_he_review: agent-checked, ";
+
+ /// <summary>A one-unit file with the three English prose fields, an anchor whose only source is Wikipedia, and the
+ /// given Hebrew counterparts (any of <see cref="PlaceHe"/>, <see cref="CommanderHe"/>, <see cref="SectorHe"/>).</summary>
+ static UnitEntry ProseUnit(string placeHe = "", string unitHe = "", string commander = "first_commander: Test Commander, ")
+ => UnitData.Parse("units:\n- {id: a, name: A, number: '1', service: army, side: israel, " + commander + unitHe
+ + "sector: Test sector, status: draft, wikipedia_only: true, anchors: [{place: Test Place, " + placeHe
+ + "lon: 34.8, lat: 32.0, from: '1948-05-15', to: '1948-06-01', end_basis: source, end_note: n, "
+ + "sources: [{url: 'https://en.wikipedia.org/wiki/X', checked: '2026-10-11'}]}]}", "u.yaml")[0];
+
+ static UnitCard ProseCard(UnitEntry u, UiText text)
+ => UnitCard.For(new PlacedToken(new UnitToken(u, u.Anchors[0], 0, "", false), default), StateAt(C.Rules.Start, 5, 0.8), text);
+
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+
+ /// <summary>#558: the three Hebrew counterparts load beside the English and show in the Hebrew card only; the English
+ /// card is the same as for the row without them, and their sources join the footer without clearing the draft note.</summary>
+ [Test]
+ public void TheHebrewProseShowsInTheHebrewCardAndTheEnglishCardIsUnchanged()
+ {
+ var u = ProseUnit(PlaceHe, CommanderHe + SectorHe);
+ Assert.AreEqual(("מקום בדיקה", "מפקד בדיקה", "גזרת בדיקה"), (u.Anchors[0].PlaceHe, u.FirstCommanderHe, u.SectorHe));
+ Assert.AreEqual(("agent-checked", "agent-checked", "agent-checked"), (u.Anchors[0].PlaceHeReview, u.FirstCommanderHeReview, u.SectorHeReview));
+ var he = ProseCard(u, He);
+ Assert.AreEqual("מיקום: מקום בדיקה\nמפקד ראשון: מפקד בדיקה\nגזרת בדיקה", he.Body);
+ var english = ProseCard(u, Text);
+ var plain = ProseCard(ProseUnit(), Text);
+ Assert.AreEqual((plain.Title, plain.Subtitle, plain.Body, plain.Note), (english.Title, english.Subtitle, english.Body, english.Note));
+ Assert.AreEqual("At Test Place\nFirst commander: Test Commander\nTest sector", english.Body);
+ StringAssert.Contains("he.example.org", he.Footer, "the Hebrew text's sources are listed, as name_he's are");
+ StringAssert.Contains("he.example.org", english.Footer, "in both languages, as name_he's are");
+ Assert.AreEqual(He["unit.draft_wikipedia"], he.Note, "a Hebrew text's source does not check a fact (#902)");
+ Assert.IsTrue(UnitData.IsWikipediaOnly(u));
+ }
+
+ /// <summary>#558: each Hebrew field falls back to its own English value when it is left out, whatever the other two do.
+ /// (The Hebrew strings wrap an English value in left-to-right marks, U+200E, as they do on main.)</summary>
+ [TestCase("", CommanderHe + SectorHe, "מיקום: \u200ETest Place\u200E\nמפקד ראשון: מפקד בדיקה\nגזרת בדיקה")]
+ [TestCase(PlaceHe, SectorHe, "מיקום: מקום בדיקה\nמפקד ראשון: \u200ETest Commander\u200E\nגזרת בדיקה")]
+ [TestCase(PlaceHe, CommanderHe, "מיקום: מקום בדיקה\nמפקד ראשון: מפקד בדיקה\nTest sector")]
+ [TestCase("", "", "מיקום: \u200ETest Place\u200E\nמפקד ראשון: \u200ETest Commander\u200E\nTest sector")]
+ public void EachHebrewFieldFallsBackToItsOwnEnglish(string placeHe, string unitHe, string body)
+ {
+ Assert.AreEqual(body, ProseCard(ProseUnit(placeHe, unitHe), He).Body);
+ }
+
+ /// <summary>#558 (owner, 19 October 2026): a Hebrew commander never adds the line the English row does not have.</summary>
+ [Test]
+ public void AHebrewCommanderWithoutTheEnglishAddsNoLine()
+ {
+ var u = ProseUnit(commander: "");
+ u.FirstCommanderHe = "מפקד בדיקה"; // past the loader, which refuses this row (BadHebrewProseNamesTheProblem)
+ Assert.AreEqual("מיקום: \u200ETest Place\u200E\nTest sector", ProseCard(u, He).Body);
+ }
+
+ // hidden: the rows with "anchors: []" reach the source checks, which run after the anchors'.
+ const string ProseRow = "units:\n- {id: a, name: A, number: '1', service: army, side: israel, sector: s, status: draft, wikipedia_only: true, hidden: h, ";
+ const string ProseAnchor = "anchors: [{place: P, lon: 34.8, lat: 32.0, from: '1948-05-15', to: '1948-06-01', end_basis: source, end_note: n, sources: [{url: 'https://x.org', checked: '2026-10-11'}], ";
+
+ // Orphans: a Hebrew text, its sources or its review flag without what it belongs to.
+ [TestCase(ProseRow + CommanderHe + "anchors: []}", "first_commander_he is set without first_commander")]
+ [TestCase(ProseRow + "first_commander: C, first_commander_he_sources: " + HeSource + ", anchors: []}", "first_commander_he_sources is set without first_commander_he")]
+ [TestCase(ProseRow + "first_commander: C, first_commander_he_review: agent-checked, anchors: []}", "first_commander_he_review is set without first_commander_he")]
+ [TestCase(ProseRow + "sector_he_sources: " + HeSource + ", anchors: []}", "sector_he_sources is set without sector_he")]
+ [TestCase(ProseRow + "sector_he_review: agent-checked, anchors: []}", "sector_he_review is set without sector_he")]
+ [TestCase(ProseRow + ProseAnchor + "place_he_sources: " + HeSource + "}]}", "place_he_sources is set without place_he")]
+ [TestCase(ProseRow + ProseAnchor + "place_he_review: agent-checked}]}", "place_he_review is set without place_he")]
+ // Present but blank: an empty or null key is an error, never read as "left out".
+ [TestCase(ProseRow + "sector_he: '', anchors: []}", "sector_he is blank")]
+ [TestCase(ProseRow + "sector_he: ~, anchors: []}", "sector_he is blank")]
+ [TestCase(ProseRow + ProseAnchor + "place_he: ' '}]}", "place_he is blank")]
+ [TestCase(ProseRow + "first_commander: C, first_commander_he: מפקד, first_commander_he_sources: ~, anchors: []}", "first_commander_he_sources is empty")]
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he_sources: [], anchors: []}", "sector_he_sources is empty")]
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he_sources: " + HeSource + ", sector_he_review: '', anchors: []}", "sector_he_review must be agent-checked")]
+ [TestCase(ProseRow + "sector_he_review: ~, anchors: []}", "sector_he_review must be agent-checked")]
+ // Invalid metadata and text.
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he_sources: " + HeSource + ", sector_he_review: reviewed, anchors: []}", "sector_he_review must be agent-checked")]
+ [TestCase(ProseRow + "sector_he: Sector, sector_he_sources: " + HeSource + ", anchors: []}", "sector_he must contain Hebrew letters")]
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he_sources: [{url: 'http://x.org', checked: '2026-10-19'}], anchors: []}", "without an https url")]
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he_sources: [{url: 'https://x.org'}], anchors: []}", "source https://x.org: checked")]
+ // Only the three meanings: other Hebrew keys are unknown, and a key twice is refused.
+ [TestCase(ProseRow + "formed: '1948', formed_he: '1948', anchors: []}", "Property 'formed_he' not found")]
+ [TestCase(ProseRow + "sector_he: גזרה, sector_he: גזרה, anchors: []}", "duplicate key sector_he")]
+ public void BadHebrewProseNamesTheProblem(string yaml, string expected)
+ {
+ var e = Assert.Throws<InvalidDataException>(() => UnitData.Parse(yaml, "u.yaml"));
+ StringAssert.StartsWith("u.yaml:", e.Message);
+ StringAssert.Contains(expected, e.Message);
+ }
+
/// <summary>Review I1: "since" only from a sourced start; never the game's first day.</summary>
[Test]
public void TheCardGivesASinceOnlyFromASourcedStart()