--- name: orchardcore-localization description: Skill for configuring localization and multi-language support in Orchard Core. Covers culture settings, content localization, PO file translations, and localization configuration. Use this skill when requests mention Orchard Core Localization, Configure Localization and Multi-Language Support, Enabling Localization Features, Localization Settings via Recipe, PO File Format, PO File Location Convention, or closely related Orchard Core implementation, setup, extension, or troubleshooting work. Strong matches include work with OrchardCore.Localization, OrchardCore.ContentLocalization, IStringLocalizer, LocalizationSettings, IActionResult, IViewLocalizer, LocalizationPart, AlterTypeDefinition, WithPart, IStringLocalizer. It also helps with localization examples, PO File Format, PO File Location Convention, Using Localization in C# Code, plus the code patterns, admin flows, recipe steps, and referenced examples captured in this skill. license: Apache-2.0 metadata: author: CrestApps Team version: "1.0" --- # Orchard Core Localization - Prompt Templates ## Configure Localization and Multi-Language Support You are an Orchard Core expert. Generate localization configuration for multi-language Orchard Core sites. ### Guidelines - Enable `OrchardCore.Localization` for basic localization support. - Enable `OrchardCore.ContentLocalization` for content item translation. - PO files (`.po`) are used for string translations. - Place PO files in the module's `Localization/` folder. - Use `IStringLocalizer` in C# code for localizable strings. - Use `{% t %}` tag in Liquid templates for translations. - Content localization links translated content items together. - Culture picker allows users to switch between languages. ### Enabling Localization Features ```json { "steps": [ { "name": "Feature", "enable": [ "OrchardCore.Localization", "OrchardCore.ContentLocalization", "OrchardCore.ContentLocalization.ContentCulturePicker" ], "disable": [] } ] } ``` ### Localization Settings via Recipe ```json { "steps": [ { "name": "Settings", "LocalizationSettings": { "DefaultCulture": "{{DefaultCulture}}", "SupportedCultures": [ "{{Culture1}}", "{{Culture2}}", "{{Culture3}}" ] } } ] } ``` ### PO File Format Place PO files in `Localization/{culture}.po` (e.g., `Localization/fr.po`): ```po # French translations msgid "Hello" msgstr "Bonjour" msgid "Welcome to {0}" msgstr "Bienvenue à {0}" msgid "Blog Post" msgstr "Article de blog" # Context-specific translation msgctxt "MyModule" msgid "Title" msgstr "Titre" ``` ### PO File Location Convention ``` MyModule/ ├── Localization/ │ ├── fr.po │ ├── es.po │ ├── de.po │ └── ja.po ``` ### Using Localization in C# Code ```csharp using Microsoft.Extensions.Localization; public sealed class MyController : Controller { private readonly IStringLocalizer S; public MyController(IStringLocalizer localizer) { S = localizer; } public IActionResult Index() { ViewData["Title"] = S["Welcome to my site"]; ViewData["Message"] = S["Hello, {0}!", User.Identity.Name]; return View(); } } ``` ### Using Localization in Views (Razor) ```cshtml @inject IViewLocalizer Localizer

@Localizer["Welcome"]

@Localizer["This site has {0} articles.", articleCount]

``` ### Using Localization in Liquid ```liquid {% t "Welcome to our site" %} {% t "Hello, {0}!" User.Identity.Name %} ``` ### Content Localization Content localization connects translated versions of the same content item: ```csharp // Add LocalizationPart to a content type _contentDefinitionManager.AlterTypeDefinition("Article", type => type .WithPart("LocalizationPart") ); ``` ### Culture Picker Widget Add the culture picker to your layout: ```liquid {% shape "ContentCulturePicker" %} ``` ### Configuring Request Culture Providers ```json { "OrchardCore": { "OrchardCore_Localization_CultureProvider": { "CookieName": ".AspNetCore.Culture", "UseUserOverrideCulture": true } } } ``` ### Date and Number Formatting Localized date formatting in Liquid: ```liquid {{ Model.ContentItem.PublishedUtc | local | date: "%x" }} {{ Model.ContentItem.PublishedUtc | local | date: "%B %d, %Y" }} ``` ### Plural Forms in PO Files ```po msgid "One item" msgid_plural "{0} items" msgstr[0] "Un élément" msgstr[1] "{0} éléments" ```