1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Handle culture code differences of Traditional Chinese

This commit is contained in:
Salman Ahmed 2023-06-08 03:27:03 +03:00
parent 9f842ccdc0
commit 251f23b2c2

View File

@ -21,7 +21,12 @@ namespace osu.Game.Extensions
/// This is required as enum member names are not allowed to contain hyphens.
/// </remarks>
public static string ToCultureCode(this Language language)
=> language.ToString().Replace("_", "-");
{
if (language == Language.zh_hant)
return @"zh-tw";
return language.ToString().Replace("_", "-");
}
/// <summary>
/// Attempts to parse the supplied <paramref name="cultureCode"/> to a <see cref="Language"/> value.
@ -30,7 +35,15 @@ namespace osu.Game.Extensions
/// <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);
{
if (cultureCode == @"zh-tw")
{
language = Language.zh_hant;
return true;
}
return Enum.TryParse(cultureCode.Replace("-", "_"), out language);
}
/// <summary>
/// Parses the <see cref="Language"/> that is specified in <paramref name="frameworkLocale"/>,