Skip to content

Instantly share code, notes, and snippets.

@milosh-96
Created March 5, 2025 00:53
Show Gist options
  • Save milosh-96/d01d1ec1f3fadfb5b45d5583167061e5 to your computer and use it in GitHub Desktop.
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)
@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>
@milosh-96
Copy link
Author

For ContentCulturePicker shape you need to install OrchardCore.ContentLocalization NuGet package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment