Introduction
Localizing an application to WPF is not an easy task. Virtually any manual for WPF localization is replete with details and manual steps to implement a localized application.
Existing Solutions
Localization using the LocBaml utility, described in the Microsoft Localization Guide, has many advantages, but is difficult to maintain. André van heerwaarde, in his
article proposed to simplify this solution using the customized build step, he also wrote utilities for merging translated text fragments. However, in his article, there are also many manual steps.
Visual Studio Project Template
I suggest using the localized application template that I created to start working on a multilingual WPF application. The project created using this template already contains all the necessary utilities for localization, as well as automates the localization procedures as much as possible during the development process.
')
In the process of developing an application, you add new XAML files without worrying about localization. Upon completion of the changes, build the project.
The configured pre-build step will call msbuild / t: updateuid [Project Name] .csproj. This step automatically adds x: Uid to each element containing text elements.
Then, during the build process, LocBaml will be automatically launched, which will find all the text elements in the XAML files and create a CSV file containing the text elements.
The next step will launch the MergeLocBamlCsv utility from André van heerwaarde. As a result, the previous translated fragments will be combined with new ones. The StripLocBamlCsv utility cuts unused elements from CSV files.
The only thing you have to do manually is the addition of new languages and the actual translation itself.
Adding a new language
To add a new language to the project you will need:
copy the localization of a neutral language to a new CSV file
Copy Translation \ Translate.csv Translation \ Translate.ru-RU.csv
open the project file in a text editor and after the lines:
< LocBamlCsv Include ="Translation\Translate.de-DE.csv" >
< Culture > de-DE </ Culture >
</ LocBamlCsv >
add a new language for example
< LocBamlCsv Include ="Translation\Translate.ru-RU.csv" >
< Culture > ru-RU </ Culture >
</ LocBamlCsv >
After that, you need to reopen the project in Visual Studio, if the project has already been opened, the development environment will ask if you want to reopen the project to reflect the changes made, answer 'Yes'.
If you made no mistakes, then a new file Translate.ru-RU.csv will appear in the newly opened project in the Translation folder.
Run the build to update the translation files, after which you can open a new file and proceed with the translation.
Loading
Links