Chapter 13. Resources and Localization
In this chapter we look at how we can localize our apps—that is, make them functional in different languages.
The general premise of localization remains unchanged from years gone by. Operationally, we have usually done this by creating a table containing strings, which are then used to replace static text on the UI. You then create copies of the table for each language that you want to support. Windows works out which table to use based on the user’s systemwide language preferences.
The story in WinRT for handling strings is different from how it was in .NET. You now add .resw files to projects, rather than .resx files. The APIs for loading the strings are, as you’ve probably guessed, different. The process by which strings are packaged along with the app is also different. Strings are not embedded into the DLL but are combined into a .pri file that is deployed along with the app. So, we’ll look in detail at how that works as we go.
Then, we’ll look at how to replace strings in the XAML markup, how to explicitly load strings, and how we can localize images. We’ll also cover a special feature that allows us to package multiple image resources that are selected out depending on the DPI of the display.
.pri files, or Package Resource Index files, are the new file format used with WinRT and in Windows Store app development. They are a binary format that represents the hierarchy of resources used in your app and any dependencies. In Windows ...