Don't crash Lua when the translation attempt fails.
This commit is contained in:
committed by
Gustas
parent
0c47a0a710
commit
807e9b5496
@@ -87,6 +87,8 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetString(string key, out string value, IDictionary<string, object> arguments = null)
|
public bool TryGetString(string key, out string value, IDictionary<string, object> arguments = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!HasMessage(key))
|
if (!HasMessage(key))
|
||||||
{
|
{
|
||||||
@@ -99,8 +101,6 @@ namespace OpenRA
|
|||||||
foreach (var (k, v) in arguments)
|
foreach (var (k, v) in arguments)
|
||||||
fluentArguments.Add(k, v.ToFluentType());
|
fluentArguments.Add(k, v.ToFluentType());
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = bundle.TryGetAttrMsg(key, fluentArguments, out var errors, out value);
|
var result = bundle.TryGetAttrMsg(key, fluentArguments, out var errors, out value);
|
||||||
foreach (var error in errors)
|
foreach (var error in errors)
|
||||||
Log.Write("debug", $"Translation of {key}: {error}");
|
Log.Write("debug", $"Translation of {key}: {error}");
|
||||||
@@ -109,7 +109,8 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Write("debug", $"Translation of {key}: {e}");
|
Log.Write("debug", $"Translation of {key} failed:");
|
||||||
|
Log.Write("debug", e);
|
||||||
value = null;
|
value = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user