R – Combine LocBaml and Resources in single satellite assembly

localizationresgenresourceswpf

Its my understanding that the recommended approach to localization in WPF is to use the LocBaml tool to extract the localizable items into e.g. a csv file, translate the items into the desired language and regenerate a new sattelite assembly from this csv file. However from my experiments this seems to conflict with the generation of satellite assemblies from resources.resx files since neither is combining the resources into the single resource file but simply override any existing satellite assembly.

Is there a recommended approach (or even better, an existing tool) for doing a "merge" of output from LocBaml /generate and the output of running resgen on a resources.resx file (which is by default done by VS on builds). Are anybody out there tackling the same issues?

Best Answer

You have to manually do this generating .resources from LocBaml and then merging the Resx and BAML resources using the Assembly linker.

The process looks something like this:

LocBaml.exe /generate ..\obj\WpfLocalization.g.en-US.resources 
            /trans:Res\de.csv /out:de /culture:de

REM Combine resource files w/ Assembly Linker
al /template:WpfLocalization.exe 
   /embed:de\WpfLocalization.g.de.resources 
   /embed:..\..\obj\WpfLocalization.Properties.Resources.de.resources   
   /culture:de  /out:de\WpfLocalization.resources.dll

(everything on one line in a batch file).

You can put the above in a batch file customized for your project. Remember LocBaml has to in the same folder as your output files. You can add this as a post build task.

Related Topic