Localizing a Silverlight application

VS Silverlight beta2 adjusted its build functionalities to support the new Silverlight runtime localization model, which essentially is “one language, one xap”. This article provides the steps to take to build a localized app

Let us say, you want to localize your app for the culture of “ja-jp”. You have created several resource files and you want VS to pack the satellite assemblies into the .xap file.

clip_image002

1. In the solution explorer unload the Silverlight project and edit the project file. There is pre-created tag of “SupportedCultures” in the first property group tag. Fill in the culture value of “ja-jp”, so you get “<SupportedCultures>ja-jp</SupportedCultures>”. Note, you can also fill in a culture list separated by “,” or “;” to support multiple cultures/languages in the same xap file. For example you can fill in a string of “ja-JP;fr-FR”. VS reads this list and only packs related satellite assembly folders.

clip_image004

2. Save the project file, reload it and then build it. You can open the .xap file generated under “Bin\Debug” to check out the content. You can see VS only packs the “ja-jp” folder, but no “ja” folder since it is not in the culture list.

clip_image006

3. If you would like to create a new xap file for a new culture, say “de”, you need to create new build configuration in VS and insert the tag of “<SupportedCultures>de</SupportedCultures>” into the related property group tag in the project file

clip_image008

The project file change looks like,

clip_image010

4. If you have a hosting web project, you are recommended to turn on the “copy to configuration specific folders” through the “Silverlight Applications” tab in web’s property page dialog. Just click the “Change…” button. You can also enable it in the “Add Silverlight Application” wizard when you create a new project. So different .xap files will stay underneath a separate subfolder, and they won’t overwrite each other.

clip_image012

clip_image014