Provides guidance on PO, data, and content localization in Orchard Core: culture settings, localizers (S, H, T), pluralization, POT extraction, OCLOC diagnostics, and admin culture picker.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Goal | Use |
|---|---|
| Translate a label or message in C#, Razor or Liquid | PO localization (OrchardCore.Localization) with S, H or T and a PO file |
| Count-dependent text ("1 item" / "{0} items") | Plural() and a PO msgid_plural entry |
| Text declared where no localizer or culture exists (static fields, permissions, deployment steps, descriptors) | LocalizationSource, see orchardcore-localization-source |
| Translate data-driven values (content type names, context-free permission descriptions, custom dynamic strings) | Data Localization (OrchardCore.DataLocalization), see orchardcore-data-localization |
| Translate content items (a blog post in French) | Content Localization (LocalizationPart), see orchardcore-content-localization |
| Add a supported culture or change the default one | Culture settings below |
| Feature | Purpose |
|---|---|
OrchardCore.Localization | PO localization, culture settings (Settings → Localization → Cultures), request localization. |
OrchardCore.Localization.ContentLanguageHeader | Adds the Content-Language response header. |
OrchardCore.Localization.AdminCulturePicker | Admin navbar culture picker (admin culture cookie), shown when more than one culture is supported. |
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Localization",
"OrchardCore.Localization.AdminCulturePicker"
]
},
{
"name": "Settings",
"LocalizationSettings": {
"DefaultCulture": "en-US",
"SupportedCultures": ["en-US", "fr-FR"],
"FallBackToParentCulture": true
}
}
]
}
| Property | Description |
|---|---|
DefaultCulture | Default request culture, for example en-US. |
SupportedCultures | Cultures the site accepts, used for both culture and UI culture. A culture must be listed before content can be translated into it. |
FallBackToParentCulture | Fall back from fr-CA to fr when looking up translations and cultures. |
The module applies these settings with app.UseRequestLocalization() when the
tenant starts. The cultures page requires
OrchardCore.Localization.LocalizationPermissions.ManageCultures. The
Culture settings deployment step exports LocalizationSettings. Read the
configured cultures through ILocalizationService
(GetDefaultCultureAsync(), GetSupportedCulturesAsync(),
GetAllCulturesAndAliases(), FallBackToParentCultures).
Host-level culture behavior is configured in OrchardCore:Localization:CultureOptions:
{
"OrchardCore": {
"Localization": {
"CultureOptions": {
"IgnoreSystemSettings": true
}
}
}
}
IgnoreSystemSettings stops the OS user's custom date and number formats from
affecting cultures. Do not invent other localization configuration sections.
| Provider | Picks the culture from |
|---|---|
ContentRequestCultureProvider (Content Localization) | The culture of the localized content item matched by the route; added first. |
AdminCookieCultureProvider (Admin Culture Picker) | The admin_culture_{tenant VersionId} cookie, on admin paths only. |
| ASP.NET Core defaults | Query string, cookie, then Accept-Language. |
| Symbol | Type | Use in | Output |
|---|---|---|---|
S | IStringLocalizer<T> field | Services, drivers, handlers, controllers | LocalizedString, encoded by Razor when rendered |
H | IHtmlLocalizer<T> field | Messages whose translation contains trusted markup | LocalizedHtmlString, markup kept, arguments encoded |
T | IViewLocalizer property | Razor views (already on the Orchard Core RazorPage) | LocalizedHtmlString |
Inject the localizer typed to the class that owns the string, and name the
field S (or H) so extraction tools find the calls:
using Microsoft.Extensions.Localization;
namespace MyModule.Services;
public sealed class GreetingService
{
internal readonly IStringLocalizer S;
public GreetingService(IStringLocalizer<GreetingService> stringLocalizer)
{
S = stringLocalizer;
}
public string Greet(string name, int count)
=> S["Hello {0}!", name] + " " + S.Plural(count, "{0} new message", "{0} new messages");
}
In Razor views write @T["..."] directly. When plain text is needed (an
attribute set in code, a list of strings, a SelectListItem), use
T.GetString("..."), not T["..."].Value, which double-encodes entities and
drops the format arguments.
In Liquid, use the t filter, and transliterate to convert text to ASCII. Named arguments of t are format arguments in their order, and their names describe the placeholders to translators; note is a translator note, not an argument:
{{ "Welcome to our site" | t }}
{{ "Hello {0}!" | t: User.Identity.Name }}
{{ "in {0} years" | t: years: time.years, note: "Relative date shown for future dates." }}
{{ "Ελληνικά" | transliterate }}
Keep keys compile-time constants (or Liquid literals) and pass values as format arguments, so the extraction can find every string.
Plural() is an extension from OrchardCore.Localization.Abstractions on
IStringLocalizer, IHtmlLocalizer and IViewLocalizer:
S.Plural(count, "{0} book", "{0} books");
H.Plural(count, "{0} <b>new</b> book", "{0} <b>new</b> books");
S.Plural(count, ["{0} book on {1}", "{0} books on {1}"], shelfName); // forms array; shelfName is {1}
count replaces {0}; extra arguments are {1}, {2}, and so on.msgid, the plural text the msgid_plural.Plural-Forms
header (gettext C expression over n, evaluated with the absolute count), so
the msgstr[n] order always matches the file's own header. An out-of-range
form selects msgstr[0].Plural() forms), an IPluralRuleProvider rule
for the culture applies. DefaultPluralRuleProvider walks CultureInfo.Parent
(zh-Hans-CN → zh-Hans → zh) and implements the CLDR 49 integer
cardinal rules (Arabic six forms, Russian three; French, Spanish, Italian and
Portuguese gain many at index 2 for nonzero multiples of 1,000,000).services.AddSingleton<IPluralRuleProvider, MyPluralRuleProvider>();
a negative Order runs it before the default provider, a positive one makes it a fallback.CultureDictionaryRecord.PluralRule (set by PoParser from the header) and
CultureDictionary.GetPluralRule(key) expose the rule applied to a translation.msgid ""
msgstr ""
"Language: cs\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
Notes and argument names are written as comments of the message in the translation template and are ignored at runtime. Use them only where a translator could not otherwise understand a message (an ambiguous word such as "Open", a format pattern, an unclear placeholder):
using static OrchardCore.Localization.LocalizationMetadata; // Razor views inherit Arg() from the base page.
H.Plural(note: "Relative date shown for future dates.", count: Arg("years", years), singular: "in 1 year", plural: "in {0} years");
S.Note("Greeting shown on the dashboard.")["Hello {0}", Arg("user name", user.Name)];
// Bounded plural count, written as the gettext range flag (#, csharp-format, range: 0..23).
H.Plural(Arg("hours", time.Hours, 0, 23), "1 hour ago", "{0} hours ago");
Arg(name, value) returns value unchanged; Arg(name, count, min, max)
returns count and only applies to the count of a Plural call (constant
bounds, 0 <= min <= max). Only declare a range the code guarantees.Note(note) is an extension on IStringLocalizer/IHtmlLocalizer (and
IViewLocalizer) that returns the same localizer; the Plural extensions
also have overloads taking note first.// TRANSLATORS: comment on the line above a C# call is extracted as a note too.LocalizationSource, pass note: to Create (see orchardcore-localization-source).The PO msgctxt must exactly match the localizer scope, or the msgid is
shown untranslated:
{Namespace}.{Class} for IStringLocalizer<T> and IHtmlLocalizer<T>
(the type's full name; an inner class + becomes .)TheAdmin.Views.Layout or MyModule.Views.Home.Indexmsgctxt "MyModule.Services.GreetingService"
msgid "Hello {0}!"
msgstr "Bonjour {0} !"
msgctxt "MyModule.Views.Home.Index"
msgid "Read more"
msgstr "Lire la suite"
To use another context, inject IStringLocalizerFactory (or
IHtmlLocalizerFactory):
S = factory.Create(typeof(SharedMessages)); // msgctxt "MyModule.SharedMessages"
_shared = factory.Create("MySharedContext", string.Empty); // msgctxt "MySharedContext"
The PO localizer factory caches the localizers it creates, so resolving one per lookup is cheap.
For fr-CA, ModularPoFileLocationProvider loads PO files from these
locations in order (the culture name can also be the neutral fr, used for
fr-CA when falling back to parent cultures):
{Extension}/Localization/fr-CA.po for each module and theme, in extension order/Localization/fr-CA.po in the web projectApp_Data/Sites/{tenant}/Localization/fr-CA.po/Localization/{ExtensionId}/fr-CA.po, /Localization/{ExtensionId}-fr-CA.po, /Localization/fr-CA/{ExtensionId}.po.po file in /Localization/fr-CA//Localization/ over App_Data in Docker: mounting a volume at
App_Data hides the files that were in the image.Localization folder are embedded in the module
assembly automatically. Include the web project's files in publish output:<ItemGroup>
<Content Include="Localization\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Community translations of Orchard Core itself are on Crowdin
(https://crowdin.com/project/orchard-core).
If a PO entry with a msgctxt has an empty msgstr, its context no longer
leaks onto the following entry without msgctxt; that entry is now loaded as a
context-free translation, as written.
Orchard Core 4.0 replaces PoExtractor with build-time, Roslyn-based extraction.
Each project keeps a checked-in gettext template, <AssemblyName>.pot, next to
its project file; a normal build only embeds it as the
<AssemblyName>.Localization.pot resource and never extracts. Add the package
to every project whose strings should be extracted (referencing it from the web
project alone does not cover modules):
<PackageReference Include="OrchardCore.Localization.Build" Version="4.*" PrivateAssets="all" />
# One project (its references are not updated).
dotnet msbuild src/MyModule/MyModule.csproj -restore -t:UpdateLocalizationCatalog
# An application and its project references, or a whole solution.
dotnet build src/MyApp.Web/MyApp.Web.csproj -p:UpdateLocalizationCatalogs=true
# Copy the templates to one folder for Crowdin (absolute path; does not update them).
dotnet build MySolution.slnx -p:LocalizationCatalogOutputPath="$PWD/artifacts/localization"
LocalizationSource
declarations, plural calls, Razor views and pages, literal Liquid t inputs
and constant DataAnnotations ErrorMessage values. It does not scan
JavaScript/TypeScript; expose those strings through a C# IJSLocalizer.LocalizationCatalogLineNumbers=true); DEBUG/TRACE code is not
extracted, and a multi-targeted project uses its first target framework.
Commit them with the strings they describe, and keep their msgstr empty.msgctxt,
plurals and placeholders), then deploy the translated PO files to a location
listed above. Embedded POT files do not change runtime translations.GenerateLocalizationCatalog (false disables embedding and
updating), UpdateLocalizationCatalogs, LocalizationCatalogPath,
LocalizationStrict (fail on extraction warnings), LocalizationCatalogOutputPath,
LocalizationViewPrefix. Add extra Liquid inputs with
<LocalizationLiquid Include="Templates/**/*.liquid" />.[SkipLocalizationExtraction] (namespace OrchardCore.Localization); it is
not inherited, and callers of the helper are still extracted.| Diagnostic | Meaning |
|---|---|
OCLOC101-OCLOC104 (IDE/build analyzers in OrchardCore.Abstractions) | LocalizationSource without context, foreign context (info), non-constant source value, non-constant localizer key. See orchardcore-localization-source. |
OCLOC001-OCLOC004 | Non-constant key, unresolved context, plural array without exactly two constant forms, empty key (warnings). |
OCLOC005 | Same context and key declared with conflicting plural forms (error). |
OCLOC006-OCLOC009 | Razor compiler, Liquid parse, C# compilation or worker failures. |
OCLOC010 / OCLOC011 | Non-constant note or argument name / invalid Arg range; the message is extracted without it. |
Fix dynamic keys at the source instead of suppressing diagnostics; for a key
that is dynamic by design, disable OCLOC104 around that call with a comment
saying where the values are declared.
The Localization module registers AddDataAnnotationsPortableObjectLocalization(),
so ValidationAttribute error messages are translated with PO files. All of
them share the OrchardCore.Localization.DataAnnotations.LocalizedDataAnnotationsMvcOptions
context. An explicit ErrorMessage is looked up as is, then with the
[Display(Name)] or property name replaced by {0}. A default message is looked
up formatted with the name ("The UserName field is required."), then as its
unformatted template ("The field {0} must be between {1} and {2}."), then with
the name replaced by {0}. Translations of templates keep their placeholders,
which the attribute fills with its own arguments (range, length, pattern). A
message without a translation, or set with ErrorMessageResourceName, is left
unchanged. A [RegularExpression] pattern containing braces, such as
^#[0-9a-fA-F]{6}$, no longer fails with a FormatException (500) when
localization is enabled (#20343).
msgctxt "OrchardCore.Localization.DataAnnotations.LocalizedDataAnnotationsMvcOptions"
msgid "The {0} field is required."
msgstr "Le champ {0} est obligatoire."
msgctxt "OrchardCore.Localization.DataAnnotations.LocalizedDataAnnotationsMvcOptions"
msgid "The field {0} must be between {1} and {2}."
msgstr "Le champ {0} doit être compris entre {1} et {2}."
When a string is declared where no localizer or culture is available, declare
a LocalizationSource and translate it at display time. Permission.Description,
DeploymentStep.Category/Title, and the Data Sources and Data Pipelines
descriptors use it in Orchard Core 4.0. Reuse CommonLocalizationSources
(for example CommonLocalizationSources.ContentManagement, PO context
OrchardCore.Localization.CommonLocalizationSources) for text several modules
share, and declare the rest in an internal {Module}LocalizationSources class.
The full guide (API, notes, analyzers, plurals, PO entries, Data Localization
interaction, migration) is orchardcore-localization-source.
Decorate every instance property of type LocalizationSource with [JsonIgnore]
(System.Text.Json.Serialization), and repeat it on overrides, since it is not
inherited; static properties don't need it. A source is a static declaration
and is never serialized or deserialized: the JSON converter of earlier 4.0
previews was removed, and the YesSql document, JOptions, MVC and SignalR
serializers drop every property holding a source from their contract
(LocalizationSourceJsonModifier). Call options.IgnoreLocalizationSources()
(OrchardCore.Json.Extensions) on your own JsonSerializerOptions. Persist a
plain string key and map it to a static source at display time.
private static readonly LocalizationSource s_saved =
LocalizationSource.Create<WidgetService>("Widget {0} saved.");
var text = stringLocalizerFactory.Localize(s_saved, widgetName); // msgctxt "MyModule.WidgetService"
Implement IJSLocalizer (register as scoped) to expose PO-backed strings for a
group, then pass Orchard.GetJSLocalizations("my-group") serialized as JSON to
the front-end component, which seeds the @orchardcore/bloom translations store
with setTranslations() and reads it with getTranslations(). The keys inside
GetLocalizations are ordinary C# localizer calls, so they are extracted into
the module's POT template; JavaScript files themselves are not scanned.
LocalizationPart links translations with LocalizationSet and stores each
item's Culture; IContentLocalizationManager.LocalizeAsync(item, culture)
creates a translation. The front-end content culture picker, the
localization_set and switch_culture_url Liquid filters, and the
ContentCulturePickerSettings recipe settings belong to Content Localization
(see orchardcore-content-localization).
OrchardCore.Localization.AdminCulturePicker only affects the admin area and
uses the admin culture cookie provider.
msgctxt is the most common cause of an untranslated string; check
the namespace and class of the localizer's type, or the view path.IStringLocalizer<T> typed to the class that owns the strings, not a
base class or a shared type, unless you deliberately want that context.msgid.H/IHtmlLocalizer only for trusted translation markup.LocalizedString values in static fields or singletons; they
capture one culture. Use LocalizationSource instead.Plural-Forms header and that its msgstr[n] order matches it. Missing
indexes throw PluralFormNotFoundException.OrchardCore_Localization_CultureOptions → OrchardCore:Localization:CultureOptions
(the old name still binds but is deprecated).OrchardCore.Localization.Permissions.ManageCultures was removed; use
OrchardCore.Localization.LocalizationPermissions.ManageCultures.Permission.Description is a LocalizationSource instead of a string, and
DeploymentStep.Category/Title are LocalizationSource instead of
LocalizedString. Built-in permission descriptions are now translated with
PO files instead of Data Localization. See orchardcore-localization-source
for the before/after code. Recompile modules.IDataResourceStringProvider was removed; use ILocalizationDataProvider.OrchardCore.Localization.Build and checked-in
<AssemblyName>.pot templates. Upload those to Crowdin instead of running
extractpo.Plural-Forms header now use it instead of the
culture's rule. Catalogs without a header follow the CLDR 49 rules, which
changed several languages: add many at index 2 for fr, pt, ca, es,
gl, it; two for he, sat, se (index 2) and mt (index 4); split
single-form fa, vi, ka, kk, ky, ug, cgg catalogs; jv and yo now
use one form; review zero for hi, bn, gu, tr, uz and others; negative
counts use the positive magnitude. Or add a matching Plural-Forms header to keep a catalog's order.*LocalizationSources classes; update the
msgctxt of PO entries that translated them (see orchardcore-localization-source).Official Orchard Core videos shown on the documentation page:
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-localizationfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job