Using resource files
Our minimal API now supports globalization, so it can switch cultures based on the request. This means that we can provide localized messages to callers, for example, when communicating validation errors. This feature is based on the so-called resource files (.resx
), a particular kind of XML file that contains key-value string pairs representing messages that must be localized.
Note
These resource files are exactly the same as they have been since the early versions of .NET.
Creating and working with resource files
With resource files, we can easily separate strings from code and group them by culture. Typically, resource files are put in a folder called Resources
. To create a file of this kind using Visual Studio, let us go through the following steps:
Important note
Unfortunately, Visual Studio Code does not provide support for handling .resx
files. More information about this topic is available at https://github.com/dotnet/AspNetCore.Docs/issues...