Localizing and globalizing with ASP.NET Core
In Chapter 7, Handling Dates, Times, and Internationalization, you learned about working with dates, times, time zones, and how to globalize and localize a .NET codebase.
In this section, we will look specifically at how to localize a website that uses ASP.NET Core.
As well as localizing string
values using IStringLocalizer
, you can localize HTML values using IHtmlLocalizer
, but this should be done with care. Usually, HTML markup should be the same for all locales. For views, you can use IViewLocalizer
.
Let’s create some resource files to localize the web user interface into American English, British English, and French, and then globalize the data like dates and currency values:
- In the
Northwind.Mvc
project, add a new folder namedResources
. This is the default name for the folder that localizer services look in for*.resx
resource files. - In
Resources
, add a new folder namedViews
. - In
Views
, add...