/// <summary> /// Gets the spell check service for the given language, if any. /// </summary> /// <param name="context">The current context.</param> /// <param name="language">The language of the spellchecker.</param> /// <returns>The spell check service, if any.</returns> public static ISpellCheckService GetSpellCheck(this IBrowsingContext context, String language) { var substitute = default(ISpellCheckService); var services = context.GetServices <ISpellCheckService>(); var culture = context.GetCultureFrom(language); var twoLetters = culture.TwoLetterISOLanguageName; foreach (var service in services) { var otherCulture = service.Culture; if (otherCulture != null) { var otherTwoLetters = otherCulture.TwoLetterISOLanguageName; if (otherCulture.Equals(culture)) { return(service); } else if (substitute == null && otherTwoLetters.Is(twoLetters)) { substitute = service; } } } return(substitute); }