-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
ContentCulturePicker.cshtml
36 lines (31 loc) · 1.33 KB
/
ContentCulturePicker.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@using Microsoft.AspNetCore.Localization
@using OrchardCore.Localization
@using System.Globalization
@inject ILocalizationService LocalizationService
@{
var supportedCultures = (await LocalizationService.GetSupportedCulturesAsync()).Select(c => CultureInfo.GetCultureInfo(c));
if (supportedCultures.Count() < 2)
{
return;
}
var currentCulture = Context.Request.HttpContext.Features
.Get<IRequestCultureFeature>()?.RequestCulture?.Culture ?? CultureInfo.CurrentUICulture;
}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="oc-culture-picker" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">@currentCulture</a>
<div class="dropdown-menu" aria-labelledby="oc-culture-picker">
@foreach (var culture in supportedCultures)
{
if (culture.Name == currentCulture.Name)
{
continue;
}
<a asp-route="RedirectToLocalizedContent"
asp-route-area="OrchardCore.ContentLocalization"
asp-route-targetCulture="@culture.Name"
asp-route-contentItemUrl="@Context.Request.Path.Value"
asp-route-queryStringValue="@Context.Request.QueryString.Value"
class="dropdown-item">@culture.NativeName</a>
}
</div>
</li>