Don't crash Lua when the translation attempt fails.

This commit is contained in:
Matthias Mailänder
2022-09-02 17:23:55 +02:00
committed by Gustas
parent 0c47a0a710
commit 807e9b5496

View File

@@ -87,6 +87,8 @@ namespace OpenRA
}
public bool TryGetString(string key, out string value, IDictionary<string, object> arguments = null)
{
try
{
if (!HasMessage(key))
{
@@ -99,8 +101,6 @@ namespace OpenRA
foreach (var (k, v) in arguments)
fluentArguments.Add(k, v.ToFluentType());
try
{
var result = bundle.TryGetAttrMsg(key, fluentArguments, out var errors, out value);
foreach (var error in errors)
Log.Write("debug", $"Translation of {key}: {error}");
@@ -109,7 +109,8 @@ namespace OpenRA
}
catch (Exception e)
{
Log.Write("debug", $"Translation of {key}: {e}");
Log.Write("debug", $"Translation of {key} failed:");
Log.Write("debug", e);
value = null;
return false;
}