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.

Hebrew unit card: dates name their month in Hebrew (refs #1292) (#1298)

Beri7632210372e5
diff --git a/changelog.d/unity-hebrew-unit-card-dates-1292.md b/changelog.d/unity-hebrew-unit-card-dates-1292.md
new file mode 100644
index 000000000..bcb22790b
--- /dev/null
+++ b/changelog.d/unity-hebrew-unit-card-dates-1292.md
@@ -0,0 +1,4 @@
+- Hebrew UI: a unit card's formed and since dates name their month in Hebrew ("הוקמה: מרץ 1948"), through the
+ existing date strings, when the date is a plain day or month; a date written as prose ("late 1947") keeps its
+ English (refs #1292). The card's place, first commander and sector still show their English until the rows get
+ `place_he`, `first_commander_he` and `sector_he` (#558): no row has them yet.
diff --git a/unity/Assets/Scripts/UI/UnitCard.cs b/unity/Assets/Scripts/UI/UnitCard.cs
index 16aecfa56..06e8c68b7 100644
--- a/unity/Assets/Scripts/UI/UnitCard.cs
+++ b/unity/Assets/Scripts/UI/UnitCard.cs
@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using Statecraft.Game.Map.Units;
using Statecraft.Sim;
@@ -34,6 +35,16 @@ namespace Statecraft.Game.UI
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;
+ // In Hebrew a formed or since date that is a plain day or month ("24 May 1948", "March 1948") names its month
+ // through the date strings, as the event cards' dates do (#1292); a date in prose ("late 1947") keeps its English.
+ string When(string english)
+ {
+ if (!hebrew) return english;
+ if (DateTime.TryParseExact(english, "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var d))
+ return text.Format("date.day_month_year", d.Day, text["date.month_" + d.Month], d.Year);
+ return DateTime.TryParseExact(english, "MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var m)
+ ? text.Format("date.month_year", text["date.month_" + m.Month], m.Year) : english;
+ }
var lines = new List<string>();
if (u.Service == UnitData.Air)
{
@@ -45,9 +56,9 @@ namespace Statecraft.Game.UI
if (sourced)
{
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!));
+ lines.Add(string.IsNullOrWhiteSpace(a.Since) ? text.Format("unit.position_plain", place) : text.Format("unit.position", place, When(a.Since!)));
}
- if (!string.IsNullOrEmpty(u.Formed)) lines.Add(text.Format("unit.formed", u.Formed!));
+ if (!string.IsNullOrEmpty(u.Formed)) lines.Add(text.Format("unit.formed", When(u.Formed!)));
// 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));
diff --git a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
index 588bc7f30..b76fba0d3 100644
--- a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
@@ -929,6 +929,31 @@ public class UnitsInPlayTests
Assert.AreEqual("מיקום: \u200ETest Place\u200E\nTest sector", ProseCard(u, He).Body);
}
+ /// <summary>#1292: the Hebrew card names a formed or since date's month in Hebrew (date.month_*), as the event cards'
+ /// dates do; a date in prose keeps its English (no row has a Hebrew one), and the English card is unchanged.</summary>
+ [TestCase("March 1948", "24 May 1948", "הוקמה: מרץ 1948", "מאז ‎24‎ במאי ‎1948‎")]
+ [TestCase("Late 1947", "the first half of May 1948", "הוקמה: ‎Late 1947‎", "מאז ‎the first half of May 1948‎")]
+ public void TheHebrewCardNamesTheMonthsOfItsDatesInHebrew(string formed, string since, string formedLine, string sinceText)
+ {
+ var u = ProseUnit();
+ u.Formed = formed; u.Anchors[0].Since = since;
+ var body = ProseCard(u, He).Body;
+ StringAssert.Contains(formedLine, body);
+ StringAssert.Contains(sinceText, body);
+ StringAssert.Contains($"At Test Place since {since}\nFormed {formed}\n", ProseCard(u, Text).Body);
+ }
+
+ /// <summary>#1292, the issue's example: the Negev Brigade's Hebrew card has no English month name left.</summary>
+ [Test]
+ public void TheNegevBrigadesHebrewCardHasNoEnglishMonth()
+ {
+ var u = Units.Single(x => x.Id == "negev");
+ var body = ProseCard(u, He).Body;
+ StringAssert.Contains("הוקמה: מרץ 1948", body);
+ StringAssert.Contains("מאז מרץ 1948", body);
+ StringAssert.DoesNotContain("March", 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'}], ";