Welcome to MSDN Blogs Sign in | Join | Help

Visual Web Developer Team Blog

Your official information source from the Visual Web Developer team.

News

  • These postings are provided "AS IS" with no warranties, and confer no rights. Use of included code samples are subject to the terms specified Terms of Use
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

Posted: Tuesday, June 10, 2008 8:27 PM by WebDevTools

Comments

Adlai Maschiach said:

What about HEBREW & ARABIC ?

What About Express Support ?

# June 11, 2008 11:58 AM

slyi said:

I added blog artical on how to get language binding working based on your post

# June 14, 2008 9:11 AM

slyi said:

Sorry wrong link try http://wpf-e.spaces.live.com/blog/cns!2B248D261D0E0035!203.entry

# June 14, 2008 9:14 AM

jordan said:

Ok, I can see why MS has gone with one locale per xap, to reduce the xap file size.  But surely this should be the choice of the developer!  I should be able to choose if I want one locale per xap or accept having a larger xap containing all the locales i wish.

It's bad enough that SL doesn't support dynamic resource dictionaries, so now I am going to have to have a xap per different customer branding of the app multiplied by the number of supported locales!!  

talk about support/build script nightmare..

# June 18, 2008 4:27 AM

jordan said:

Anyone looking for a working example of this, download

http://cid-e0f26f7a54cfc7b0.skydrive.live.com/self.aspx/Documents/SilverlightLoc.zip

There are some caveats, please read post: http://silverlight.net/forums/p/17678/62357.aspx#62357

# June 18, 2008 4:30 AM

jordan said:

As there is on xap per locale, is there a way to define the Source property to point to the correct locale folder path depending on URL Querystring?

I'm pretty novice with asp.net, but as far as I can see property values cannot be dynamic.

As I could potentially have hundreds of xap files for different brands/locales, it is not something I would want to code in javascript, code behind c# would be better.

# June 18, 2008 9:43 AM

jordan said:

sample source updated.

See post here for comments:

http://silverlight.net/forums/p/17678/62546.aspx#62546

# June 18, 2008 12:30 PM

slyi said:

If you want multi lang xap then the culture assemebly's must not in culture sub-folders but in the root of the xap itself.

eg add <AssemblyPart Source="SilverlightApplication1.de.resources.dll" /><AssemblyPart Source="SilverlightApplication1.fr.resources.dll" /> into Deployment.Parts section in file Properties\AppManifest.xml

Sample on http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/SL-Loc.zip

# June 20, 2008 3:56 AM

Laurent Duveau said:

I’ve just finished teaching my first Silverlight Tour training in Montreal, people were very excited

# November 24, 2008 1:50 AM

Laurent Duveau said:

I’ve just finished teaching my first Silverlight Tour training in Montreal, people were very excited

# November 24, 2008 3:14 AM
New Comments to this post are disabled
Page view tracker