/// <summary> /// Gets the culture from the language string (or the current culture). /// </summary> /// <param name="context">The current context.</param> /// <param name="language">The ISO culture name.</param> /// <returns> /// The culture info representing the language or the current culture. /// </returns> public static CultureInfo GetCultureFrom(this IBrowsingContext context, String language) { try { return(new CultureInfo(language)); } catch (CultureNotFoundException) { return(context.GetCulture()); } }
/// <summary> /// Gets the language of the current context. /// </summary> /// <param name="context">The current context.</param> /// <returns>The ISO name of the culture.</returns> public static String GetLanguage(this IBrowsingContext context) => context.GetCulture().Name;