File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Views/Shared
Components/TopBarLanguageSwitch Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ @using AbpCompanyName .AbpProjectName .Web .Views .Shared .Components .TopBarLanguageSwitch
2
+ @model TopBarLanguageSwitchViewModel
3
+ <li class =" dropdown" >
4
+ <a href =" javascript:void(0);" class =" dropdown-toggle" data-toggle =" dropdown" role =" button" >
5
+ <i class =" @Model.CurrentLanguage.Icon" title =" @Model.CurrentLanguage.DisplayName" ></i >
6
+ <span >@Model.CurrentLanguage.DisplayName </span >
7
+ <b class =" caret" ></b >
8
+ </a >
9
+ <ul class =" dropdown-menu pull-right" >
10
+ @foreach ( var language in Model .Languages )
11
+ {
12
+ if (language .Name != Model .CurrentLanguage .Name )
13
+ {
14
+ < li >< a href = " @(ApplicationPath)AbpLocalization/ChangeCulture?cultureName=@(language.Name)&returnUrl=@(Context.Request.Path)" >< i class = " @language.Icon" >< / i > @language .DisplayName < / a >< / li >
15
+ }
16
+ }
17
+ </ul >
18
+ </li >
Original file line number Diff line number Diff line change
1
+ using Abp . Localization ;
2
+ using Microsoft . AspNetCore . Mvc ;
3
+
4
+ namespace AbpCompanyName . AbpProjectName . Web . Views . Shared . Components . TopBarLanguageSwitch
5
+ {
6
+ public class TopBarLanguageSwitchViewComponent : ViewComponent
7
+ {
8
+ private readonly ILanguageManager _languageManager ;
9
+
10
+ public TopBarLanguageSwitchViewComponent ( ILanguageManager languageManager )
11
+ {
12
+ _languageManager = languageManager ;
13
+ }
14
+
15
+ public IViewComponentResult Invoke ( )
16
+ {
17
+ var model = new TopBarLanguageSwitchViewModel
18
+ {
19
+ CurrentLanguage = _languageManager . CurrentLanguage ,
20
+ Languages = _languageManager . GetLanguages ( )
21
+ } ;
22
+
23
+ return View ( model ) ;
24
+ }
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using Abp . Localization ;
3
+
4
+ namespace AbpCompanyName . AbpProjectName . Web . Views . Shared . Components . TopBarLanguageSwitch
5
+ {
6
+ public class TopBarLanguageSwitchViewModel
7
+ {
8
+ public LanguageInfo CurrentLanguage { get ; set ; }
9
+
10
+ public IReadOnlyList < LanguageInfo > Languages { get ; set ; }
11
+ }
12
+ }
Original file line number Diff line number Diff line change 4
4
@using AbpCompanyName .AbpProjectName
5
5
@using AbpCompanyName .AbpProjectName .Web .Resources
6
6
@using AbpCompanyName .AbpProjectName .Web .Views .Shared .Components .SideBarNav
7
+ @using AbpCompanyName .AbpProjectName .Web .Views .Shared .Components .TopBarLanguageSwitch
7
8
@inject AbpCompanyName .AbpProjectName .Timing .AppTimes AppTimes
8
9
@inject IAbpAntiForgeryManager AbpAntiForgeryManager
9
10
@inject IMultiTenancyConfig MultiTenancyConfig
106
107
<!-- Call Search -->
107
108
<li ><a href =" javascript:void(0);" class =" js-search" data-close =" true" ><i class =" material-icons" >search</i ></a ></li >
108
109
<!-- #END# Call Search -->
110
+
109
111
<!-- Notifications -->
110
112
<li class =" dropdown" >
111
113
<a href =" javascript:void(0);" class =" dropdown-toggle" data-toggle =" dropdown" role =" button" >
215
217
</ul >
216
218
</li >
217
219
<!-- #END# Notifications -->
220
+
221
+ @await Component.InvokeAsync(typeof(TopBarLanguageSwitchViewComponent), new { activeMenu = ViewBag .CurrentPageName } )
222
+
218
223
<li class =" pull-right" ><a href =" javascript:void(0);" class =" js-right-sidebar" data-close =" true" ><i class =" material-icons" >more_vert</i ></a ></li >
219
224
</ul >
220
225
</div >
You can’t perform that action at this time.
0 commit comments