1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 21:42:56 +08:00

Merge pull request #21746 from peppy/fix-language-update

Closes https://github.com/ppy/osu/issues/21744
This commit is contained in:
Joseph Madamba 2022-12-21 11:06:52 -08:00 committed by GitHub
commit b09c00d71b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -87,18 +87,21 @@ namespace osu.Game.Overlays.FirstRunSetup
});
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
frameworkLocale.BindValueChanged(_ => onLanguageChange());
localisationParameters = localisation.CurrentParameters.GetBoundCopy();
localisationParameters.BindValueChanged(p =>
{
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue);
localisationParameters.BindValueChanged(_ => onLanguageChange(), true);
}
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
// Scheduling ensures the button animation plays smoothly after any blocking operation completes.
// Note that a delay is required (the alternative would be a double-schedule; delay feels better).
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50);
}, true);
private void onLanguageChange()
{
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
// Scheduling ensures the button animation plays smoothly after any blocking operation completes.
// Note that a delay is required (the alternative would be a double-schedule; delay feels better).
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50);
}
private void updateSelectedStates(Language language)

View File

@ -44,10 +44,13 @@ namespace osu.Game.Overlays.Settings.Sections.General
},
};
localisationParameters.BindValueChanged(p
=> languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue), true);
frameworkLocale.BindValueChanged(_ => updateSelection());
localisationParameters.BindValueChanged(_ => updateSelection(), true);
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
}
private void updateSelection() =>
languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
}
}