From 74a34ea95c860bbca58b34cbcc5608d7d7e1b6ed Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 27 Jun 2018 11:35:12 +0300 Subject: [PATCH] Resolved #312: Add language switch only if there are multiple languages. --- .../BasicThemeMainTopToolbarContributor.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs index eda14baeb7..3c86a68a82 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs @@ -1,4 +1,8 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.UserMenu; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; @@ -19,7 +23,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Toolbars return Task.CompletedTask; } - context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitchViewComponent))); + var requestLocalizationOptions = context.ServiceProvider.GetService>(); + + if (requestLocalizationOptions.Value.SupportedCultures.Count > 1) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitchViewComponent))); + } + context.Toolbar.Items.Add(new ToolbarItem(typeof(UserMenuViewComponent))); return Task.CompletedTask;