Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Localizing Windows Phone 8 applications

Back to Forum: Tech Off
  • User profile image
    Mauricio Feijo

    Microsoft made it so easy to localize applications on the Windows Phone 8 platform. It is really a no brainer at this point.

    I will not mention best patterns and practices here. You can read all about that at

    Here is how it happens: When Windows Phone 8 starts your app it chooses which AppResources file to use when we access the AppResources class in code. BAM! That is it!

    All we have to do at development time is use that class instead of a literal.

    In C# instead of:

    saveButton.Text = "Save" ;

    we use

    saveButton.Text = AppResources.SaveButtonText;

    When typing the resource name of your choice, in my example "SaveButtonText", you will notice Visual Studio puts a red squiggle underneath the name. It is because you still haven't created the resource. To do that open AppResourcex.resx under "Resource" in solution explorer and add the resource name and value to the list. Once the resource name is entered in the list, the red squiggle disappears and you are good to go. 

    Lets take a look at XAML as well. Most times XAML is what you will be using. In XAML it is a bit more verbose, but not rocket surgery either:

    <ApplicationBarIconButton Text="Save" ... />

    we use

    <ApplicationBarIconButton Text="{Binding Path=LocalizedResources.SaveButtonText, Source={StaticResource LocalizedStrings}}" ... />

    You can now build and run your app and all should work as it did before we started localizing.

    Adding languages:

    Now go to the Properties page of your project, under "Supported Cultures" , and select which languages and culture will be supported. I started with Portuguese and Spanish. English was already checked.

    After making that change and saving visual studio will have created one AppResources.resx file for each culture/language you added. You can now open those and change the values to the values on each specific language.

    I may be wrong, but it seems Visual Studio copies the AppResources.resx file from the default language to each new language, so you might want to do this as the very last minute, after your app is ready, or you may need to enter each resource manually on each resx file. Unless there is some sort of refresh functionality I am not aware of.

    So in bullet points:

    • Use AppResource instead of "text"
    • Create each resource as you go on the default resource file
    • Choose your languages at the project Properties page
    • Translate each resource on their language specific resx files.

    Done! Easy huh?

    Hope this helps some people. As usual, let me know if I screwed up something. Thanks!


  • User profile image
    Mauricio Feijo

    Does anyone know whats going on with the formatting?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.