﻿namespace NetCreditHub.Localization
{
    using System.Globalization;
    using Extensions;

    internal static class GlobalizationHelper
    {
        /// <summary>
        /// 是否为有效的文化代码
        /// </summary>
        /// <param name="cultureCode">语言文化代码</param>
        /// <returns></returns>
        public static bool IsValidCultureCode(string cultureCode)
        {
            if (cultureCode.IsNullOrWhiteSpace())
            {
                return false;
            }

            try
            {
                CultureInfo.GetCultureInfo(cultureCode);
                return true;
            }
            catch (CultureNotFoundException)
            {
                return false;
            }
        }
    }
}
