Files
jsmr/JSMR.Infrastructure/Globalization/LocaleMap.cs
Brian Bicknell d9e421178f
All checks were successful
ci / build-test (push) Successful in 2m21s
ci / publish-image (push) Successful in 2m19s
Added inital job entity and services. Added released works API integration.
2026-03-27 01:32:39 -04:00

48 lines
1.6 KiB
C#

using JSMR.Application.Enums;
namespace JSMR.Infrastructure.Globalization;
internal class LocaleMapper
{
// TODO: Deprecate
public static readonly IReadOnlyDictionary<Locale, (string Abbreviation, string Code)> Map =
new Dictionary<Locale, (string, string)>
{
{ Locale.Japanese, ("jp", "ja_JP") },
{ Locale.English, ("en", "en_US") },
{ Locale.ChineseSimplified, ("zh-cn", "zh_CN") },
{ Locale.ChineseTraditional, ("zh-tw", "zh_TW") },
{ Locale.Korean, ("ko", "ko_KR") },
};
public static string ToDLSiteLocale(Locale locale) => locale switch
{
Locale.Japanese => "ja-jp",
Locale.English => "en-us",
Locale.ChineseSimplified => "zh-cn",
Locale.ChineseTraditional => "zh-tw",
Locale.Korean => "ko-kr",
_ => throw new NotSupportedException($"Locale '{locale}' is not supported.")
};
public static string ToDLSiteApiLocale(Locale locale) => locale switch
{
Locale.Japanese => "ja_JP",
Locale.English => "en_US",
Locale.ChineseSimplified => "zh_CN",
Locale.ChineseTraditional => "zh_TW",
Locale.Korean => "ko_KR",
_ => throw new NotSupportedException($"Locale '{locale}' is not supported.")
};
public static string ToAbbreviation(Locale locale) => locale switch
{
Locale.Japanese => "jp",
Locale.English => "en",
Locale.ChineseSimplified => "zh-cn",
Locale.ChineseTraditional => "zh-tw",
Locale.Korean => "ko",
_ => throw new NotSupportedException($"Locale '{locale}' is not supported.")
};
}