Localize the UI

Abstract

Overview of how to add a new language for localization.

The Sitecore Identity (SI) server uses ASP.NET Core services and middleware to localize to different languages and cultures. You store the messages that the SI server returns in the <application_root>\localization folder. The files are named in the common Sitecore localization file name format (languageName-cultureName.xml).

To add a new language for localization:

  1. Copy the localization file to the <application_root>\localization folder on the SI server.

  2. Restart the SI server application.

The SI server uses ASP.NET Core request providers to select language and culture for each request. For each request, the SI server uses the first provider in the following list that can determine what request culture is used:

  • StoredQueryStringCultureProvider

    If the UI culture is set in a query string, the StoredQueryStringCultureProvider provider resolves the language and culture and stores it in a browser cookie to use with subsequent requests.

    The following example sets the specific culture (language and region) to Spanish/Mexico:

        http://localhost:5000/?culture=es-MX
  • CookieRequestCultureProvider

    If the language and culture are not specified in a query string, the CookieRequestCultureProvider provider resolves the language and culture from the browser cookie. The .AspNetCore.Culture cookie is used by default.

  • AcceptLanguageHeaderRequestCultureProvider

    If the language and culture are not specified in a query string or in the cookie, the AcceptLanguageHeaderRequestCultureProvider provider resolves the language and culture from the Accept-Language request HTTP header of the browser. Browsers set values for this header according to the user interface language that they are using.

You can specify the default request language that should be used if none of the providers can be resolved, You specify the default request language in the Sitecore.identityServer.Host.xml file, in the DefaultCulture setting:

<Settings>
  <Sitecore>
    <IdentityServerHost>
      <DefaultCulture>en</DefaultCulture>
    </IdentityServerHost>
  </Sitecore>
</Settings>

The SI server uses culture fallback when it searches for localization resources. It starts at the requested culture. If it cannot find this, it goes to the parent culture of that culture. This normally, but not always, means that is removes the national signifier from the ISO code. For example, the dialect of Spanish spoken in Mexico is es-MX. The parent is es: Spanish that is not specific to any country.