According to Microsoft, the Top 50 Windows Phone apps are all available in 8 or more languages. Furthermore: over 70% of all Windows Phones are set to a language other than English. Right there you can clearly see just how important localization is.
This guide focuses on Windows Phone 8.1 apps, but the steps described in this guide are the same for any Windows Store application, including Windows Hub/Grid apps (“Metro apps”). Furthermore, you should have Visual Studio 2013 Update 2 or higher and the Windows Phone SDK installed.
Right-click your Project in the Solution Explorer, choose Properties -> Application -> Package Mainfest… -> and set a default language, that’s ‘en-US’ in most cases. This language will be displayed by the OS when the users preferred language is not available.
In the top level directory of your project, create a new directory named “Strings”. Next, create a new directory for each language you want to ship with your app. Inside the language directories, create a Resources.resw file. The resource files will hold all translated strings.
Your directory structure should now look similar to this:
Now it’s time to move all hard-coded strings in your application to the Resources.resw files. For a typical Windows Phone app there will be two kinds of strings that need to be moved: messages that are generated dynamically by code and hard-coded labels for UI elements stored in the XAML files.
In your XAML files, you may have UI Elements that are declared like this:
// XAML file
<Button Content="Hello World!" VerticalAlignment="Top" Height="50" />
Change this to:
// XAML file
<Button x:Uid="Greeting" />
This will instruct the OS to load the properties (‘Content’, ‘VerticalAlignment’, ‘Height’, …) from the Resources.resw file:
Loading a String from the Resource file in your C# code is also very straightforward:
ResourceLoader resourceLoader = new ResourceLoader();
String hello = resourceLoader.GetString("Greeting.Content");
String bye = resourceLoader.GetString("Goodbye");
More good news: you are done here! Windows Phone does all the magic in the background and loads the right Resources.resw file based on the users language settings.
It is time to test your freshly translated app! Fire up the emulator, go to Home -> Settings -> Language to change the language. Adding a new language requires a full reboot of the Emulator.
Getting Professional Translation And Sharing Resource Files With Translators
If you want to take localization one step further, check out PhraseApp, a service that helps you manage your translation process online. You can even order professional translations with the click of a button.
The PhraseApp Visual Studio Plugin integrates seamlessly with Visual Studio. It let’s you push and pull translation to and from PhraseApp, making the translation workflow easier.
Be sure to subscribe and receive all updates from the PhraseApp blog straight to your inbox. You’ll receive localization best practices, about cultural aspects of breaking into new markets, guides and tutorials for optimizing software translation and other industry insights and information. Don’t miss out!
Also published on Medium.