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: a refused order names its kind in the UI's language (refs #595) (#651)

Eyal Golan92c5e02bb22d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf697b626..30d218b47 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -530,6 +530,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
It decodes to the same bytes, so the terrain is unchanged (#44).
### Fixed
+- In the Hebrew UI a refused order names its kind in Hebrew (refs #595; owner, 15 October 2026: "Yes, translate them"),
+ for example "לא ניתן לזהות מדיניות", not "policy לא מוכר". Each kind is a string, `order.kind.<kind>`, in both
+ strings files; English reads as before ("Unknown policy"). The Hebrew words wait for the native reviewer (#564).
- An autosave that cannot be continued (refs #631, #622) no longer shows the sim's English reason or a replay's exception
message to the player: the note always gives the short reason "the file could not be read or replayed", in English and
Hebrew, and the full exception goes to the log. A replay that throws keeps that exception, with its stack, as the
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index 4fc9fc067..5fcd2ca9a 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -71,12 +71,13 @@ namespace Statecraft.Game.UI
public Command? QueuedLike(Command c) => queue.FirstOrDefault(q => Key(q) == Key(c));
/// <summary>Null if the id is known, else the player-facing reason. The player sees only the kind of thing (#622: a
- /// content id means nothing to them); the id goes to the log, for a bug report.</summary>
+ /// content id means nothing to them), in the UI's language: the string order.kind.&lt;kind&gt; (#595). The id goes to
+ /// the log, for a bug report.</summary>
string? Unknown(string kind, string? id, IEnumerable<string> known)
{
if (!string.IsNullOrEmpty(id) && known.Contains(id)) return null;
- UnityEngine.Debug.Log($"Order refused: unknown {kind} '{id}'");
- return text.Format("order.unknown", kind);
+ UnityEngine.Debug.Log($"Order refused: unknown {kind.Replace('_', ' ')} '{id}'");
+ return text.Format("order.unknown", text["order.kind." + kind]);
}
/// <summary>Checks every id an order carries against the content, so End Turn can never be handed an id the
@@ -93,7 +94,7 @@ namespace Statecraft.Game.UI
case MapAction m: return Unknown("action", m.Action, MapActions.Actions);
case AllocateBudget b:
if (b.Shares == null) return text["order.invalid"];
- foreach (var k in b.Shares.Keys) { var r = Unknown("budget line", k, Content.Rules.BudgetStart.Keys); if (r != null) return r; }
+ foreach (var k in b.Shares.Keys) { var r = Unknown("budget_line", k, Content.Rules.BudgetStart.Keys); if (r != null) return r; }
return null;
case SetMobilization _: case SecurityOrder _: return null;
// The GDD orders (#380): ids only. Roles, counts and limits are the sim's, which refuses them with its own
@@ -107,7 +108,7 @@ namespace Statecraft.Game.UI
// Pioneer work (#378): ids only; the sim refuses a busy unit, a built site or a short Treasury with its own reason.
case PioneerWork w:
return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)))
- ?? Unknown("pioneer work", w.Action, new[] { Projects.BuildYishuv }) ?? Unknown("site", w.Site, Content.Sites.Select(x => x.Id));
+ ?? Unknown("pioneer_work", w.Action, new[] { Projects.BuildYishuv }) ?? Unknown("site", w.Site, Content.Sites.Select(x => x.Id));
case StopWork w: return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)));
default: return text["order.invalid"];
}
diff --git a/unity/Assets/Tests/EditMode/HudTests.cs b/unity/Assets/Tests/EditMode/HudTests.cs
index b73d11eaa..de1665b21 100644
--- a/unity/Assets/Tests/EditMode/HudTests.cs
+++ b/unity/Assets/Tests/EditMode/HudTests.cs
@@ -304,7 +304,7 @@ public class HudTests
var text = hebrew ? UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml") : Text;
LogAssert.Expect(LogType.Log, new System.Text.RegularExpressions.Regex("unknown policy 'curfew'"));
var unknown = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text).Queue(new SetPolicy("curfew", 1));
- Assert.AreEqual(text.Format("order.unknown", "policy"), unknown);
+ Assert.AreEqual(text.Format("order.unknown", text["order.kind.policy"]), unknown); // the kind in the UI's language (#595)
StringAssert.DoesNotContain("curfew", unknown);
LogAssert.Expect(LogType.Exception, new System.Text.RegularExpressions.Regex("stack detail 42"));
diff --git a/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs b/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs
new file mode 100644
index 000000000..9a644a29e
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs
@@ -0,0 +1,79 @@
+#nullable enable
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.TestTools;
+
+/// <summary>#595: a refused order names the kind of thing (policy, city, unit, …) in the UI's language. Each kind word is a
+/// string, order.kind.&lt;kind&gt;, in strings.en.yaml and strings.he.yaml; English reads as it did before.</summary>
+public class SimBridgeKindTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ static readonly Regex Latin = new Regex("[A-Za-z]");
+
+ /// <summary>The kinds SimBridge.Validate can name: every Unknown("kind", …) call in its source. A call whose kind is
+ /// not a literal fails the count, so a new kind cannot slip past this test.</summary>
+ static string[] KindsInTheBridge()
+ {
+ var source = File.ReadAllText(Path.Combine(Application.dataPath, "Scripts/UI/SimBridge.cs"));
+ var calls = Regex.Matches(source, @"(?<![\w.])Unknown\(").Count - 1; // less the method's own declaration
+ var kinds = Regex.Matches(source, @"(?<![\w.])Unknown\(""([a-z_]+)""").Cast<Match>().Select(m => m.Groups[1].Value).ToList();
+ Assert.AreEqual(calls, kinds.Count, "every Unknown(...) call names its kind as a literal");
+ return kinds.Distinct().OrderBy(k => k, System.StringComparer.Ordinal).ToArray();
+ }
+
+ [Test]
+ public void EveryKindTheBridgeCanNameHasAnEnglishAndAHebrewWord()
+ {
+ var kinds = KindsInTheBridge();
+ Assert.GreaterOrEqual(kinds.Length, 13, "the kinds are read from the source");
+ var en = En;
+ var he = He;
+ foreach (var k in kinds)
+ {
+ // English as before #595: the word the bridge passed, "budget line" for budget_line.
+ Assert.AreEqual(k.Replace('_', ' '), en["order.kind." + k], k);
+ var word = he["order.kind." + k];
+ Assert.IsTrue(UiDirection.HasRightToLeft(word), k + ": " + word);
+ Assert.IsFalse(Latin.IsMatch(word), k + ": " + word);
+ Assert.AreEqual(-1, word.IndexOfAny(new[] { '"', '\'' }), k + ": gershayim and geresh are ״ and ׳, not ASCII quotes");
+ }
+ }
+
+ [Test]
+ public void AnEnglishRefusalReadsAsBefore()
+ {
+ LogAssert.Expect(LogType.Log, new Regex("unknown policy 'curfew'"));
+ Assert.AreEqual("Unknown policy", new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En).Queue(new SetPolicy("curfew", 1)));
+ LogAssert.Expect(LogType.Log, new Regex("unknown budget line 'nowhere'"));
+ var shares = new System.Collections.Generic.Dictionary<string, double> { ["nowhere"] = 1 };
+ Assert.AreEqual("Unknown budget line", new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En).Queue(new AllocateBudget(shares)));
+ }
+
+ /// <summary>The issue's done-when: an unknown id queued with the Hebrew strings gives a reason with no Latin kind word
+ /// (no Latin letter at all), for a legacy kind and a GDD one.</summary>
+ [Test]
+ public void AHebrewRefusalHasNoEnglishWord()
+ {
+ var he = He;
+ LogAssert.Expect(LogType.Log, new Regex("unknown policy 'curfew'"));
+ var policy = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), he).Queue(new SetPolicy("curfew", 1));
+ Assert.AreEqual(he.Format("order.unknown", he["order.kind.policy"]), policy);
+ LogAssert.Expect(LogType.Log, new Regex("unknown city 'no_such_city'"));
+ var city = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), he).Queue(new AssignWorkers("no_such_city", "job", 1));
+ Assert.AreEqual(he.Format("order.unknown", he["order.kind.city"]), city);
+ foreach (var reason in new[] { policy!, city! })
+ {
+ Assert.IsFalse(Latin.IsMatch(reason), reason);
+ Assert.IsTrue(UiDirection.RightToLeft(reason), reason);
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs.meta b/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs.meta
new file mode 100644
index 000000000..345a5db14
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SimBridgeKindTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 1947d7677eefe4fd69d0a1496d279985
\ No newline at end of file
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 45649265b..3b2e7044e 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -67,6 +67,20 @@ outcome.skip: "Click, Enter or Space to skip · Esc skips all"
order.game_over: "The game is over"
order.no_attention: "Not enough attention (need {0:0.0}, have {1:0.0})"
order.unknown: "Unknown {0}"
+# The kind of thing a refused order names in order.unknown (SimBridge.Validate; #595), one key per kind.
+order.kind.policy: "policy"
+order.kind.office: "office"
+order.kind.person: "person"
+order.kind.event: "event"
+order.kind.option: "option"
+order.kind.action: "action"
+order.kind.budget_line: "budget line"
+order.kind.city: "city"
+order.kind.training: "training"
+order.kind.cohort: "cohort"
+order.kind.unit: "unit"
+order.kind.pioneer_work: "pioneer work"
+order.kind.site: "site"
order.invalid: "That order is not valid"
order.failed: "The turn could not run"
defence.rung1: "1 Routine threat: border incidents, deterrence upkeep"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 336730978..2ee242f4a 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -59,7 +59,22 @@ outcome.order: "הפקודה שלך: {0}"
outcome.skip: "לחיצה, Enter או רווח לדילוג · Esc מדלג על הכול"
order.game_over: "המשחק הסתיים"
order.no_attention: "אין מספיק תשומת לב (נדרש {0:0.0}, יש {1:0.0})"
-order.unknown: "{0} לא מוכר"
+order.unknown: "לא ניתן לזהות {0}"
+# The kind of thing a refused order names in order.unknown (SimBridge.Validate; #595), one key per kind. order.unknown puts
+# the kind after the verb, so no adjective has to agree with its gender. For the native reviewer (#564).
+order.kind.policy: "מדיניות"
+order.kind.office: "תפקיד"
+order.kind.person: "אדם"
+order.kind.event: "אירוע"
+order.kind.option: "אפשרות"
+order.kind.action: "פעולה"
+order.kind.budget_line: "סעיף תקציב"
+order.kind.city: "עיר"
+order.kind.training: "מסלול הכשרה"
+order.kind.cohort: "מחזור הכשרה"
+order.kind.unit: "יחידה"
+order.kind.pioneer_work: "עבודה חלוצית"
+order.kind.site: "אתר"
order.invalid: "הפקודה אינה תקפה"
order.failed: "לא ניתן היה להריץ את התור"
defence.rung1: "1 איום שגרתי: תקריות גבול, שימור ההרתעה"