Original address:
Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-7-Localizing-the-App
Series Address: Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners
Source code: HTTP://AKA.MS/ABSBEGINNERDEVWP8 PDF File: http://aka.ms/absbeginnerdevwp8pdf
In this lesson I'll explain how to localize your application, which means we can render text in different languages in your application. For example, I need users who support both English and Spanish to open up a market for potential sales applications. Now it is a big step in the right direction to have more sales in different markets instead of being confined to the local market.
The plan for this lesson is:
We will learn to store name/value pairs in Appresources.resx files and access them in declarative XAML code (or in imperative C # code).
We'll see how to create files for specific languages and regions in Visual Studio.
We will learn how the Windows Phone 8 operating system chooses the correct version of the Appresouces.resx file based on the user's language and region.
1. Modify the Appresources.resx setting and bind to its value
If you expand the Resource folder for the PetSounds project, you will see a file called Appresources.resx:
If you double-click and open it, it will be opened in the main area of a particular designer:
The file is a series of name/value pairs. On the left is the name of the setting we are going to bind. To the right is the settings for the given language. What kind of language? Please see the final attribute.
Resource Language (resourcelanguage)
is set to:
En-US
The meaning of "en" is "中文版". "US" means an area, which means "USA" here. Therefore, these settings are used for English-speaking American users. It is also the default Appresources file (you will soon see the difference between the default and the other languages/regions we support).
A name/value pair is primarily a fragment of text that we use in the application. However, the resource flow direction (resourceflowdirection) is the setting where the character should be rendered. As you know, some language reading habits are done from the right, and this setting is used in the application for this purpose.
As you can see, the Applictiontitle setting is set to "my application." What should I do if I want to convert the TextBlock in MainPage.xaml to use the settings in Appresources? I will use the following binding expression:
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/