Localize Component
The Localize component inherits from Literal and is functionally identical.
In Web Forms, it marks text as localizable for design-time tooling.
In Blazor, use it for markup compatibility when migrating from Web Forms.
Basic Usage
Hello, World!LiteralMode: PassThrough (renders raw HTML)
Bold text rendered as HTMLLiteralMode: Encode (default — HTML-encodes the text)
<b>Bold text</b> rendered as encoded textLiteralMode: Transform
Text with transform modeUsing with IStringLocalizer (conceptual)
In Web Forms, <asp:Localize> works with resource expressions
(<%$ Resources:MyResource,Greeting %>). In Blazor, inject
IStringLocalizer<T> and pass the localized string to the Text property:
Code:
@inject IStringLocalizer<Index> Localizer
<Localize Text="Hello, World!" />
<Localize Mode="LiteralMode.PassThrough" Text="<b>Bold text</b>" />
<Localize Mode="LiteralMode.Encode" Text="<b>Bold text</b>" />
<Localize Text="@Localizer["Greeting"]" />