2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2021-04-20 08:06:01 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-15 03:50:34 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-06-16 09:10:03 +00:00
|
|
|
|
using osu.Game.Extensions;
|
2021-04-20 08:06:01 +00:00
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.General
|
|
|
|
|
{
|
|
|
|
|
public class LanguageSettings : SettingsSubsection
|
|
|
|
|
{
|
2021-04-20 08:06:01 +00:00
|
|
|
|
private SettingsDropdown<Language> languageSelection;
|
|
|
|
|
private Bindable<string> frameworkLocale;
|
|
|
|
|
|
2021-08-11 07:25:08 +00:00
|
|
|
|
protected override LocalisableString Header => GeneralSettingsStrings.LanguageHeader;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(FrameworkConfigManager frameworkConfig)
|
|
|
|
|
{
|
2021-04-20 08:06:01 +00:00
|
|
|
|
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-04-20 08:06:01 +00:00
|
|
|
|
languageSelection = new SettingsEnumDropdown<Language>
|
|
|
|
|
{
|
2021-08-11 07:25:08 +00:00
|
|
|
|
LabelText = GeneralSettingsStrings.LanguageDropdown,
|
2021-04-20 08:06:01 +00:00
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-08-13 09:15:18 +00:00
|
|
|
|
LabelText = GeneralSettingsStrings.PreferOriginalMetadataLanguage,
|
2020-10-06 08:18:41 +00:00
|
|
|
|
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowUnicode)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2021-04-20 08:06:01 +00:00
|
|
|
|
|
2021-06-16 09:10:03 +00:00
|
|
|
|
if (!LanguageExtensions.TryParseCultureCode(frameworkLocale.Value, out var locale))
|
2021-04-20 08:06:01 +00:00
|
|
|
|
locale = Language.en;
|
|
|
|
|
languageSelection.Current.Value = locale;
|
|
|
|
|
|
2021-06-16 09:10:03 +00:00
|
|
|
|
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|