If you want to provide multilingual support to your Windows Phone application, you must need to localize your apps, with respect to text along with other cultural entities. While building Windows Phone 8 application, it is quite easier to enable and implement the localization. In an other way, you can say, the default template describe how to use the localization for your application.
Start a new Windows Phone 8 Project and Select the Default Phone App Template. If you explore the solution explorer, you will find two files “LocalizedStrings.cs” and “AppResources.resx” .
The AppResources.resx file contains the localized text resources where as the LocalizedStrings.cs files reads and map them with the application controls contents.
The resource file contain some of the text entry; which can be applied to the controls. For an example you want to localize the page name for the application first. So, first add an entry in the resource file as “PageName” and give the corresponding value as “Login Page”.
Next task is to apply this text in your XAML, So replace the following line of code
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
with
<TextBlock Text="{Binding Path=LocalizedResources.PageName, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
If you noticed, you will find the only difference between these two line is the “Text” property binding. In case of first one, we have given a hard coded text, where as the next one is reading from the resource file. Simple enough!
What next ! Run the application, you will see the page title shows “Login Page” which reads from the resource file.
So where is the localization? In a first look it seems to be done a for single language and that is English ! Now to apply the same things for the other language, you just need to provide the support text. For an example, you want to support the “Spanish” language support.
So to enable the Spanish, from the project property window –> Application tab, select the “Supported Cultures” – Spanish (Mexico) “ or choose which ever you prefer.
Once you save the Property, a new file “AppResources.es-MX.resx” will be generated with in the resource folder.
Open the new resource file, just change the “PageName” value to text you want to give for Spanish language.
Once done, run the application. first you will find it as English ( Assuming default settings for your emulator). Then change the Language Settings of your emulator and change the Spanish, and run the application again. You will find the application text on other language.
[Note : Changing language settings requires your Emulator OS to restart ]
Sort and simple ! Similarly you can apply this for any other languages and for your complete applications. The only thing you need to keep in mind, while adding a new language support, Visual Studios adds a new resource file corresponding to that language. You just need to append the value for each and individual name for each languages.
Hope this was useful !