Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Windows Phone Internationalization

0.00/5 (No votes)
9 May 2012 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here