mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Merge pull request #13520 from bdach/add-more-language-enum-values
Add more languages to settings dropdown
This commit is contained in:
commit
537cbd1214
33
osu.Game/Extensions/LanguageExtensions.cs
Normal file
33
osu.Game/Extensions/LanguageExtensions.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Extensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Conversion utilities for the <see cref="Language"/> enum.
|
||||||
|
/// </summary>
|
||||||
|
public static class LanguageExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the culture code of the <see cref="CultureInfo"/> that corresponds to the supplied <paramref name="language"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is required as enum member names are not allowed to contain hyphens.
|
||||||
|
/// </remarks>
|
||||||
|
public static string ToCultureCode(this Language language)
|
||||||
|
=> language.ToString().Replace("_", "-");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse the supplied <paramref name="cultureCode"/> to a <see cref="Language"/> value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cultureCode">The code of the culture to parse.</param>
|
||||||
|
/// <param name="language">The parsed <see cref="Language"/>. Valid only if the return value of the method is <see langword="true" />.</param>
|
||||||
|
/// <returns>Whether the parsing succeeded.</returns>
|
||||||
|
public static bool TryParseCultureCode(string cultureCode, out Language language)
|
||||||
|
=> Enum.TryParse(cultureCode.Replace("-", "_"), out language);
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,104 @@ namespace osu.Game.Localisation
|
|||||||
[Description(@"English")]
|
[Description(@"English")]
|
||||||
en,
|
en,
|
||||||
|
|
||||||
|
// TODO: Requires Arabic glyphs to be added to resources (and possibly also RTL support).
|
||||||
|
// [Description(@"اَلْعَرَبِيَّةُ")]
|
||||||
|
// ar,
|
||||||
|
|
||||||
|
// TODO: Some accented glyphs are missing. Revisit when adding Inter.
|
||||||
|
// [Description(@"Беларуская мова")]
|
||||||
|
// be,
|
||||||
|
|
||||||
|
[Description(@"Български")]
|
||||||
|
bg,
|
||||||
|
|
||||||
|
[Description(@"Česky")]
|
||||||
|
cs,
|
||||||
|
|
||||||
|
[Description(@"Dansk")]
|
||||||
|
da,
|
||||||
|
|
||||||
|
[Description(@"Deutsch")]
|
||||||
|
de,
|
||||||
|
|
||||||
|
// TODO: Some accented glyphs are missing. Revisit when adding Inter.
|
||||||
|
// [Description(@"Ελληνικά")]
|
||||||
|
// el,
|
||||||
|
|
||||||
|
[Description(@"español")]
|
||||||
|
es,
|
||||||
|
|
||||||
|
[Description(@"Suomi")]
|
||||||
|
fi,
|
||||||
|
|
||||||
|
[Description(@"français")]
|
||||||
|
fr,
|
||||||
|
|
||||||
|
[Description(@"Magyar")]
|
||||||
|
hu,
|
||||||
|
|
||||||
|
[Description(@"Bahasa Indonesia")]
|
||||||
|
id,
|
||||||
|
|
||||||
|
[Description(@"Italiano")]
|
||||||
|
it,
|
||||||
|
|
||||||
[Description(@"日本語")]
|
[Description(@"日本語")]
|
||||||
ja
|
ja,
|
||||||
|
|
||||||
|
[Description(@"한국어")]
|
||||||
|
ko,
|
||||||
|
|
||||||
|
[Description(@"Nederlands")]
|
||||||
|
nl,
|
||||||
|
|
||||||
|
[Description(@"Norsk")]
|
||||||
|
no,
|
||||||
|
|
||||||
|
[Description(@"polski")]
|
||||||
|
pl,
|
||||||
|
|
||||||
|
[Description(@"Português")]
|
||||||
|
pt,
|
||||||
|
|
||||||
|
[Description(@"Português (Brasil)")]
|
||||||
|
pt_br,
|
||||||
|
|
||||||
|
[Description(@"Română")]
|
||||||
|
ro,
|
||||||
|
|
||||||
|
[Description(@"Русский")]
|
||||||
|
ru,
|
||||||
|
|
||||||
|
[Description(@"Slovenčina")]
|
||||||
|
sk,
|
||||||
|
|
||||||
|
[Description(@"Svenska")]
|
||||||
|
se,
|
||||||
|
|
||||||
|
[Description(@"ไทย")]
|
||||||
|
th,
|
||||||
|
|
||||||
|
[Description(@"Tagalog")]
|
||||||
|
tl,
|
||||||
|
|
||||||
|
[Description(@"Türkçe")]
|
||||||
|
tr,
|
||||||
|
|
||||||
|
// TODO: Some accented glyphs are missing. Revisit when adding Inter.
|
||||||
|
// [Description(@"Українська мова")]
|
||||||
|
// uk,
|
||||||
|
|
||||||
|
[Description(@"Tiếng Việt")]
|
||||||
|
vn,
|
||||||
|
|
||||||
|
[Description(@"简体中文")]
|
||||||
|
zh,
|
||||||
|
|
||||||
|
[Description(@"繁體中文(香港)")]
|
||||||
|
zh_hk,
|
||||||
|
|
||||||
|
[Description(@"繁體中文(台灣)")]
|
||||||
|
zh_tw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ using osu.Game.Updater;
|
|||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using LogLevel = osu.Framework.Logging.LogLevel;
|
using LogLevel = osu.Framework.Logging.LogLevel;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Skinning.Editor;
|
using osu.Game.Skinning.Editor;
|
||||||
@ -580,7 +581,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
foreach (var language in Enum.GetValues(typeof(Language)).OfType<Language>())
|
foreach (var language in Enum.GetValues(typeof(Language)).OfType<Language>())
|
||||||
{
|
{
|
||||||
var cultureCode = language.ToString();
|
var cultureCode = language.ToCultureCode();
|
||||||
Localisation.AddLanguage(cultureCode, new ResourceManagerLocalisationStore(cultureCode));
|
Localisation.AddLanguage(cultureCode, new ResourceManagerLocalisationStore(cultureCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.General
|
namespace osu.Game.Overlays.Settings.Sections.General
|
||||||
@ -35,11 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Enum.TryParse<Language>(frameworkLocale.Value, out var locale))
|
if (!LanguageExtensions.TryParseCultureCode(frameworkLocale.Value, out var locale))
|
||||||
locale = Language.en;
|
locale = Language.en;
|
||||||
languageSelection.Current.Value = locale;
|
languageSelection.Current.Value = locale;
|
||||||
|
|
||||||
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToString());
|
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Overlays.Settings
|
|||||||
Margin = new MarginPadding { Top = 5 };
|
Margin = new MarginPadding { Top = 5 };
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user