Click here to Skip to main content
Click here to Skip to main content

Windows Phone Internationalization

, 9 May 2012
Rate this:
Please Sign up or sign in to vote.
Simple way to do internationalization on your Windows Phone app.

Introduction

I originally posted this article on BlogMarq, but felt it might be useful for more people to see.

Background

I used this solution in my #Top10 Windows Phone App #Notebox. Internationalization doesn’t have to be that difficult. I have recently internationalized #Notebox using the following method.

First, I added a helper class that will act as my store for the current culture strings/phrase for use in my View bindings:

public class InternationalizationHelper
{
   private static readonly AppResources LocalizedResource = new AppResources();

   public AppResources Resources
   {
      get { return LocalizedResource; }
   }
}

Next, I made this class available to my Views by adding this line to my App.xaml:

<Code:InternationalizationHelper x:Key="localizedResx" />

Now for the actual strings and phrases. I added a Resources file called “AppResources.resx” to my project and started adding the Name/Value strings. E.g., Name="LoginPageTile", Value="Login Page". This default resources file will be used by the application Neutral Language, which can be found on the Project Properties, Assembly Info panel. To add further support for other languages, I needed to do twp things:

  • Add support for the culture to the Visual Studio project file (edit the proj file and add to the SupportCulture section). E.g.:
  • <SupportedCultures>it-IT;el-GR;es-ES;</SupportedCultures>
  • Add a AppResources.xx-XX.resx for each culture you want to support, where “xx-XX” is the culture code.
  • For this to work, all of the resource files must use the same key name(s). If a resource file for a particular culture does not contain the key name then the default AppResources.resx name entry will be used.

    The final step was to refer to these names within the Resources file. This was achieved using a binding like this:

    Text="{Binding Path=Resources.LoginPageTitle, Source={StaticResource localizedResx}}"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Paul Marques
Software Developer ByteMarq
United Kingdom United Kingdom
Director, ByteMarq Ltd - Windows Phone App development
 
#Notebox Pro #WindowsPhone App - secure note taking made simple
 
Follow me on Twitter @bytemarq
 
Some quotes I like because I'm a 2 wheeled racing fan:
 
"Racing is life. Anything before or after is just waiting." (Steve McQueen)
 
"Life is like a fast qualifying lap, you only get one chance so might as well make it a good one." (Unknown)
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 9 May 2012
Article Copyright 2012 by Paul Marques
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid