From 021e4485c22dff00fe2597bbe450100c6577c11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8D=E4=BA=88?= Date: Wed, 25 Mar 2026 00:31:10 +0800 Subject: [PATCH] Prepare for l10n of tournament client (#36827) ## Changes - Extract / Move l10n initialisation methods - Add analyser support for tournament project For the tournament client, it's a bit different around l10n initialisation compared with the main client. `TournamentGame` needs to show warning boxes for bracket errors and window size warnings, and we may make l10n support ready in advance. --------- Co-authored-by: Dean Herbert --- .../osu.Game.Tournament.csproj | 4 +++ osu.Game/OsuGame.cs | 25 ----------------- osu.Game/OsuGameBase.cs | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tournament/osu.Game.Tournament.csproj b/osu.Game.Tournament/osu.Game.Tournament.csproj index c8578ac464..2fa7143216 100644 --- a/osu.Game.Tournament/osu.Game.Tournament.csproj +++ b/osu.Game.Tournament/osu.Game.Tournament.csproj @@ -10,5 +10,9 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 150d084a78..caf2a6279a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -36,7 +36,6 @@ using osu.Game.Beatmaps; using osu.Game.Collections; using osu.Game.Configuration; using osu.Game.Database; -using osu.Game.Extensions; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; @@ -1053,30 +1052,6 @@ namespace osu.Game { base.LoadComplete(); - var languages = Enum.GetValues(); - - var mappings = languages.Select(language => - { -#if DEBUG - if (language == Language.debug) - return new LocaleMapping("debug", new DebugLocalisationStore()); -#endif - - string cultureCode = language.ToCultureCode(); - - try - { - return new LocaleMapping(new ResourceManagerLocalisationStore(cultureCode)); - } - catch (Exception ex) - { - Logger.Error(ex, $"Could not load localisations for language \"{cultureCode}\""); - return null; - } - }).Where(m => m != null); - - Localisation.AddLocaleMappings(mappings); - // 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. // This prevents the cursor from showing until we have a screen with CursorVisible = true diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index e957753c8b..a31dd24352 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -306,6 +306,7 @@ namespace osu.Game MessageFormatter.WebsiteRootUrl = endpoints.WebsiteUrl; + // Initialise localisation frameworkLocale = frameworkConfig.GetBindable(FrameworkSetting.Locale); frameworkLocale.BindValueChanged(_ => updateLanguage()); @@ -501,6 +502,33 @@ namespace osu.Game Fonts.AddStore(new OsuIcon.OsuIconStore(Textures)); } + protected override void LoadComplete() + { + base.LoadComplete(); + + var localeMappings = Enum.GetValues().Select(language => + { +#if DEBUG + if (language == Language.debug) + return new LocaleMapping("debug", new DebugLocalisationStore()); +#endif + + string cultureCode = language.ToCultureCode(); + + try + { + return new LocaleMapping(new ResourceManagerLocalisationStore(cultureCode)); + } + catch (Exception ex) + { + Logger.Error(ex, $"Could not load localisations for language \"{cultureCode}\""); + return null; + } + }).Where(m => m != null); + + Localisation.AddLocaleMappings(localeMappings); + } + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));