In this tutorial you are going to see how to Localize and Globalize a Windows Store application step by step. Localization is the process of translating a product into different languages or adapting a product for a specific country or region. When your app is targeting a global market like India, UAE, Russia language plays a major role as most of the user specific are not in English. So we cant really develop apps in multiple languages for each of the location. To localize the application for Windows Store apps, Microsoft recommends to use the inbuilt localization mechanism to translate the language and use it appropriate.
Let us see the steps on how to achieve the localization mechanism in a Windows Store application. First open Visual Studio and create a new project or open your existing project where you want to explicitly apply the Localization. Once you open the application navigate to the App Manifest file and see to what is the Default Language the app is assigned. Most probably it should be en-US English language, in some cases it can be of other language if you have changed it previously.
Now create a folder called strings and add new folders for each of the language which you want to use, say if you want to localize the application to French and Hindi add folders like “en-US”, “fr-fr” and “hi-IN” and right click on each of the folder and add a resource file (.resw) as shown in the screen below.
Now go to each of the resource file and add the content which are familiar of as shown in the screen below. If you are not familiar with the content then we need to get the help from the knowledgeable source who can help us in translating the information required as shown in the screen below.
Once you assigned the values to different cultures with some help from your known persons, we can force the culture to load or by default when the user changes the language the app will automatically change the information in the application. In case if you want to load a particular culture you can do that as well with the help of the CultureInfo class as shown in the code below.
Code:
var culture = new CultureInfo(“hi-IN”);
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
Based on the above culture on load event the specific culture information will be loaded which is not a best practice,, but to test it locally we can follow this approach and try to get the appropriate resource changes are applied if we need to get it done for that particular culture.