Jefim Borissov Житие мое

19Mar/102

Localizing a WPF application

I know, Google knows so much about this, yet still, no clear and simple step-by-step guide. So here it goes:

  • Download LocBaml tool here
  • Compile it and get the LocBaml.exe
  • Open your project file with Notepad.
  • Add the following there: <UICulture>en-US</UICulture> under all <PropertyGroup> tags (for all build configs that is).
  • In your XAML files add x:Uid="someUniqueUid" to any element you want to localize.
  • Build your project.
  • Navigate your explorer to the build folder - you will see that it has a new subfolder called en-US. Inside you will find a file - YourProject.resources.dll
  • Copy the binary of your project (e.g. YourProject.exe), LocBaml.exe and any referenced project binaries into this en-US folder.
  • Open a command line prompt in this folder (under Windows seven you can press [Shift] + Right click and choose the command prompt window from the context menu).
  • Run the following: locbaml /parse YourProject.resources.dll /out:YourProject.txt - a human-readable text file will appear in the folder.
  • Edit the text file (translate the values in it). Excel is your best option - open the file from Excel menu and it will ask you if you want to treat tab symbols as text separators).
  • Run the following after you localized the text file: locbaml /generate /trans:YourProject.txt /out:..\ru-RU /cul:ru-RU YourProject.resources.dll (replace ru-RU with the culture you are localizing into).
  • Now all you have to do is to set the CultureInfo for your application thread like this:
var cultureInfo = new CultureInfo("ru-RU");
System.Threading.CurrentThread.CurrentCulture = cultureInfo;
System.Threading.CurrentThread.CurrentUICulture = cultureInfo;

And you are done. You app should be localized now!

Comments (2) Trackbacks (0)
  1. Localizing a WTF application. Исправь ошибку :)

  2. Спасибо, поправил :)


Leave a comment


No trackbacks yet.