4.1 KiB
title | author | description | ms.author | monikerRange | ms.date | uid |
---|---|---|---|---|---|---|
Globalization and localization in ASP.NET Core | rick-anderson | Learn how ASP.NET Core provides services and middleware for localizing content into different languages and cultures. | riande | >= aspnetcore-3.1 | 02/23/2023 | fundamentals/localization |
Globalization and localization in ASP.NET Core
:::moniker range="> aspnetcore-5.0"
By Rick Anderson, Damien Bowden, Bart Calixto, Nadeem Afana, and Hisham Bin Ateya
A multilingual website allows a website to reach a wider audience. ASP.NET Core provides services and middleware for localizing into different languages and cultures.
Terms
- Globalization (G11N): The process of making an app support different languages and regions. The abbreviation comes from the first and last letters and the number of letters between them.
- Localization (L10N): The process of customizing a globalized app for specific languages and regions.
- Internationalization (I18N): Both globalization and localization.
- Culture: A language and, optionally, a region.
- Neutral culture: A culture that has a specified language, but not a region (for example "en", "es").
- Specific culture: A culture that has a specified language and region (for example, "en-US", "en-GB", "es-CL").
- Parent culture: The neutral culture that contains a specific culture (for example, "en" is the parent culture of "en-US" and "en-GB").
- Locale: A locale is the same as a culture.
Language and country/region codes
The RFC 4646 format for the culture name is <language code>-<country/region code>
, where <language code>
identifies the language and <country/region code>
identifies the subculture. For example, es-CL
for Spanish (Chile), en-US
for English (United States), and en-AU
for English (Australia). RFC 4646 is a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code associated with a country or region. For more information, see xref:System.Globalization.CultureInfo?displayProperty=fullName.
Tasks to localize an app
Globalizing and localizing an app involves the following tasks:
- Make an ASP.NET Core app's content localizable.
- Provide localized resources for the cultures the app supports
- Implement a strategy to select the culture for each request
View or download sample code (how to download)
Additional resources
IStringLocalizer
: Uses the xref:System.Resources.ResourceManager and xref:System.Resources.ResourceReader to provide culture-specific resources at run time. The interface has an indexer and anIEnumerable
for returning localized strings.IHtmlLocalizer
: For resources that contain HTML.- View and DataAnnotations
- xref:fundamentals/troubleshoot-aspnet-core-localization
- Globalizing and localizing .NET applications
- Resources in .resx Files
- Microsoft Multilingual App Toolkit
- Localization & Generics
:::moniker-end
[!INCLUDE localization35]