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.")
    };
}