Пример #1
0
        //private readonly List<string> _supportedLanguages = LanguagesProvider._supportedLanguages;
        public static bool IsSupported(string langCode)
        {
            //if (LanguagesProvider._supportedLanguages.Contains(langCode))
            //    return true;
            if (LanguagesProvider.GetListLanguages().Any(x => x.LanguageCultureName.Contains(langCode)))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        private bool SetHeaderIfGlobalAcceptLanguageMatchesSupportedLanguage(HttpRequestMessage request)
        {
            var listLangs = LanguagesProvider.GetListLanguages();

            foreach (var lang in request.Headers.AcceptLanguage)
            {
                var globalLang = lang.Value.Substring(0, 2);
                if (LanguagesProvider.GetListLanguages().Any(t => t.LanguageCultureName.StartsWith(globalLang)))
                {
                    //SetCulture(request, _supportedLanguages.FirstOrDefault(i => i.StartsWith(globalLang)));
                    SetCulture(request, listLangs.FirstOrDefault(i => i.LanguageCultureName.StartsWith(globalLang)).LanguageCultureName);
                    return(true);
                }
            }

            return(false);
        }