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 Hebrew info panel names its towns and 1948 localities in Hebrew (refs #899) (#925)

Beri8696f6106129
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6850c85b..2631cde73 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
target follows with its pool (#781).
### Fixed
+- Under `?lang=he` the hex info panel names its towns and 1948 localities in Hebrew: the title, the "Settlements"
+ line and the 1948 name in the localities line read the row's `name_he`, and the English name where a row has none
+ (13 of 271 localities). Where the Hebrew 1948 and today names are one word (48 rows that would otherwise show
+ a today name), the "today" part is left out. English is unchanged (refs #899).
- In the Hebrew UI the info panel's build line is a date label with no verb, "{0} – תאריך הקמה: {1}" (refs #701), since
the fixed masculine "נבנה" read wrong for a feminine name ("מעברה נבנה"). Beri approved the wording as a native speaker.
English is unchanged.
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 4517d14be..35db66d89 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -44,9 +44,9 @@ namespace Statecraft.Game.UI
/// agreement (null: no region line).</param>
/// <param name="townHex">The hex each settlement's own point lies in, by id (<see cref="TownHex"/>; null: no note on
/// a town drawn from the water hex next door, #204).</param>
- /// <param name="townNamesHe">Each settlement's Hebrew name (name_he), by id: the Hebrew UI names the town in that
- /// note with it, or with the English name where it has none (null: English names). The "Settlements" line keeps the
- /// English names (#558).</param>
+ /// <param name="townNamesHe">Each settlement's Hebrew name (name_he), by id: the Hebrew UI names the town with it in the
+ /// title, the "Settlements" line and that note (#899), or with the English name where it has none (null: English
+ /// names).</param>
public InfoPanelPresenter(VisualElement root, SimBridge bridge, UiText text, IReadOnlyDictionary<string, string> settlementNames,
ScreenNav? nav = null, System.Func<PlacedToken?>? selectedUnit = null, MapRegions? regions = null,
System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt = null,
@@ -171,13 +171,19 @@ namespace Statecraft.Game.UI
side == Control1948.Side.Arab && holder != null && p.Fronts.Contains(holder);
/// <summary>The "1948 localities" line for a hex: each place's 1948 name, with today's name where Localities.TodayName
- /// allows ("Beisan (today: Beit She'an)"); empty for a hex with none.</summary>
+ /// allows ("Beisan (today: Beit She'an)"); empty for a hex with none. The Hebrew UI names a place by its name_he, by the
+ /// English name where it has none (#899), and drops a today name that is the same Hebrew word (Umm el Fahm and Umm al-Fahm
+ /// are both one name in Hebrew: 48 rows that would otherwise show a today name).</summary>
public static string LocalitiesText(UiText text, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place> places)
{
if (places.Count == 0) return "";
bool hebrew = text["ui.lang"] == "he";
- var names = places.Select(p => Statecraft.Game.Map.Kits.Localities.TodayName(p, hebrew) is string today
- ? text.Format("info.locality_today", p.Settlement.Name, today) : p.Settlement.Name);
+ var names = places.Select(p =>
+ {
+ var name = hebrew && !string.IsNullOrWhiteSpace(p.NameHe) ? p.NameHe! : p.Settlement.Name;
+ return Statecraft.Game.Map.Kits.Localities.TodayName(p, hebrew) is string today && today != name
+ ? text.Format("info.locality_today", name, today) : name;
+ });
return text.Format("info.localities", string.Join(", ", names));
}
@@ -190,6 +196,11 @@ namespace Statecraft.Game.UI
return id => at[id];
}
+ /// <summary>A settlement's name in the UI's language: its name_he under Hebrew, the English name where it has none.</summary>
+ string TownName(string id) =>
+ text["ui.lang"] == UiLanguage.Hebrew && townNamesHe != null && townNamesHe.TryGetValue(id, out var he)
+ && !string.IsNullOrWhiteSpace(he) ? he : settlementNames[id];
+
void ShowLocalities(string line)
{
localitiesLabel.text = line;
@@ -236,7 +247,7 @@ namespace Statecraft.Game.UI
var (q, r) = Selected.Value;
var hex = c.HexAt(q, r);
ShowThumb(hex?.Biome);
- var owned = c.SettlementHexes.Where(x => x.Q == q && x.R == r).Select(x => settlementNames[x.Id]).ToList(); // strict: every settlement hex has a name (final review M4)
+ var owned = c.SettlementHexes.Where(x => x.Q == q && x.R == r).Select(x => TownName(x.Id)).ToList(); // strict: every settlement hex has a name (final review M4)
title.text = owned.Count > 0 ? owned[0] : hex == null ? text["info.off_map"] : text["info.biome." + hex.Biome];
subtitle.text = hex == null ? "" : text.Format("info.hex", text["info.biome." + hex.Biome], hex.ElevM); // no debug coordinates in player text (playtest 2, P2-6)
// The armistice zone in force, else the sub-district on 15 May 1948, and any armistice line in force through the
@@ -247,12 +258,7 @@ namespace Statecraft.Game.UI
// so, so this hex's elevation does not read as the town's (#204).
if (townHex != null)
foreach (var town in c.SettlementHexes.Where(x => x.Q == q && x.R == r && townHex(x.Id) != (q, r)))
- {
- // The Hebrew UI names the town in Hebrew (name_he), and in English where it has no Hebrew name.
- var name = text["ui.lang"] == UiLanguage.Hebrew && townNamesHe != null && townNamesHe.TryGetValue(town.Id, out var he)
- && !string.IsNullOrWhiteSpace(he) ? he : settlementNames[town.Id];
- settlements.text += "\n" + text.Format("info.town_in_water", name);
- }
+ settlements.text += "\n" + text.Format("info.town_in_water", TownName(town.Id));
ShowLocalities(localitiesAt == null ? "" : LocalitiesText(text, localitiesAt(q, r)));
var here = MapActions.At(s, q, r);
var queued = bridge.QueuedLike(new MapAction(MapActions.Housing, q, r)) as MapAction;
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index d5b41774d..8ca1c5ca7 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -235,6 +235,30 @@ public class InfoPanelLayoutTests
}
}
+ /// <summary>#899: under Hebrew the panel's title and its "Settlements" line name the hex's towns by their name_he (all 25
+ /// settlement rows have one); under English both stay the English names.</summary>
+ [Test]
+ public void InHebrewTheTitleAndTheSettlementsLineAreTheTownsHebrewNames()
+ {
+ var namesHe = SettlementPlacer.Parse(MapFile(SettlementPlacer.DefaultFileName)).ToDictionary(t => t.Id, t => t.NameHe);
+ var names = Names();
+ var lod = C.SettlementHexes.Single(s => s.Id == "lod");
+ var owned = C.SettlementHexes.Where(s => s.Q == lod.Q && s.R == lod.R).Select(s => s.Id).ToList();
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ Assert.AreEqual("לוד", namesHe["lod"]);
+ foreach (var (text, name) in new (UiText, System.Func<string, string>)[] { (Text, id => names[id]), (he, id => namesHe[id]!) })
+ {
+ using var ui = new UiTestKit();
+ var info = new InfoPanelPresenter(ui.Root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text), text, names,
+ townNamesHe: namesHe);
+ info.Show(lod.Q, lod.R);
+ Assert.AreEqual(name(owned[0]), ui.Q<Label>("info-title").text, $"{text["ui.lang"]}: the title");
+ Assert.AreEqual(text.Format("info.owned", string.Join(", ", owned.Select(name))), ui.Q<Label>("info-settlements").text,
+ $"{text["ui.lang"]}: the Settlements line");
+ info.Dispose();
+ }
+ }
+
/// <summary>#204 drift guard: the note says "water hex" because a town's own hex (TownHex) differs from its drawn hex
/// only where hexgrid.settlement_hex moved it off a water hex. Every such town's own hex is on the map and not land, and
/// there is at least one (Tiberias), so the guard cannot pass on an empty list.</summary>
diff --git a/unity/Assets/Tests/EditMode/LocalityNameTests.cs b/unity/Assets/Tests/EditMode/LocalityNameTests.cs
index cac6fd1ca..8d92e03d3 100644
--- a/unity/Assets/Tests/EditMode/LocalityNameTests.cs
+++ b/unity/Assets/Tests/EditMode/LocalityNameTests.cs
@@ -101,12 +101,29 @@ public class LocalityNameTests
[Test]
public void TheHebrewPanelUsesHebrewTodayNames()
{
- var p = map.Localities.First(x => Localities.TodayName(x, true) != null && !string.IsNullOrEmpty(x.TodayHe));
+ var p = map.Localities.First(x => Localities.TodayName(x, true) != null && !string.IsNullOrEmpty(x.TodayHe) && x.TodayHe != x.NameHe); // #899 drops a today name equal to the Hebrew 1948 name
var text = InfoPanelPresenter.LocalitiesText(He, new[] { p });
StringAssert.Contains(p.TodayHe!, text);
Assert.AreEqual("", InfoPanelPresenter.LocalitiesText(He, new Localities.Place[0]));
}
+ /// <summary>#899: under Hebrew each 1948 locality is named by its name_he (Beisan is ביסאן), and by the English name where the
+ /// row has none (Na'ana). Where the Hebrew 1948 name and the Hebrew today name are one word (Umm el Fahm and Umm al-Fahm
+ /// are both אום אל-פחם: 48 rows that would otherwise show a today name), the "today" part would repeat the name, so it is left out. English is unchanged.</summary>
+ [Test]
+ public void TheHebrewPanelNamesEach1948LocalityByItsHebrewName()
+ {
+ var by = map.Localities.ToDictionary(p => p.Settlement.Id);
+ var (beisan, naana, fahm) = (by["beit_shean"], by["naana"], by["umm_al_fahm"]);
+ Assert.IsNull(naana.NameHe, "Na'ana has no Hebrew name");
+ Assert.AreEqual(fahm.NameHe, fahm.TodayHe, "one Hebrew word for 1948 and today");
+ Assert.AreEqual("יישובים ב-1948: ביסאן (היום: בית שאן)", InfoPanelPresenter.LocalitiesText(He, new[] { beisan }));
+ Assert.AreEqual(He.Format("info.localities", "Na'ana"), InfoPanelPresenter.LocalitiesText(He, new[] { naana })); // Format marks the Latin run
+ Assert.AreEqual("יישובים ב-1948: אום אל-פחם", InfoPanelPresenter.LocalitiesText(He, new[] { fahm }));
+ Assert.AreEqual("1948 localities: Beisan (today: Beit She'an), Na'ana, Umm el Fahm (today: Umm al-Fahm)",
+ InfoPanelPresenter.LocalitiesText(En, new[] { beisan, naana, fahm }));
+ }
+
/// <summary>The list wraps inside the info panel: the hex with the most localities (seven around Tel Aviv) at a desktop,
/// a laptop and a phone size, on the real Game.uxml and PanelSettings. Unwrapped, the line ran far past the panel.</summary>
[UnityTest]