This is a mirror of official site: http://jasper-net.blogspot.com/

Localize a Silverlight 4 Application

| Thursday, April 14, 2011
In this article, I will demonstrate how to localize a Silverlight application. In simple words, localization is the customization of applications for a given culture or locale. If you have been doing ASP.NET development, you probably are already familiar with localizing applications. The process of localizing a Silverlight application is quite similar, i.e. using Resource files. You create a resource file for each culture or language your application plans to support and Silverlight will use the CurrentUICulture of the UI thread to decide which resource to use. Let us see the steps in detail.

Note: Whenever I talk to developers about localization, they often refer to localization as translation of text in different languages. Although that’s true, localization is much more than that. Depending on the culture, you can display icons, images, flow of text (right to left or vice-versa), audio and much more, for a specific culture or language that your application supports.

Step 1: Create a new Silverlight project and call it ‘SliverlightLocalize’. Drag and drop a textbox from the Toolbox to the Silverlight designer.

Step 2: Right click your Silverlight project > Add > New Item > Select ‘Resources File’ and rename it as localstring.resx. In the resource file, add a Name and Value as shown below

localstringresource0128.png

Also make sure the access modifier combo box says ‘Public’.

Step 3: Let us add support for the Spanish language in our application. Make a copy of this resource file by copying it from the project in the Solution Explorer and pasting it back ‘twice’ inside the project. Rename it to localstring.es.resx and localstring.es-ES.resx. What we have done is created an invariant resource file (es), as well as a culture-specific resource file(es-ES). This is a good practice often referred to as the fallback culture practice and you should adopt this for every language/culture you support.

Now type the Spanish translation for Hello World in both the files as shown below

localstringspanishresource0128.png

Read more: net curry

Posted via email from Jasper-net

0 comments: