This blog post is part of a series about how Windows Phone 8.1 affects developers. This blog post talks how to localize your apps and is written by Johan Olsson at Jayway and was originally posted here.


When you create an app that is to be released in more than one market you must globalize and localize your app. A globalized app displays data, such as dates and numbers, in the culture format of the user. A localized app is adapted to a specific local market. This mostly involves text strings in you app being translated to other languages, like French or German With the release of Windows Phone 8.1 the way you localize your app has changed. It is now more consistent with how you localize a Windows Store app.


How it was done in Windows Phone 8.0

Adding language resources

You add languages by checking the language in the project properties. 1 This will automatically add one .resx file for each language. 2  


Accessing resources from xaml

3 Assuming you have a resource named “SampleProperty”, you show the string by binding to in Xaml.
<TextBlock Text="{Binding LocalizedResources.SampleProperty, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />

How it is done in Windows Phone 8.1

Adding resource files

You do not specify what languages you support in the project properties any more. You only specify the default language in the app manifest. 4 You have to manually add one .resw file for each language you support. The files must all be named Resources.resw and must be placed in a sub-folder, named after the language, under a “Strings” folder in your project. 5  


Accessing resources from xaml

You access the resources by setting the x:Uid property of a control to a unique name. Unfortunately the x:Uid property is not recognized by the properties window, neither in VisualStudio nor in Blend, so you must hand code it directly in the xaml file. Example:
<TextBlock x:Uid="MyTextBlock" />
<Button x:Uid="MyButton" />
You must then add a resource with the uid-name with dot-notation, that is, after the dot you write the name of the property of the control in which you want the text. Like in the picture below. 6   If you have a control with more than one text property, like the new ToggleSwitch control, you set the uid once and then add one resource for each property.
<ToggleSwitch x:Uid="MyToggleSwitch" />



Yes, it is a bit more complicated to localize an app in 8.1 and the potential for mistakes is greater. I do expect that in time the tooling will get better, but for now you just have to be a bit more careful with your resources.