From 8f5d8de1c2da056924fbb52b51791f681a2d0eb1 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Thu, 13 Apr 2023 17:51:49 +0300 Subject: [PATCH] Allow empty translation keys --- OpenRA.Game/Translation.cs | 4 ++-- mods/common/scripts/utils.lua | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/OpenRA.Game/Translation.cs b/OpenRA.Game/Translation.cs index 39d51f3244..135fb81562 100644 --- a/OpenRA.Game/Translation.cs +++ b/OpenRA.Game/Translation.cs @@ -88,8 +88,8 @@ namespace OpenRA public bool TryGetString(string key, out string value, IDictionary arguments = null) { - if (string.IsNullOrEmpty(key)) - throw new ArgumentException("A translation key must not be null or empty.", nameof(key)); + if (key == null) + throw new ArgumentNullException(nameof(key)); try { diff --git a/mods/common/scripts/utils.lua b/mods/common/scripts/utils.lua index a7970cedd4..e474aa1254 100644 --- a/mods/common/scripts/utils.lua +++ b/mods/common/scripts/utils.lua @@ -38,10 +38,7 @@ end ---@param description string key of the translation string ---@return number id used to query for the objective later AddPrimaryObjective = function(player, description) - local translation = description - if translation ~= "" then - translation = UserInterface.Translate(description) - end + local translation = UserInterface.Translate(description) Media.DisplayMessageToPlayer(player, translation, UserInterface.Translate("new-primary-objective")) return player.AddObjective(translation, UserInterface.Translate("primary"), true) @@ -52,10 +49,7 @@ end ---@param description string key of the translation string ---@return number id used to query for the objective later AddSecondaryObjective = function(player, description) - local translation = description - if translation ~= "" then - translation = UserInterface.Translate(description) - end + local translation = UserInterface.Translate(description) Media.DisplayMessageToPlayer(player, translation, UserInterface.Translate("new-secondary-objective")) return player.AddObjective(translation, UserInterface.Translate("secondary"), false)