When you publish a Windows Phone application in the Marketplace, you will have more success if you support the multiple languages. This is called localization.



An easy way to build a localized app is to use resources file (.resx).



First of all remember to set the default "neutral" language in the project properties! This is an important step because the "AppResources.resx" file is used from all not specified languages.



Add new file, and name it "AppResources.resx" for default language. For a new language, just add a new resource named with the CultureInfo ISO letters:

  • AppResources.it-IT.resx for italian language.
  • AppResources.cs-CZ.resx for czech language.
  • AppResources.fr-FR.resx for french language.
  • etc..
Remember to set all resource files to the public access modifier.





Now unload your project and edit the csproj file to add your supported language:

<SupportedCultures>it-IT;en-US;cs-CZ;fr-FR</SupportedCultures>
Create a class to get your resources.

public class LocalizedStrings
{
    private static AppResources localizedResources = new AppResources();
 
    public AppResources Strings
    {
        get
        {
            return localizedResources;
        }
    }
}
In your xaml you need to declare your class as resource:

<phone:PhoneApplicationPage.Resources>
     <local:LocalizedStrings x:Key="LocalizedStrings"/>
</phone:PhoneApplicationPage.Resources>
Now you can use your localized string like this:

Text="{Binding Strings.Loading, Source={StaticResource LocalizedStrings}}"
Or from code behind:

txtLoading.Text = AppResources.Loading;
To test your app you can insert this code in application launching event:

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("it-IT");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
All CultureInfo codes here.



Article via Developer's blog

See Also

Another important place to find a huge amount of Windows Phone related articles is the TechNet Wiki itself. The best entry point is Windows Phone Resources on the TechNet Wiki.