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 HTML

LiteralMode: Encode (default — HTML-encodes the text)

<b>Bold text</b> rendered as encoded text

LiteralMode: Transform

Text with transform mode

Using 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:

Welcome! (from a localized resource)

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"]" />