// Copyright (c) ppy Pty Ltd . 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 { /// /// Conversion utilities for the enum. /// public static class LanguageExtensions { /// /// Returns the culture code of the that corresponds to the supplied . /// /// /// This is required as enum member names are not allowed to contain hyphens. /// public static string ToCultureCode(this Language language) => language.ToString().Replace("_", "-"); /// /// Attempts to parse the supplied to a value. /// /// The code of the culture to parse. /// The parsed . Valid only if the return value of the method is . /// Whether the parsing succeeded. public static bool TryParseCultureCode(string cultureCode, out Language language) => Enum.TryParse(cultureCode.Replace("-", "_"), out language); } }