Silverlight Localization Gotcha

2 commentsWritten on March 27th, 2009 by
Categories: Silverlight

Wasted a bit of time figuring this out, so i'm posting it here for future reference. We have this multi-language silverlight app where the UI needs to be shown in either English or Dutch. So you know, i copied my TextResources.resx file (which contains the translated strings in English) and created a TextResources.nl.resx file where i replaced the English strings with the Dutch strings.

In the output folder of the Silverlight project, you can clearly see that the Our.KickAss.Silverlight.Project.resources.dll file is located in the 'nl' folder. The XAP file that is being copied to the actual web project however, doesn't contain the dutch resources.

Apparantly, the key to 'fixing' this is opening the .csproj file of your Silverlight project, and then you need to modify the SupportedCultures element so it contains the cultures you're supporting:

<SupportedCultures>en;nl</SupportedCultures>

There might be a way to do this from the UI within Visual Studio, but i sure didn't find it anywhere.

And now you can simply switch between the translations setting the generated resource class's static Culture property to the culture you want, for instance:

            TextResources.Culture = new CultureInfo("nl-BE");

  • http://benpittoors.wordpress.com den Ben

    allright… this kept me busy quite some time yesterday too :/

    _being twice as bad because you’re a coworker of mine_

    -> same app, and it now also needed French language support… imagine me seeing it work perfectly for English and Dutch but fail for French :s

    maybe you should add some extra tags to this post so it shows up a bit earlier in the search results for “Silverlight resource files localization” (or maybe this comment alone will allready help a bit)

    As far as I know this setting is not exposed in the Visual Studio (2008) IDE

  • http://davybrion.com Davy Brion

    at the moment it’s the 7th result when you google for ‘silverlight localization’ :p