1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 23:07:44 +08:00
osu-lazer/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs

46 lines
1.5 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
2021-04-20 16:06:01 +08:00
using System;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
2021-04-20 16:06:01 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics;
2021-04-20 16:06:01 +08:00
using osu.Game.Localisation;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings.Sections.General
{
public class LanguageSettings : SettingsSubsection
{
2021-04-20 16:06:01 +08:00
private SettingsDropdown<Language> languageSelection;
private Bindable<string> frameworkLocale;
2018-04-13 17:19:50 +08:00
protected override string Header => "Language";
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig)
{
2021-04-20 16:06:01 +08:00
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
2018-04-13 17:19:50 +08:00
Children = new Drawable[]
{
2021-04-20 16:06:01 +08:00
languageSelection = new SettingsEnumDropdown<Language>
{
LabelText = "Language",
},
2018-04-13 17:19:50 +08:00
new SettingsCheckbox
{
LabelText = "Prefer metadata in original language",
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowUnicode)
2018-04-13 17:19:50 +08:00
},
};
2021-04-20 16:06:01 +08:00
if (!Enum.TryParse<Language>(frameworkLocale.Value, out var locale))
locale = Language.en;
languageSelection.Current.Value = locale;
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToString());
2018-04-13 17:19:50 +08:00
}
}
}