public static List <LanguageRequest> GetLanguages(PortalSettings PortalSettings, UserInfo UserInfo) { List <LanguageRequest> Languages = new List <LanguageRequest>(); try { foreach (KeyValuePair <string, Locale> item in LocaleController.Instance.GetLocales(Null.NullInteger)) { LanguageRequest language = new LanguageRequest { LanguageId = item.Value.LanguageId, Icon = Globals.ResolveUrl( string.IsNullOrEmpty(item.Value.Code) ? "~/images/Flags/none.gif" : $"~/images/Flags/{item.Value.Code}.gif"), Code = item.Value.Code, NativeName = item.Value.NativeName, EnglishName = item.Value.EnglishName, Enabled = IsLanguageEnabled(PortalSettings.PortalId, item.Value.Code), IsDefault = item.Value.Code == PortalSettings.DefaultLanguage }; Languages.Add(language); } } catch (Exception exc) { DotNetNuke.Services.Exceptions.Exceptions.LogException(exc); } return(Languages); }
public static List <LanguageRequest> GetAllLanguages(bool IsNativeName) { List <LanguageRequest> Languages = new List <LanguageRequest>(); try { List <CultureInfo> supportedLanguages = LocaleController.Instance.GetCultures(LocaleController.Instance.GetLocales(Null.NullInteger)); List <CultureInfo> cultures = new List <CultureInfo>(CultureInfo.GetCultures(CultureTypes.SpecificCultures)); foreach (CultureInfo info in supportedLanguages) { string cultureCode = info.Name; CultureInfo culture = cultures.SingleOrDefault(c => c.Name == cultureCode); if (culture != null) { cultures.Remove(culture); } } foreach (CultureInfo info in cultures) { LanguageRequest language = new LanguageRequest { Icon = Globals.ResolveUrl( string.IsNullOrEmpty(info.Name) ? "~/images/Flags/none.gif" : $"~/images/Flags/{info.Name}.gif"), Code = info.Name }; if (IsNativeName) { language.DisplayName = info.NativeName; } else { language.DisplayName = info.EnglishName; } language.NativeName = info.NativeName; language.EnglishName = info.EnglishName; Languages.Add(language); } } catch (Exception exc) { DotNetNuke.Services.Exceptions.Exceptions.LogException(exc); } return(Languages.OrderBy(l => l.DisplayName).ToList()); }