Supporting multiple languages – localization
To support multiple languages, we can use the .NET built-in mechanism for localizing applications. In a XAML file, we can use the x:Static
markup extension to use the string defined in resource files.
Creating a .resx file
Resource files are XML files with a .resx
extension that are compiled into binary resource files during the build process. A resource file can be added by right-clicking the project node and selecting Add > New Item... > Resources File, as shown in Figure 3.7:
Figure 3.7: Creating a Resources File
We can create the Resources.resx
resource file in the Properties
folder.
To support different cultures, we can add additional resource files with cultural information as part of the resource file’s name:
Resources.resx
: The resource file for the default culture, which we will set toen-US
(US English) laterResources.zh-Hans.resx
: The resource file for the...