コード例 #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);
            }
        }
コード例 #2
0
        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);
            }
        }