Geeks With Blogs
Adrian Hara Working through the .NET maze
In case you missed it, a really good whitepaper by Rick Strahl and Michele Leroux Bustamante was published a few days ago on dealing with localization in WPF. At 66 pages long, I found the whitepaper really good, as it takes a hands-on, no-bull approach (in the familiar style of the authors ;) ) on the subject. There is also sample code for download containing examples and some goodies.

For those interested, here's a quick summary of the paper (which is NOT supposed to replace reading it):
  • you can use LocBAML for localization, which is an unsupported tool from Microsoft. Basically it sucks, but if you have a finished WPF application which you wrote without localization in mind, this tool might help you somewhat.
  • you can use the plain ol' ResX resources, together with the {x:Static} markup extension to access them. This works loads better than the LocBAML approach, but has the major disadvantage that you're limited to localizing only simple string properties, because the {x:Static} markup extension doesn't use type converters (so, for example, localizing a Thickness might be tricky if not impossible).
  • you can use the plain ol' ResX resources, but this time together with a custom markup extension which knows how to use type converters. The authors of the whitepaper kindly supply for download such an extension, which does quite a lot of other nice stuff besides the type converter business. I'd say this is the way to go :)
  • you can use a mechanism similar to the one used in Winforms and Asp.net applications where you could have a label, say "lblTitle" and then resource keys with sub-properties, like "lblTitle.Text", "lblTitle.Width" and so on. To do this in WPF the authors again supply some attached properties which do some magic to get this working. While this looks pretty cool, unfortunately they also don't support type converters, so you're stuck to localizing "simple" stuff.
Again, if you're interested in the subject, please read the whitepaper as it provides a lot more subject matter than the actual possibilities of localization and I'd go as far as to say it's a mandatory read for anyone who has to localize WPF applications.

Codeplex link:

http://wpflocalization.codeplex.com/

Posted on Thursday, July 2, 2009 1:32 AM | Back to top


Comments on this post: WPF Localization Guidance

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Adrian Hara | Powered by: GeeksWithBlogs.net