Created
March 5, 2025 00:53
-
-
Save milosh-96/d01d1ec1f3fadfb5b45d5583167061e5 to your computer and use it in GitHub Desktop.
Orchard Core Content Culture Picker shape rendered in a razor Layout (CSHTML)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using System.Globalization | |
@using OrchardCore.ContentLocalization.ViewModels | |
@using OrchardCore.Localization | |
@inject ILocalizationService localizationService | |
<!DOCTYPE html> | |
<html lang="@Orchard.CultureName()" dir="@Orchard.CultureDir()"> | |
<head> | |
<title>Welcome</title> | |
</head> | |
<body> | |
<header> | |
@{ | |
List<string> cultures = (await localizationService.GetSupportedCulturesAsync()).ToList(); | |
List<CultureInfo> cultureInfos = new List<CultureInfo>(); | |
cultures.ForEach(c => cultureInfos.Add(CultureInfo.GetCultureInfo(c))); | |
CultureInfo currentCulture = CultureInfo.GetCultureInfo(Orchard.CultureName()); | |
} | |
<shape Type="ContentCulturePicker" prop-SupportedCultures=cultureInfos prop-CurrentCulture=currentCulture></shape> | |
<hr /> | |
</header> | |
<main> | |
@await RenderBodyAsync() | |
</main> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For ContentCulturePicker shape you need to install OrchardCore.ContentLocalization NuGet package.