I’m developing a WPF C# app under VS2012 where I have UserControls from different sources in separate projects in the solution. I would like to localize all the UI strings in the entire solution in one place, if I can.
It seems like locbaml isn’t really set up for this kind of thing since it appears for every class library, I need to create a separate resource DLL for each class library DLL?
Can anyone give me some guidance on the Best Practice way to do this? I’m at a loss to figure out how to apply the various localization techniques to a solution with multiple projects.
Thanks for any advice.
Corey.
Revising my post a bit to be more inclusive:
Overarching best practices are detailed on the MSDN here.
Really, you have three choices.
There are plenty of scenarios where locbaml is optimal, which are outlined on the best practices page, but resx files are reasonably portable (the format is simple) and will fulfill a requirement for dynamic language swapping.
If you decide to go with (1), you’re on your own. Godspeed! 🙂
If you choose to use locbaml (2), it’s best to approach the problem by first abstracting your strings into a ResourceDictionary, allowing you to put all strings into one file for localizing. See here : How to: Use a ResourceDictionary to Manage Localizable String Resources
The linked article details still using locbaml, but you should only need to use it to localize the single ResourceDictionary. Keeping the resources neatly isolated in this fashion should make your life a lot easier. Note that if desired, the ResourceDictionaries can be split categorically – just a matter of whether one monolithic file or multiple smaller files are better for your project.
If you choose to use resx files (3) and want to support painless run-time language switching, this short tutorial\example code provides an excellent starting point. It’s written with Prism in mind, but can be used outside of Prism with no difficulties. There are other, simpler approaches that also use resx files, but if you want the best approach, IMHO you are looking at it. The one (maybe?) major caveat is that this approach will not work on Silverlight. This is a WPF question but I realize it may be a concern for some people.