示例#1
0
        public async Task <GetLanguageForEditOutput> GetLanguageForEdit(NullableIdDto input)
        {
            ApplicationLanguage language = null;

            if (input.Id.HasValue)
            {
                language = await _languageRepository.GetAsync(input.Id.Value);
            }

            var output = new GetLanguageForEditOutput();

            //Language
            output.Language = language != null
                ? ObjectMapper.Map <ApplicationLanguageEditDto>(language)
                : new ApplicationLanguageEditDto();

            //Language names
            output.LanguageNames = CultureHelper
                                   .AllCultures
                                   .Select(c => new ComboboxItemDto(c.Name, c.EnglishName + " (" + c.Name + ")")
            {
                IsSelected = output.Language.Name == c.Name
            })
                                   .ToList();

            //Flags
            output.Flags = FamFamFamFlagsHelper
                           .FlagClassNames
                           .OrderBy(f => f)
                           .Select(f => new ComboboxItemDto(f, FamFamFamFlagsHelper.GetCountryCode(f))
            {
                IsSelected = output.Language.Icon == f
            })
                           .ToList();

            return(output);
        }
示例#2
0
        public async Task DeleteLanguage(IdInput input)
        {
            ApplicationLanguage async = await this._languageRepository.GetAsync(input.Id);

            await this._applicationLanguageManager.RemoveAsync(this.AbpSession.TenantId, async.Name);
        }
示例#3
0
        public async Task <PagedResultOutput <LanguageTextListDto> > GetLanguageTexts(GetLanguageTextsInput input)
        {
            if (input.BaseLanguageName.IsNullOrEmpty())
            {
                ApplicationLanguage defaultLanguageOrNullAsync = await this._applicationLanguageManager.GetDefaultLanguageOrNullAsync(this.AbpSession.TenantId);

                ApplicationLanguage applicationLanguage = defaultLanguageOrNullAsync;
                if (applicationLanguage == null)
                {
                    IReadOnlyList <ApplicationLanguage> languagesAsync = await this._applicationLanguageManager.GetLanguagesAsync(this.AbpSession.TenantId);

                    applicationLanguage = languagesAsync.FirstOrDefault <ApplicationLanguage>();
                    if (applicationLanguage == null)
                    {
                        throw new ApplicationException("No language found in the application!");
                    }
                }
                input.BaseLanguageName = applicationLanguage.Name;
            }
            ILocalizationSource source           = this.LocalizationManager.GetSource(input.SourceName);
            CultureInfo         cultureInfo      = CultureInfo.GetCultureInfo(input.BaseLanguageName);
            CultureInfo         cultureInfo1     = CultureInfo.GetCultureInfo(input.TargetLanguageName);
            IQueryable <LanguageTextListDto> key = (
                from localizedString in source.GetAllStrings(true)
                select new LanguageTextListDto()
            {
                Key = localizedString.Name,
                BaseValue = this._applicationLanguageTextManager.GetStringOrNull(this.AbpSession.TenantId, source.Name, cultureInfo, localizedString.Name, true),
                TargetValue = this._applicationLanguageTextManager.GetStringOrNull(this.AbpSession.TenantId, source.Name, cultureInfo1, localizedString.Name, false)
            }).AsQueryable <LanguageTextListDto>();

            if (input.TargetValueFilter == "EMPTY")
            {
                key =
                    from s in key
                    where s.TargetValue.IsNullOrEmpty()
                    select s;
            }
            if (!input.FilterText.IsNullOrEmpty())
            {
                key =
                    from l in key
                    where l.Key != null && l.Key.IndexOf(input.FilterText, StringComparison.CurrentCultureIgnoreCase) >= 0 || l.BaseValue != null && l.BaseValue.IndexOf(input.FilterText, StringComparison.CurrentCultureIgnoreCase) >= 0 || l.TargetValue != null && l.TargetValue.IndexOf(input.FilterText, StringComparison.CurrentCultureIgnoreCase) >= 0
                    select l;
            }
            int num = key.Count <LanguageTextListDto>();

            if (!input.Sorting.IsNullOrEmpty())
            {
                key = key.OrderBy <LanguageTextListDto>(input.Sorting, new object[0]);
            }
            if (input.SkipCount > 0)
            {
                key = key.Skip <LanguageTextListDto>(input.SkipCount);
            }
            if (input.MaxResultCount > 0)
            {
                key = key.Take <LanguageTextListDto>(input.MaxResultCount);
            }
            return(new PagedResultOutput <LanguageTextListDto>(num, key.ToList <LanguageTextListDto>()));
        }
        private void ChangeLanguage(ApplicationLanguage selectedLanguage)
        {
            IsRestartRequired = initialLanguage != selectedLanguage.Tag;

            ApplicationLanguages.PrimaryLanguageOverride = selectedLanguage.Tag;
        }
 public async Task UpdateLanguage(int?tenantId, ApplicationLanguage language)
 {
     await _languageManager.UpdateAsync(null, language);
 }
        public async Task <ApplicationLanguage> GetDefaultLanguageOrNull()
        {
            ApplicationLanguage language = await _languageManager.GetDefaultLanguageOrNullAsync(null);

            return(language);
        }
 public async Task Addlanguage(ApplicationLanguage language)
 {
     await _languageManager.AddAsync(language);
 }
示例#8
0
        public async Task <ApplicationLanguage> GetDefaultLanguageOrNullAsync(int?tenantId)
        {
            ApplicationLanguage language = await _languageManager.GetDefaultLanguageOrNullAsync(tenantId);

            return(language);
        }