Пример #1
0
        /// <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);
        }
Пример #3
0
        public static bool IsValidCultureCode(string cultureCode)
        {
            if (cultureCode.IsNullOrWhiteSpace())
            {
                return(false);
            }

            try
            {
                CultureInfoHelper.Get(cultureCode);
                return(true);
            }
            catch (CultureNotFoundException)
            {
                return(false);
            }
        }