mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 19:54:15 +08:00
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 <pe@ppy.sh>
This commit is contained in:
@@ -10,5 +10,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageReference Include="ppy.LocalisationAnalyser" Version="2025.1208.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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<Language>();
|
||||
|
||||
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
|
||||
|
||||
@@ -306,6 +306,7 @@ namespace osu.Game
|
||||
|
||||
MessageFormatter.WebsiteRootUrl = endpoints.WebsiteUrl;
|
||||
|
||||
// Initialise localisation
|
||||
frameworkLocale = frameworkConfig.GetBindable<string>(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<Language>().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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user