Click here to Skip to main content
13,043,650 members (54,158 online)
Click here to Skip to main content
Add your own
alternative version

Stats

7.2K views
2 bookmarked
Posted 8 May 2012

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
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Comments and Discussions

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