---
title: Localizing content
related:
  - https://docs.kentico.com/13/multilingual-websites/setting-up-a-multilingual-user-interface/localizing-builder-components.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

To serve content in multiple languages on your site, you first need to ensure the following:

- Set up [functionality that detects and sets the current culture](https://docs.kentico.com/13/multilingual-websites/setting-up-multilingual-websites/setting-up-culture-detection.md) for each request
- [Assign cultures to your site](https://docs.kentico.com/13/multilingual-websites/setting-up-multilingual-websites.md) in Xperience, and localize the content displayed on the site's pages

## Localizing site content

### Pages in the content tree

To localize content stored within [page fields](https://docs.kentico.com/13/managing-website-content/working-with-pages/editing-pages.md) or edited via the [page builder](https://docs.kentico.com/13/managing-website-content/adding-page-content-using-widgets.md):

- Create separate language versions of pages in the **Pages** application. For detailed information, see [Editing the content of multilingual websites](https://docs.kentico.com/13/multilingual-websites/editing-the-content-of-multilingual-websites.md).
- When [retrieving page content](https://docs.kentico.com/13/developing-websites/retrieving-content/displaying-page-content.md) in the live site application's code, load the correct culture version of pages based on the current culture of the request.

  > **Tip:** You can use the **IPageRetriever** API to automatically retrieve pages matching the culture of the current request. See [Working with pages in the API](https://docs.kentico.com/13/custom-development/working-with-pages-in-the-api.md).

### Independent text strings

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

For individual text strings displayed on the site (which are not stored within page fields), we recommend using multilingual [resource strings](https://docs.kentico.com/13/multilingual-websites/setting-up-a-multilingual-user-interface/working-with-resource-strings.md). You can create and edit the strings in the **Localization** application of the Xperience administration interface.

To retrieve localized strings in the MVC application, add a using statement for the _CMS.Helper&#x73;_&#x6E;amespace, and use the _ResHelper_ class:

```csharp title="Example"

@using CMS.Helpers;
...
@{
    ViewBag.Title = ResHelper.GetString("SiteName.OurProducts");
}

<h2>@ResHelper.GetString("SiteName.OurProducts")</h2>

```

<!-- dev-model:mvc end -->

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

Individual text strings displayed on the site (which are not stored within page fields) can be localized just like in any ASP.NET Core application via strings in resource files.

Follow the practices described in [Microsoft's localization documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization).

> **Note:** **Xperience Localization application**
>
> Text values used within ASP.NET Core live site applications must be stored within localized resource files. For this purpose, you cannot use the **Localization** application of the Xperience administration interface (i.e., resource strings stored in the database).
>
> Such strings can only be [placed into fields](#text-fields-in-the-administration) in the administration using localization macros.

<!-- dev-model:core end -->

### Text fields in the administration

If you need to supply a localized value into a field or text area where localization expressions are supported (such as the [form builder UI](https://docs.kentico.com/13/managing-website-content/forms/localizing-form-fields.md)), you can use expressions in the following formats:

| Format                                                                                                         | Description                                                                                                                                                                          | Sample Value                          |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |
| **Basic format:**<br>{$key$}                                                                                   | Displays the value of the resource string with the specified key. Strings can be viewed and edited in the _.resx_ files of your web projects or in the **Localization** application. | _{$myform.firstname$}_                |
| **In-place localization:**<br>{$=default\_string\|culture\_code=translation\|culture\_code=translation\|etc.$} | Displays the strings defined in the expression.                                                                                                                                      | _{$=Hello\|de-de=Hallo\|it-it=Ciao$}_ |

See also: [Macro syntax](https://docs.kentico.com/13/macro-expressions/macro-syntax.md)

## Localizing validation results and model properties

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

The standard approach for setting validation messages and other text properties of data models is to use attributes from the [System.ComponentModel.DataAnnotations](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations) namespace. The attributes allow you to define common validation patterns, such as range checking, string length and required fields.

Localization of data annotation attributes in Xperience follows the conventional ASP.NET Core pattern. See the [DataAnnotation localization](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization#dataannotations-localization) section in the official ASP.NET Core documentation.

<!-- dev-model:core end -->

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

The default approach to validating the data model of MVC applications is to decorate the model and its properties with attributes from the [System.ComponentModel.DataAnnotations](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations?view=netframework-4.8) namespace. You use the attributes to define common validation patterns, such as range checking, string length and required fields.

The _Kentico.Xperience.AspNet.Mvc5_ [integration package](https://docs.kentico.com/13/developing-websites/starting-with-mvc-development/installing-xperience-integration-packages.md) provides a feature that allows you to use localized [Xperience resource strings](https://docs.kentico.com/13/multilingual-websites/setting-up-a-multilingual-user-interface/working-with-resource-strings.md) as error messages in data annotation attributes. The strings are localized based on the current culture context of the current visitor. The _Kentico.Xperience.LanguagePack.English_ [integration package](https://docs.kentico.com/13/developing-websites/starting-with-mvc-development/installing-xperience-integration-packages.md) (installed with the _Kentico.Xperience.AspNet.Mvc5_ integration package) contains a _.resx_ filewith the resource strings used in the English localization of Xperience. Aside from that, you can also use the standard resource strings stored in the database.

The feature supports localization of the following data annotation attributes:

- _Display_
- _DisplayName_
- _DataType_
- _MaxLength_
- _MinLength_
- _Range_
- _RegularExpression_
- _Required_
- _StringLength_

### Enabling data annotation localization

To enable localization of data annotations in your MVC application:

1. Open your MVC project in Visual Studio.
2. Enable the localization feature by calling the **UseDataAnnotationsLocalization()** method of the _ApplicationBuilder_ instance.

   - Enable the feature at the start of your application's life cycle, for example in the **Application\_Start** method of your project's **Global.asax** file.

     > **Info:** MVC projects created by the [installer](https://docs.kentico.com/13/installation/installing-xperience.md) contain the _ApplicationConfig_ class, whose _RegisterFeatures_ method is called in the _Application\_Start_ method by default. You can use this class to encapsulate all of your _ApplicationBuilder_ code (enabling and configuring of Xperience MVC features).

     ```csharp

     using Kentico.Web.Mvc;

     ...

     protected void Application_Start()
     {
         ...

         // Gets the ApplicationBuilder instance
         // Allows you to enable and configure selected Xperience MVC integration features
         ApplicationBuilder builder = ApplicationBuilder.Current;

         // Enables the data annotation localization feature
         builder.UseDataAnnotationsLocalization();

         ...
     }

     ```

If the feature is enabled, validation results and display names of model properties are localized using Xperience localization services.

```csharp

public class MessageModel
{
...
     [Required(ErrorMessage = "General.RequiresMessage")]
     [Display(Name = "General.Message")]
     [DataType(DataType.MultilineText)]
     [MaxLength(500, ErrorMessage = "General.MaxlengthExceeded")]
     public string MessageText
     {
         get;
         set;
     }
...
}

```

> **Note:** **Note**: Individual error messages are processed by the _System.String.Format_ method and support composite formatting. That is, the strings themselves can contain format items that are specific to each validation attribute and represent their parameters. For example, the _minimum length_ for the _MinLenghtAttribute_ or the _minimum_ and _maximum_ for the _RangeAttribute_.

<!-- dev-model:mvc end -->
