There are two things you need to do. First, set the project as having a neutral language. This is done in Visual Studio 2008 by going to the project's properties, selecting Application, clicking on Assembly information and setting the language. However, it doesn't set an UltimateResourceFallbackLocation. So you have to do it manually, by editing the Properties\AssemblyInfo.cs file and adding
[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.Satellite)]

The second thing is rather dumb. I haven't found ANY way to do it from Visual Studio. I just edited the csproj file manually. It needs
set in (under, actually) every <PropertyGroup> in it.

What that does is create a language folder in the bin directory when compiled with a localizable resource file. Using the locBaml utility in the Windows SDK you can turn a resources.dll in the language folder into a CSV, then back into a dll like this:
LocBaml /parse ProjectName.g.en-US.resources /out:en-US.csv
LocBaml /generate ProjectName.resources.dll /trans:fr-CA.csv /cul:fr-CA

You will not find locBaml in the Windows SDK folder except maybe as a sample project. The sample project can be downloaded here. Don't forget to compile it!

Some other useful links:
WPF Localization
Localizing WPF Applications using Locbaml
LocBaml + MsBuild + ClickOnce Deployment

Rick Strahl presents an easier and better alternative by using normal resx files! I don't want to copy (too much) from his post, so just read it:
Resx and BAML Resources in WPF


Be the first to post a comment

Post a comment