Try-catch around localisation store registration

Some platforms (android, older windows versions) will throw exceptions
at runtime when an unsupported `CultureInfo` is attempted to be
instantiated, leading to nasty crashes. Add a preventative try-catch
registration to prevent the crash, and log the errors for visibility.
This commit is contained in:
Bartłomiej Dach 2021-06-19 08:00:36 +02:00
parent 89c27dcb10
commit 76db87f9cb

View File

@ -55,6 +55,7 @@ using osu.Game.IO;
using osu.Game.Localisation;
using osu.Game.Performance;
using osu.Game.Skinning.Editor;
using osu.Framework.Extensions;
namespace osu.Game
{
@ -585,8 +586,16 @@ namespace osu.Game
foreach (var language in Enum.GetValues(typeof(Language)).OfType<Language>())
{
var cultureCode = language.ToCultureCode();
try
{
Localisation.AddLanguage(cultureCode, new ResourceManagerLocalisationStore(cultureCode));
}
catch (Exception ex)
{
Logger.Error(ex, $"Could not load localisations for language \"{cultureCode}\"");
}
}
// The next time this is updated is in UpdateAfterChildren, which occurs too late and results
// in the cursor being shown for a few frames during the intro.