Open Closed

Languge Switcher missing in Lepton Theme #8907


User avatar
0
a3x created
  • ABP Framework version: v9.0.6

  • UI Type: MVC

  • Database System: EF Core (SQL Server)

  • Tiered (for MVC) or Auth Server Separated (for Angular): no

Hi,
I miss the language switch in the UI to change the language. I currently have 2 languages activated and have not made any changes to the theme. How can I switch the language switcher back on?
Enclosed the source code, here should actually be the code for the language changer:

image.png


6 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, as far as I understand, you have overridden the MainNavbarBrandViewComponent, right? Can you confirm and explain your scenario in detail, please?

    ABP provides LanguageSwitchViewComponent which is used as a toolbar item, and lists the related languages and allows you to change language in your application.

    Regards.

  • User Avatar
    0
    a3x created

    Hi,
    Thank you for your reply. No, I don't overridethe MainNavbarBrand or any other related Toolbar components:

    image.png

    Langauges are also activated:
    image.png

    image.png

    Any ideas?

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Did you add a new toolbar or remove an existing toolbar from the application? (https://abp.io/docs/latest/framework/ui/mvc-razor-pages/toolbars)

    If you did not, please share your module class and the relevant configurations, so I can better assist you.

    Best regards.

  • User Avatar
    0
    a3x created

    No, I did not overwrite the existing toolbar.
    Here is my module class:

    using System.IO;
    using Azure.Monitor.OpenTelemetry.AspNetCore;
    using Entrafin.Web.Bundling;
    using Hangfire;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Extensions.DependencyInjection;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Identity;
    using Microsoft.AspNetCore.Mvc.Razor;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.DependencyInjection.Extensions;
    using Microsoft.Extensions.Hosting;
    using Microsoft.OpenApi.Models;
    using MyappDb.EMail;
    using MyappDb.EntityFrameworkCore;
    using MyappDb.Jobs;
    using MyappDb.Localization;
    using MyappDb.Permissions;
    using MyappDb.Web.Bundling.Kendo;
    using MyappDb.Web.Components.Kendo;
    using MyappDb.Web.Components.Myapp;
    using MyappDb.Web.Filters;
    using MyappDb.Web.Menus;
    using OpenIddict.Validation.AspNetCore;
    using Volo.Abp;
    using Volo.Abp.Account.Admin.Web;
    using Volo.Abp.Account.Public.Web;
    using Volo.Abp.Account.Web;
    using Volo.Abp.AspNetCore.ExceptionHandling;
    using Volo.Abp.AspNetCore.Mvc;
    using Volo.Abp.AspNetCore.Mvc.Localization;
    using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
    using Volo.Abp.AspNetCore.Mvc.UI.Components.LayoutHook;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton.Bundling;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling;
    using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
    using Volo.Abp.AspNetCore.Serilog;
    using Volo.Abp.Auditing;
    using Volo.Abp.AuditLogging.Web;
    using Volo.Abp.Autofac;
    using Volo.Abp.AutoMapper;
    using Volo.Abp.BackgroundWorkers;
    using Volo.Abp.BackgroundWorkers.Hangfire;
    using Volo.Abp.BlobStoring;
    using Volo.Abp.Hangfire;
    using Volo.Abp.Identity;
    using Volo.Abp.Identity.Web;
    using Volo.Abp.LanguageManagement;
    using Volo.Abp.LeptonTheme.Management;
    using Volo.Abp.Modularity;
    using Volo.Abp.OpenIddict.Pro.Web;
    using Volo.Abp.PermissionManagement.Identity;
    using Volo.Abp.Swashbuckle;
    using Volo.Abp.TextTemplateManagement.Web;
    using Volo.Abp.UI.Navigation;
    using Volo.Abp.UI.Navigation.Urls;
    using Volo.Abp.VirtualFileSystem;
    using Volo.Saas.Host;
    using Volo.Abp.BlobStoring.Azure;
    using Volo.Abp.Ui.LayoutHooks;
    using MyappDb.ShopIntegration;
    using NUglify.JavaScript.Syntax;
    using Volo.Abp.Emailing;
    using Volo.Abp.Localization;
    using Volo.Abp.Uow;
    
    namespace MyappDb.Web;
    
    [DependsOn(
        typeof(MyappDbHttpApiModule),
        typeof(MyappDbApplicationModule),
        typeof(MyappDbEntityFrameworkCoreModule),
        typeof(AbpAutofacModule),
        typeof(AbpIdentityWebModule),
        typeof(AbpPermissionManagementDomainIdentityModule),
        typeof(AbpAccountPublicWebOpenIddictModule),
        typeof(AbpOpenIddictProWebModule),
        typeof(AbpAuditLoggingWebModule),
        typeof(LeptonThemeManagementWebModule),
        typeof(SaasHostWebModule),
        typeof(AbpAccountAdminWebModule),
        typeof(LanguageManagementWebModule),
        typeof(AbpAspNetCoreMvcUiLeptonThemeModule),
        typeof(TextTemplateManagementWebModule),
        typeof(AbpSwashbuckleModule),
        typeof(AbpAspNetCoreSerilogModule),
        typeof(AbpBackgroundWorkersHangfireModule)
    )]
    [DependsOn(typeof(AbpBlobStoringAzureModule))]
    public class MyappDbWebModule : AbpModule
    {
    
        public override void PreConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.PreConfigure(options =>
            {
                options.AddAssemblyResource(
                    typeof(MyappDbResource),
                    typeof(MyappDbDomainModule).Assembly,
                    typeof(MyappDbDomainSharedModule).Assembly,
                    typeof(MyappDbApplicationModule).Assembly,
                    typeof(MyappDbApplicationContractsModule).Assembly,
                    typeof(MyappDbWebModule).Assembly
                );
            });
            
         
    
            PreConfigure(builder =>
            {
                builder.AddValidation(options =>
                {
                    options.AddAudiences("MyappDb"); // Replace with your application name
                    options.UseLocalServer();
                    options.UseAspNetCore();
                });
            });
        }
    
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            var hostingEnvironment = context.Services.GetHostingEnvironment();
            var configuration = context.Services.GetConfiguration();
    
            Configure(options =>
            {
                options.Timeout = DatabaseConst.CommandTimeout;
            });
    
    
            ConfigureUrls(configuration);
            ConfigurePages(configuration);
            ConfigureAuthentication(context, configuration);
            ConfigureImpersonation(context, configuration);
            ConfigureAutoMapper();
            ConfigureVirtualFileSystem(hostingEnvironment);
            ConfigureNavigationServices();
            ConfigureAutoApiControllers();
            ConfigureSwaggerServices(context.Services);
      
            // ConfigureHealthChecks(context);
            ConfigureHangfire(context, configuration);
    
            ConfigurePasswortResetToken(context);
    
            ConfigureAuditLogging();
    
            if (hostingEnvironment.IsDevelopment())
            {
                ConfigureExceptionHandling(context);
            }
            //Replace mail sender
            context.Services.Replace(ServiceDescriptor.Singleton());
    
         
            
            ConfigureAddApplicationInsightsTelemetry(context, configuration);
        }
    
        private void ConfigureAddApplicationInsightsTelemetry(ServiceConfigurationContext context, IConfiguration configuration)
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                return;
    
            }
            context.Services.AddOpenTelemetry().UseAzureMonitor();
    
        }
    
        /// 
        /// Set Token for Registration & Password reset
        /// 
        /// 
        private void ConfigurePasswortResetToken(ServiceConfigurationContext context)
        {
            context.Services.Configure(options =>
                options.TokenLifespan = TimeSpan.FromDays(5));
        }
    
        private void ConfigureAuditLogging()
        {
            bool isEnabled = true;
    
            // #if DEBUG
            //         isEnabled = false;
            // #endif
    
            Configure(options =>
            {
                options.IsEnabled = isEnabled;
    
                options.IsEnabledForGetRequests = false;
                options.EntityHistorySelectors.AddAllEntities();
            });
        }
    
     
    
        private void ConfigurePages(IConfiguration configuration)
        {
            Configure(options =>
            {
                options.Conventions.AuthorizePage("/HostDashboard", MyappDbPermissions.Dashboard.Host);
                options.Conventions.AuthorizePage("/TenantDashboard", MyappDbPermissions.Dashboard.Tenant);
     
            });
        }
    
    
        private void ConfigureUrls(IConfiguration configuration)
        {
            Configure(options => { options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; });
        }
    
        private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults
                .AuthenticationScheme);
        }
    
        private void ConfigureImpersonation(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.Configure(options => { options.EnableTenantImpersonation = false; });
            context.Services.Configure(options => { options.EnableUserImpersonation = true; });
            context.Services.Configure(options =>
            {
                options.TenantAdminUserName = "admin";
                options.ImpersonationTenantPermission = SaasHostPermissions.Tenants.Impersonation;
                options.ImpersonationUserPermission = IdentityPermissions.Users.Impersonation;
            });
        }
    
        private void ConfigureAutoMapper()
        {
            Configure(options => { options.AddMaps(); });
        }
    
        private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
        {
            Configure(options =>
            {
                options.FileSets.AddEmbedded();
    
                if (hostingEnvironment.IsDevelopment())
                {
                    options.FileSets.ReplaceEmbeddedByPhysical(
                        Path.Combine(hostingEnvironment.ContentRootPath,
                            string.Format("..{0}MyappDb.Domain.Shared", Path.DirectorySeparatorChar)));
                    options.FileSets.ReplaceEmbeddedByPhysical(
                        Path.Combine(hostingEnvironment.ContentRootPath,
                            string.Format("..{0}MyappDb.Domain", Path.DirectorySeparatorChar)));
                    options.FileSets.ReplaceEmbeddedByPhysical(
                        Path.Combine(hostingEnvironment.ContentRootPath,
                            string.Format("..{0}MyappDb.Application.Contracts", Path.DirectorySeparatorChar)));
                    options.FileSets.ReplaceEmbeddedByPhysical(
                        Path.Combine(hostingEnvironment.ContentRootPath,
                            string.Format("..{0}MyappDb.Application", Path.DirectorySeparatorChar)));
                    options.FileSets.ReplaceEmbeddedByPhysical(
                        Path.Combine(hostingEnvironment.ContentRootPath,
                            string.Format("..{0}..{0}src{0}MyappDb.HttpApi", Path.DirectorySeparatorChar)));
                    options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath);
                }
            });
        }
    
        private void ConfigureNavigationServices()
        {
            Configure(options => { options.MenuContributors.Add(new MyappDbMenuContributor()); });
    
    ;
        }
    
        private void ConfigureAutoApiControllers()
        {
            Configure(options =>
            {
                options.ConventionalControllers.Create(typeof(MyappDbApplicationModule).Assembly);
            });
        }
    
        private void ConfigureSwaggerServices(IServiceCollection services)
        {
            services.AddAbpSwaggerGen(
                options =>
                {
                    options.SwaggerDoc("v1", new OpenApiInfo
                    {
                        Title = "MyappDb API",
                        Version = "v1"
                    });
                    options.DocInclusionPredicate((docName, description) => true);
                    options.CustomSchemaIds(type => type.FullName);
                    options.DocumentFilter(); //add new document filter
                    options.HideAbpEndpoints();
                }
            );
        }
    
        private void ConfigureExceptionHandling(ServiceConfigurationContext context)
        {
            context.Services.Configure(options =>
            {
                options.SendExceptionsDetailsToClients = true;
            });
        }
    
    
        private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.AddHangfire(config =>
            {
                config.UseSqlServerStorage(configuration.GetConnectionString("Default"));
            });
        }
    
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();
            var env = context.GetEnvironment();
    
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
    
            app.UseAbpRequestLocalization();
    
            if (!env.IsDevelopment())
            {
                app.UseErrorPage();
                app.UseHsts();
            }
    
            app.UseHttpsRedirection();
            app.UseCorrelationId();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
    
            //if (MultiTenancyConsts.IsEnabled)
            //{
            //    app.UseMultiTenancy();
            //}
    
            app.UseUnitOfWork();
            app.UseAuthorization();
            app.UseSwagger();
    
            app.UseAbpSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyappDb API");
                options.EnableFilter();
                //add a new document filteroptions.DocumentFilter();
            });
    
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                app.UseAuditing();
            }
    
            app.UseAbpSerilogEnrichers();
            app.UseConfiguredEndpoints();
    
            //Configure User Access Permission requirements for hangfire
            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                AsyncAuthorization = new[]
                {
                    new AbpHangfireAuthorizationFilter(requiredPermissionName: "AbpAccount.SettingManagement")
                }
            });
    
        }
    
    
    }
    
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Please send your project via email to support@abp.io (with specifying the ticket number). If you did not make any customization, it's weird to see that there is no language-switch component registered in your application.

  • User Avatar
    0
    a3x created

    I send you the code, however, I checked the source coce of the original module and found the issue:

    image.png

    @if (Model.OtherLanguages.Count > 1)
    {
        
    }
    
    

    I have two langauges. This is why OtherLanguages is 1
    Correct code should be:

    @if (Model.OtherLanguages.Count > 0)
    {
        
    }
    

    Maybe you can fix this in the next release.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08