Open Closed

Angular: bootstrap theme #532


User avatar
0
sammy@projile.com created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v3.1.2
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): yes
  • Exception message and stack trace: NA
  • Steps to reproduce the issue: NA

Hi Team, 2 queries:

1- Can i use 3rd party bootstrap theme in UI. If yes what is the steps to add this new bootstrap theme in angular UI? 2- How i can setup default language for user? currently i cannot see any provision to select user language while creating new user. My use case is once user language is defined then as user login, all content should be displayed in the defined language only. 3- What is the steps to show all text in selected language?


2 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    I'll answer 2 & 3 . 2- There's no out of box feature to set a language for a user manually. However you can set a language as default. A user can change his language on his own. See also https://github.com/abpframework/abp/issues/2775 https://github.com/abpframework/abp/issues/2469 (If I find a smooth way of implementing this, I'll write)

    3- I guess below code can help you to get all language texts.

    public class LanguageAppService : LanguageAppServiceBase, ILanguageAppService
        {
            protected ISettingManager SettingManager { get; }
            protected ILanguageRepository LanguageRepository { get; }
            protected AbpLocalizationOptions AbpLocalizationOptions { get; }
    
            public LanguageAppService(
                ISettingManager settingManager,
                IOptions<AbpLocalizationOptions> abpLocalizationOptions, 
                ILanguageRepository languageRepository)
            {
                SettingManager = settingManager;
                LanguageRepository = languageRepository;
                AbpLocalizationOptions = abpLocalizationOptions.Value;
            }
     
            public async Task<PagedResultDto<LanguageDto>> GetListAsync(GetLanguagesTextsInput input)
            {
                var languages = await LanguageRepository.GetListAsync(input.Sorting,input.MaxResultCount,input.SkipCount,input.Filter);
                var totalCount = await LanguageRepository.GetCountAsync(input.Filter);
                var defaultLanguage = await FindDefaultLanguage(languages);
    
                var languageDtos = ObjectMapper.Map<List<Language>, List<LanguageDto>>(languages);
    
                if (defaultLanguage != null)
                {
                    var defaultLanguageDto = languageDtos.Find(
                        l => l.CultureName == defaultLanguage.CultureName &&
                             l.UiCultureName == defaultLanguage.CultureName
                    );
    
                    if (defaultLanguageDto != null)
                    {
                        defaultLanguageDto.IsDefaultLanguage = true;
                    }
                }
    
                return new PagedResultDto<LanguageDto>(totalCount,languageDtos);
            }
        }
    
    
       public class GetLanguagesTextsInput : PagedAndSortedResultRequestDto
        {
            public string Filter { get; set; }
    
            public string ResourceName { get; set; }
    
            public string BaseCultureName { get; set; }
    
            public string TargetCultureName { get; set; }
    
            public bool GetOnlyEmptyValues { get; set; }
        }
    
    
        public class LanguageDto : ExtensibleCreationAuditedEntityDto<Guid>
        {
            public string CultureName { get; set; }
    
            public string UiCultureName { get; set; }
    
            public string DisplayName { get; set; }
    
            public string FlagIcon { get; set; }
    
            public bool IsEnabled { get; set; }
    
            public bool IsDefaultLanguage { get; set; }
        }
    
  • User Avatar
    0
    alper created
    Support Team Director

    For you question2:

    Inject ISettingProvider then set the default language for a user with this method _settingProvider.SetForUserAsync() you can use LocalizationSettingNames.DefaultLanguage constant for the setting name.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38