/// <summary> /// Sets the default language for a tenant or the host. /// </summary> /// <param name="tenantId">Tenant Id of null for host</param> /// <param name="languageName">Name of the language.</param> public virtual async Task SetDefaultLanguageAsync(int?tenantId, string languageName) { var cultureInfo = CultureInfoHelper.Get(languageName); if (tenantId.HasValue) { await _settingManager.ChangeSettingForTenantAsync(tenantId.Value, LocalizationSettingNames.DefaultLanguage, cultureInfo.Name); } else { await _settingManager.ChangeSettingForApplicationAsync(LocalizationSettingNames.DefaultLanguage, cultureInfo.Name); } }
protected virtual IMultiTenantLocalizationDictionary CreateLocalizationDictionary(LanguageInfo language) { var internalDictionary = _internalProvider.Dictionaries.GetOrDefault(language.Name) ?? new EmptyDictionary(CultureInfoHelper.Get(language.Name)); var dictionary = _iocManager.Resolve <IMultiTenantLocalizationDictionary>(new { sourceName = _sourceName, internalDictionary = internalDictionary }); return(dictionary); }
public static bool IsValidCultureCode(string cultureCode) { if (cultureCode.IsNullOrWhiteSpace()) { return(false); } try { CultureInfoHelper.Get(cultureCode); return(true); } catch (CultureNotFoundException) { return(false); } }