Пример #1
0
        private CultureInfo GetClosestMatchingLanguage(CultureInfo culture)
        {
            if(culture == null || culture.Equals(CultureInfo.InvariantCulture)) {
                return null;
            }

            var cultures = _cultureProvider.GetSupportedCultures.ToList();

            var specificCulture = cultures.FirstOrDefault(c => c.IsSameCultureAs(culture));
            var neutralCulture = cultures.FirstOrDefault(c => c.IsSameLanguageAs(culture));
            var fallBackCulture = culture.IsSameLanguageAs(FallbackCulture) ? FallbackCulture : null;

            return specificCulture ?? neutralCulture ?? fallBackCulture;
        }