Localization

The Windows Phone 8 applications can be used in many countries. Thus, it could be beneficial to provide support for more than one language. Fortunately, such a feature can be added to the application in an easy way. A detailed description how to add a support for the Polish language in the Menu screen is presented in this section.

At the beginning, you should open the Packaging tab in the manifest file and select the languages that should be supported by the application. As an example, you can choose Polish. After saving changes and closing the tab with manifest, let's open properties of the SpaceAim3D project, by choosing the Properties option from the context menu. Then, the additional tab is opened, where you should choose Polish in the Supported Cultures list. Next, the new file should be visible in the Resources directory. Currently, the directory should contain two .resx files: AppResources.resx and AppResources. pl .resx. The first one contains translations for the default language (English), while the other contains translations for Polish. Next, you should specify translations for both English and Polish languages, using the built-in editors of the .resx files, as presented in the following screenshot:

Localization

The last step consists of binding properties of UI elements to suitable translations—currently only in case of captions for the asteroids. You can use the localized string in the Text property of the TextBlock control with the following part of code:

<Border (...) Tag="play">
  <TextBlock Style="{StaticResource ButtonText}" 
    Text="{Binding LocalizedResources.MenuPlay, 
      Source={StaticResource LocalizedStrings}}" />
</Border>

It uses the data binding concept to look for the MenuPlay translation inside the LocalizedStrings resource defined in App.xaml. It is worth mentioning that here the Source property of the Binding object is used to specify the source for the mechanism.

Currently, the Menu screen supports both languages—English and Polish, as shown in the following screenshot:

Localization

The proper translations are selected automatically, depending on the currently set language in the phone. However, in case of missing translations in Polish language, content from the default one is used instead. Let's launch the application, change the language (in the language+region group in phone settings), run it once again, and see how it works!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.124