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.

End screen: each Hebrew date stays whole in its line (Fixes #2060) (#2062)

Berida26b1bb9f72
diff --git a/changelog.d/2060.md b/changelog.d/2060.md
new file mode 100644
index 000000000..4a69168da
--- /dev/null
+++ b/changelog.d/2060.md
@@ -0,0 +1,4 @@
+### Fixed
+- The Hebrew end screen keeps each date in an objective line and the population line whole, "20 בספטמבר 1949" right
+ after "ב־" (#2060): the date now sits between direction marks (RLE/PDF), so a line laid out left to right no longer
+ pulls its day onto the next word and its year to the far end. English is unchanged.
diff --git a/unity/Assets/Scripts/UI/EndScreenPresenter.cs b/unity/Assets/Scripts/UI/EndScreenPresenter.cs
index fe7900bd6..9e57ef501 100644
--- a/unity/Assets/Scripts/UI/EndScreenPresenter.cs
+++ b/unity/Assets/Scripts/UI/EndScreenPresenter.cs
@@ -74,7 +74,15 @@ namespace Statecraft.Game.UI
public static IReadOnlyList<(string Name, string Text)> Lines(Content c, GameState s, UiText t)
{
var r = EndReport.For(c, s);
- string Date(DateTime d) => t.Format("date.day_month_year", d.Day, t["date.month_" + d.Month], d.Year);
+ // A Hebrew date goes between RLE and PDF (#2060): left bare in a line laid out left to right, the bidi rules pull
+ // its day onto the next word and its year to the line's far end. Not RLI/PDI: UI Toolkit's advanced text generator
+ // still drew the date in that order with the isolates (measured on 6000.3), the embedding keeps it whole.
+ // English dates are left as they are.
+ string Date(DateTime d)
+ {
+ var value = t.Format("date.day_month_year", d.Day, t["date.month_" + d.Month], d.Year);
+ return UiDirection.HasRightToLeft(value) ? "\u202B" + value + "\u202C" : value;
+ }
// The GDD loop ends only as the MVP end or a defeat (R-END-002, R-END-005); the legacy codes get the generic line.
var outcome = "end.outcome." + r.Outcome;
var lines = new List<(string, string)>
diff --git a/unity/Assets/Tests/EditMode/EndScreenTests.cs b/unity/Assets/Tests/EditMode/EndScreenTests.cs
index 0c7101eea..6aee369a7 100644
--- a/unity/Assets/Tests/EditMode/EndScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/EndScreenTests.cs
@@ -296,4 +296,32 @@ public class EndScreenTests
Assert.AreEqual(He["hud.new_game"], k.Ui.Q<Button>("end-screen-new-game").text);
StringAssert.StartsWith(He["hud.caption.cohesion"] + ":", k.Line("cohesion"));
}
+
+ /// <summary>#2060: in Hebrew each date an end-screen line inserts sits between RLE and PDF (U+202B, U+202C), so it
+ /// reads as one unit right after "ב־" ("20 בספטמבר 1949") even in a line laid out left to right, instead of the bidi
+ /// rules pulling its day onto the next word and its year to the line's far end. The lines are compared ordinally, so
+ /// every direction mark counts. The titles are read back from the lines: #2041 decides which title shows, this test
+ /// pins the dates around it.</summary>
+ [Test]
+ public void HebrewIsolatesEachDateItInserts()
+ {
+ using var k = new Kit(He, Ended);
+ var first = C.Objectives.Single(o => o.Id == "absorb_immigrants");
+ const char Lrm = '\u200E', Rle = '\u202B', Pdf = '\u202C';
+ string Date(System.DateTime d) => $"{Rle}{Lrm}{d.Day}{Lrm} ב{He["date.month_" + d.Month]} {Lrm}{d.Year}{Lrm}{Pdf}";
+ var line = k.Line("objective-" + first.Id);
+ var title = line.Substring("יעד ".Length, line.IndexOf(": הושלם", System.StringComparison.Ordinal) - "יעד ".Length);
+ var expected = "יעד " + title + ": הושלם ב־" + Date(first.ReferenceDate.AddMonths(-1)) + "; בהיסטוריה ב־" + Date(first.ReferenceDate);
+ Assert.IsTrue(string.Equals(expected, line, System.StringComparison.Ordinal), "expected\n" + Escape(expected) + "\nbut was\n" + Escape(line));
+ var open = C.Objectives.First(o => o.Id != first.Id); // Ended completes only the first
+ var openLine = k.Line("objective-" + open.Id);
+ var openTitle = openLine.Substring("יעד ".Length, openLine.IndexOf(": לא הושלם", System.StringComparison.Ordinal) - "יעד ".Length);
+ var openExpected = "יעד " + openTitle + ": לא הושלם; בהיסטוריה ב־" + Date(open.ReferenceDate);
+ Assert.IsTrue(string.Equals(openExpected, openLine, System.StringComparison.Ordinal), "expected\n" + Escape(openExpected) + "\nbut was\n" + Escape(openLine));
+ var anchor = EndReport.For(C, k.Bridge.State).PopulationHistory!;
+ Assert.GreaterOrEqual(k.Line("population").IndexOf(Date(anchor.Date), System.StringComparison.Ordinal), 0, "the population line's date too: " + Escape(k.Line("population")));
+ }
+
+ /// <summary>The line with its invisible marks spelled out, for a failure message.</summary>
+ static string Escape(string s) => string.Concat(s.Select(c => c < 0x2000 || c > 0x206F ? c.ToString() : $"<U+{(int)c:X4}>"));
}