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 map layer label formats through UiText.Format, so Hebrew marks its values (refs #596, #585) (#619)

Eyal Golan7a4617edd35c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5215e376a..459676712 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -490,6 +490,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
sources disagree) instead of "the first four arrived on 20 May"; the Spitfire note names the two sources for the
27 September 1948 landing of three aircraft at Ramat David. Sources added, checked 15 October 2026. Notes only: no
date changes, map-only file outside the content hash, no golden moves.
+- Hebrew UI preview (refs #596, #585): the map layer label (`MapRegions.Label`) formats through `UiText.Format`, so the
+ values its Hebrew patterns insert (a front's English name, the "1950 modus vivendi" note) get the same left-to-right
+ marks as the rest of the Hebrew UI and keep their own order. English is unchanged.
- Hebrew UI preview (refs #543, #193): a value inserted into a Hebrew line keeps its own order. `UiText.Format` puts a
left-to-right mark (U+200E) on each side of each value with no Hebrew in it that it inserts into a Hebrew template, so
negative foreign currency reads "-$4.2m" (not "$4.2m-") and "15 May 1948" in the Why screen's turn line stays one
diff --git a/unity/Assets/Scripts/Map/MapRegions.cs b/unity/Assets/Scripts/Map/MapRegions.cs
index 747538fcd..ed6c25928 100644
--- a/unity/Assets/Scripts/Map/MapRegions.cs
+++ b/unity/Assets/Scripts/Map/MapRegions.cs
@@ -133,23 +133,24 @@ namespace Statecraft.Game.Map
}
/// <summary>The map label: the sub-district layer's, and once a front's line is shown, those fronts and the fronts
- /// still without line data. <paramref name="withLines"/> formats {0} label, {1} armistice label, {2} front names;
- /// <paramref name="noData"/> formats {0} a front's name, appended for each front without data; <paramref name="low"/>
- /// formats {0} a low-accuracy front's name (Jordan, from a low-resolution scan); <paramref name="note"/> formats {0} a
- /// front's name and {1} the notes of its items shown (the 1950 modus vivendi).</summary>
- public string Label(DateTime date, string withLines, string noData, string low = "{0}", string note = "{0} ({1})")
+ /// still without line data. <paramref name="format"/> formats a UI string by key, as UiText.Format does, so a value
+ /// inserted into a Hebrew pattern is put between left-to-right marks (#585, #596): map.layer_with_armistice ({0}
+ /// label, {1} armistice label, {2} front names); map.layer_front_no_data ({0} a front's name, appended for each front
+ /// without data); map.layer_front_low ({0} a low-accuracy front's name: Jordan, from a low-resolution scan);
+ /// map.layer_front_note ({0} a front's name and {1} the notes of its items shown: the 1950 modus vivendi).</summary>
+ public string Label(DateTime date, Func<string, object[], string> format)
{
var (on, none) = FrontsOn(date);
if (on.Count == 0 || Armistice == null) return Subdistricts.Label;
string Name(Armistice1949.Front f)
{
- var n = f.LowAccuracy ? string.Format(CultureInfo.InvariantCulture, low, f.Name) : f.Name;
+ var n = f.LowAccuracy ? format("map.layer_front_low", new object[] { f.Name }) : f.Name;
var notes = Armistice.Zones.Concat(Armistice.Lines).Where(x => x.Front == f && InForce(x, date) && x.LabelNote != "")
.Select(x => x.LabelNote).Distinct().ToList();
- return notes.Count == 0 ? n : string.Format(CultureInfo.InvariantCulture, note, n, string.Join(", ", notes));
+ return notes.Count == 0 ? n : format("map.layer_front_note", new object[] { n, string.Join(", ", notes) });
}
- var text = string.Format(CultureInfo.InvariantCulture, withLines, Subdistricts.Label, Armistice.Label, string.Join(", ", on.Select(Name)));
- foreach (var f in none) text += string.Format(CultureInfo.InvariantCulture, noData, f.Name);
+ var text = format("map.layer_with_armistice", new object[] { Subdistricts.Label, Armistice.Label, string.Join(", ", on.Select(Name)) });
+ foreach (var f in none) text += format("map.layer_front_no_data", new object[] { f.Name });
return text;
}
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 318000b78..8bf65236a 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -228,8 +228,7 @@ namespace Statecraft.Game.UI
{
regions.Apply(bridge.State.Date);
layerLabel.text = regions.ControlLabel(bridge.State.Date, k => text[k])
- ?? regions.Label(bridge.State.Date, text["map.layer_with_armistice"], text["map.layer_front_no_data"],
- text["map.layer_front_low"], text["map.layer_front_note"]);
+ ?? regions.Label(bridge.State.Date, text.Format);
layerLabel.style.display = regions.Shown ? DisplayStyle.Flex : DisplayStyle.None;
};
onDate();
diff --git a/unity/Assets/Tests/EditMode/ArmisticeTests.cs b/unity/Assets/Tests/EditMode/ArmisticeTests.cs
index d9046efaa..869b676ef 100644
--- a/unity/Assets/Tests/EditMode/ArmisticeTests.cs
+++ b/unity/Assets/Tests/EditMode/ArmisticeTests.cs
@@ -135,8 +135,7 @@ public class ArmisticeTests
static string L(MapRegions m, DateTime d)
{
- var t = Text;
- return m.Label(d, t["map.layer_with_armistice"], t["map.layer_front_no_data"], t["map.layer_front_low"], t["map.layer_front_note"]);
+ return m.Label(d, Text.Format);
}
[Test]
@@ -157,6 +156,43 @@ public class ArmisticeTests
StringAssert.Contains("Jordan: Mandate sub-districts, no armistice line data", L(noJordan, new DateTime(1949, 8, 1)));
}
+ static UiText HeText => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+
+ static string LHe(MapRegions m, DateTime d)
+ {
+ return m.Label(d, HeText.Format);
+ }
+
+ /// <summary>The Hebrew map label (#596): a value with no Hebrew in it that a Hebrew pattern inserts (the 1950 note,
+ /// a front's English name) is put between left-to-right marks as UiText.Format does (#585), so the note "1950 modus
+ /// vivendi" keeps its year before its words in the right-to-left line.</summary>
+ [Test]
+ public void TheHebrewLabelMarksTheValuesItsHebrewPatternsInsert()
+ {
+ const string Lrm = "‎";
+ var sub = Subdistricts1948.Parse(SubText.Replace("label: \"Mandate sub-districts, 1947\"", "label: \"נפות המנדט, 1947\""));
+ var arm = ArmText.Replace("label: \"1949 armistice lines\"", "label: \"קווי שביתת הנשק, 1949\"");
+ // The fronts' names as they are today (English), inside the Hebrew line.
+ var m = new MapRegions(sub, Armistice1949.Parse(arm));
+ Assert.AreEqual("נפות המנדט, 1947", LHe(m, Start));
+ var en = LHe(m, new DateTime(1950, 3, 1));
+ Assert.AreEqual("נפות המנדט, 1947 · קווי שביתת הנשק, 1949: " + Lrm + "Egypt" + Lrm + " (וגם " + Lrm + "1950 modus vivendi" + Lrm + "), Lebanon, "
+ + Lrm + "Jordan" + Lrm + " (דיוק נמוך), Syria", en);
+ Assert.IsTrue(UiDirection.RightToLeft(en), en);
+ // Hebrew names: a Hebrew value is left alone, the note is still marked.
+ var heNames = new MapRegions(sub, Armistice1949.Parse(arm.Replace("name: \"Egypt\"", "name: \"מצרים\"").Replace("name: \"Jordan\"", "name: \"ירדן\"")));
+ StringAssert.Contains(": מצרים (וגם " + Lrm + "1950 modus vivendi" + Lrm + "), Lebanon, ירדן (דיוק נמוך), Syria", LHe(heNames, new DateTime(1950, 3, 1)));
+ // A front without line data: its name is marked in the Hebrew note that says so.
+ var noJordan = new MapRegions(sub, Armistice1949.Parse(
+ "layer: x\nlabel: קווי שביתת הנשק, 1949\nfronts:\n" +
+ " - { key: egypt, name: Egypt, agreement: A, signed: 1949-02-24, shown_from: 1949-02-24, note: '' }\n" +
+ " - { key: jordan, name: Jordan, agreement: B, signed: 1949-04-03, shown_from: null, note: 'no line data' }\n"));
+ StringAssert.EndsWith(" · " + Lrm + "Jordan" + Lrm + ": נפות המנדט, אין נתוני קו שביתת נשק", LHe(noJordan, new DateTime(1949, 8, 1)));
+ // Taking the marks out gives string.Format's text back.
+ Assert.AreEqual(string.Format(System.Globalization.CultureInfo.InvariantCulture, HeText["map.layer_with_armistice"], "נפות המנדט, 1947", "קווי שביתת הנשק, 1949",
+ "Egypt (וגם 1950 modus vivendi), Lebanon, Jordan (דיוק נמוך), Syria"), en.Replace(Lrm, ""));
+ }
+
[Test]
public void TheInfoPanelNamesTheZoneOrLineAndTheAgreement()
{