Click here to Skip to main content
15,886,137 members
Articles / Mobile Apps / Windows Phone 7
Tip/Trick

Windows Phone Internationalization

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
9 May 2012CPOL1 min read 9.5K   2  
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:

C#
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:

XML
<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.:
  • XML
    <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:

    XML
    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)


Written By
Software Developer ByteMarq
United Kingdom United Kingdom
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
-- There are no messages in this forum --