public void SetCurrent(string ietfLanguageTag) { var culture = _cultureFactory.Create(ietfLanguageTag); System.Threading.Thread.CurrentThread.CurrentCulture = culture; System.Threading.Thread.CurrentThread.CurrentUICulture = culture; }
/// <summary> /// Sets the current thread culture and UI culture. /// </summary> /// <param name="ietfLanguageTag">An IETF language tag to set the current thread culture to e.g. 'en-US' or 'es'.</param> public void SetCurrent(string ietfLanguageTag) { if (string.IsNullOrEmpty(ietfLanguageTag)) { throw new ArgumentException("Cannot set the current culture to empty.", ietfLanguageTag); } var culture = _cultureFactory.Create(ietfLanguageTag); if (culture != null) { CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; } }