Fix some bugs in Translation.
- Use error.Message to reports errors, as error.ToString isn't overridden. - Ensure multiple translation languages are handled correctly, we need to use a list to maintain English being the first one.
This commit is contained in:
@@ -54,7 +54,7 @@ namespace OpenRA
|
||||
readonly FluentBundle bundle;
|
||||
|
||||
public Translation(string language, string[] translations, IReadOnlyFileSystem fileSystem)
|
||||
: this(language, translations, fileSystem, error => Log.Write("debug", error.ToString())) { }
|
||||
: this(language, translations, fileSystem, error => Log.Write("debug", error.Message)) { }
|
||||
|
||||
public Translation(string language, string[] translations, IReadOnlyFileSystem fileSystem, Action<ParseError> onError)
|
||||
{
|
||||
@@ -92,12 +92,12 @@ namespace OpenRA
|
||||
{
|
||||
// Always load english strings to provide a fallback for missing translations.
|
||||
// It is important to load the english files first so the chosen language's files can override them.
|
||||
var paths = translations.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToHashSet();
|
||||
var paths = translations.Where(t => t.EndsWith("en.ftl", StringComparison.Ordinal)).ToList();
|
||||
foreach (var t in translations)
|
||||
if (t.EndsWith($"{language}.ftl", StringComparison.Ordinal))
|
||||
paths.Add(t);
|
||||
|
||||
foreach (var path in paths)
|
||||
foreach (var path in paths.Distinct())
|
||||
{
|
||||
var stream = fileSystem.Open(path);
|
||||
using (var reader = new StreamReader(stream))
|
||||
|
||||
Reference in New Issue
Block a user