Orchard Core Localization
Use OrchardCore.Localization for UI localization and
OrchardCore.ContentLocalization for translated content items. Configure the
default and supported cultures in the site settings UI or with a root recipe:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Localization",
"OrchardCore.ContentLocalization",
"OrchardCore.Localization.AdminCulturePicker"
]
},
{
"name": "Settings",
"LocalizationSettings": {
"DefaultCulture": "en-US",
"SupportedCultures": ["en-US", "fr-FR"],
"FallBackToParentCulture": true
}
}
]
}
The localization module uses these settings to configure request
localization. Do not invent an OrchardCore_Localization_CultureProvider
configuration section.
In Orchard Core 3.0, ILocalizationService exposes culture lookup through
an instance service method. Do not call a static default implementation.
PoParser is static; use PoParser.Parse or PoParser.ParseAsync for PO
file parsing.
UI Strings
Use the localizer typed to the class that owns the string:
private readonly IStringLocalizer<MyController> _localizer;
public MyController(IStringLocalizer<MyController> localizer)
{
_localizer = localizer;
}
In Liquid, use the t filter:
{{ "Welcome to our site" | t }}
{{ "Hello {0}!" | t: User.Identity.Name }}
PO Contexts and Locations
The PO msgctxt must exactly match the localizer scope:
{Namespace}.{Class}forIStringLocalizer<T>{Namespace}.{ViewPath}for a Razor view
msgctxt "MyModule.Controllers.HomeController"
msgid "Welcome to our site"
msgstr "Bienvenue sur notre site"
msgctxt "MyModule.Views.Home.Index"
msgid "Read more"
msgstr "Lire la suite"
For fr-CA, the provider checks these locations in order:
{Extension}/Localization/fr-CA.po/Localization/fr-CA.poApp_Data/Sites/{tenant}/Localization/fr-CA.po/Localization/{ExtensionId}/fr-CA.po/Localization/{ExtensionId}-fr-CA.po/Localization/fr-CA/{ExtensionId}.po, then each.poin that culture folder
Content and Admin Culture Pickers
LocalizationPart links translations with LocalizationSet and stores each
item's Culture. The content culture picker is a separate content-localization
feature. OrchardCore.Localization.AdminCulturePicker instead adds a navbar
shape in the admin area when more than one supported culture is configured; it
uses the admin culture cookie provider and does not render a front-end picker.