Start Building an International Application for Windwos Phone 7 (Part 2)
In the Part I post, we already described how to create the application and in the Part II, we will continue to cover the rest of the 2 sections, Build and run the application and Try culture fallback mechanism so you will see the application loads different string resources defined for English and Italian based on Display language setting in region & language on Windows Phone 7.
Let’s start building/running this international application created in the Part I post and try fallback mechanism with it for Windows Phone 7.
· Build and run the application
1. Open IntlWinPhoneApp in Visual Studio.
2. Hit F5 to run.
3. After the application is deployed to Windows Phone emulator, you will see the application loads the strings defined in AppResx.resx whose resource culture locale is en-US.
4. Hit OK button, you will be prompted with a message box telling You will be directed to English MSDN page which is the string defined in AppResx.resx and the English MSDN page will show up in the web browser control.
5. Click button in the emulator, and then click to select Settings | region & language.
6. Change Display language to Italiano and click Tap here to accept changes and restart your phone as shown in Screen 2.
7. After the emulator reboots, you will see the below screen and then click button and then click IntlWinPhoneApp to run this application again.
8. You will see the current resource culture locale is it-IT and the application loads the strings defined in AppResx.it-IT.resx which means users can see the localized Italian strings if you put the Italian strings rather than English strings in AppRex.it-IT.resx. In this post, we still use English strings here for making the sample application easier to understand.
9. Hit OK button, you will be prompted with a message box telling You will be directed to Italian MSDN page which is the string defined in AppResx.it-IT.resx and then Italian MSDN page will show up in the web browser control.
· Try culture fallback mechanism
As we created AppResx.it.resx already in the previous post, let’s check to see if the application can fall back to load the strings defined in AppResx.it.resx after removing AppResx.it-IT.resx from the project since it is the parent culture locale of it-IT.
1. In Solution Explorer, right-click on AppResx.it-IT.resx and select Exclude from Project and save the project.
2. Hit F5 to run.
3. Change the display language by repeating step 5 – step 7 in the section Build and run the application to re-run the application.
4. The screen you’re seeing now is the same as Screen 1, which means the application doesn’t fall back to load the strings defined in AppResx.it.resx but fall back to load the strings defined in AppResx.resx instead. Why? This is because we didn’t explicitly specify it (the parent culture locale of it-IT)as one of the supported cultures in IntlWinPhoneApp.csproj.
5. To make the application fall back to load the strings defined in AppResx.it.resx, you have to close the project and then open IntlWinPhoneApp.csproj with notepad to add the following code to explicitly specify it (the parent culture locale of it-IT) as one of the supported cultures as shown in Screen 5 and save it then close it.
6. Re-open the application in Visual Studio and hit F5 to run.
7. Change the display language by repeating step 5 – step 7 in the section Build and Run the Application to re-run the application.
8. You now can see the application falls back to load the strings defined in AppRex.it.resx this time as shown in Screen 6 below.
An international application should support localized users interfaces for all users in different countries and separated localized resources and the fallback mechanism play the key role for it. If you need more information about this, you can refer to Packaging and Deploying Resources topic. I hope you have found this post to be helpful to you. Thanks for taking the time to read this post and other posts on the Global Developer Blog!