diff --git a/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs index 438a599dce..fdb9b89861 100644 --- a/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/UserInterfaceGlobal.cs @@ -9,6 +9,8 @@ */ #endregion +using System.Collections.Generic; +using Eluant; using OpenRA.Mods.Common.Widgets; using OpenRA.Primitives; using OpenRA.Scripting; @@ -32,8 +34,26 @@ namespace OpenRA.Mods.Common.Scripting.Global luaLabel.GetColor = () => c; } - public string Translate(string text) + public string Translate(string text, LuaTable table = null) { + if (table != null) + { + var argumentDictionary = new Dictionary(); + foreach (var kv in table) + { + using (kv.Key) + using (kv.Value) + { + if (!kv.Key.TryGetClrValue(out string variable) || !kv.Value.TryGetClrValue(out object value)) + throw new LuaException($"Translation arguments requires a table of [\"string\"]=value pairs. Received {kv.Key.WrappedClrType().Name},{kv.Value.WrappedClrType().Name}"); + + argumentDictionary.Add(variable, value); + } + } + + return Context.World.Map.Translate(text, argumentDictionary); + } + return Context.World.Map.Translate(text); } }