1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 05:52:36 +08:00

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
Unverified
parent 89c27dcb10
commit 76db87f9cb
+10 -1
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,7 +586,15 @@ namespace osu.Game
foreach (var language in Enum.GetValues(typeof(Language)).OfType<Language>())
{
var cultureCode = language.ToCultureCode();
Localisation.AddLanguage(cultureCode, new ResourceManagerLocalisationStore(cultureCode));
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