/// <summary> /// Loads the <see cref="LocalizationConfiguration"/> /// from application configuration file (section with <paramref name="sectionName"/>). /// </summary> /// <param name="sectionName">Name of the section.</param> /// <returns> /// The <see cref="LocalizationConfiguration"/>. /// </returns> public static LocalizationConfiguration Load(string sectionName) { var section = (ConfigurationSection)ConfigurationManager.GetSection(sectionName); var result = new LocalizationConfiguration(); result.DefaultCulture = Thread.CurrentThread.CurrentCulture; string cultureName = section == null ? string.Empty : section.DefaultCulture.Name; if (string.IsNullOrEmpty(cultureName)) { return(result); } try { var culture = new CultureInfo(cultureName); result.DefaultCulture = culture; } catch (CultureNotFoundException) { } return(result); }
private static LocalizationConfiguration GetConfigurationFromSection(ConfigurationSection configurationSection) { var result = new LocalizationConfiguration(); result.DefaultCulture = Thread.CurrentThread.CurrentCulture; string cultureName = configurationSection == null ? string.Empty : configurationSection.DefaultCulture.Name; if (string.IsNullOrEmpty(cultureName)) { return(result); } try { var culture = new CultureInfo(cultureName); result.DefaultCulture = culture; } catch (CultureNotFoundException) { } return(result); }