Background
Localizing a WPF application is not an easy task. Almost any article on the localization of WPF is replete with details and manual steps toimplementation a localized application.Existing solutions
Localization using the utility LocBaml are described in the localization of Microsoft has lots of advantages, but difficult to maintain. André van heerwaarde in his article proposed to simplify this decision by the configured build step. He wrote an utility to merge the translated text fragments. However, in his article, still many manual steps.Visual Studio Project Template
I propose to use a Localized WPF Application template, I've created to start working on a multilingual WPF application. Project created using this template already contains all the necessary tools for localization, as well as the maximum automates the localization process.During application development, you add a new XAML file without having to worry about localization. Upon completion of the changes simply build project.
- Custom build step will call msbuild / t: updateuid [Project Name].csproj. This step will automatically add x:Uid at every element containing the text elements.
- Then in the build process will start automatically LocBaml, which finds all text elements in the XAML file and generates a CSV file containing the text elements.
- The next step will run the utility from MergeLocBamlCsv André van heerwaarde. As a result, earlier translated segments will be merged with the new.
- Utility StripLocBamlCsv Cut unused items from the CSV file.
The only thing you have to do manually is to add new languages and the actual translation itself.
Adding a new language
To add a new language in the draft you will have:copy the location of the neutral language in the new CSV file
copy Translation\Translate.csv Translation\Translate.ru-RU.csv
open the project file in a text editor and after 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>
Then you need to reopen the project in Visual Studio, if the project was already open, the IDE will ask whether you wish to reopen the project to reflect the changes, answer 'Yes'.
If you did not make mistakes, then the newly open project folder Translation will be a new file Translate.ru-RU.csv
Start the assembly to update the translation files, then you can open a new file and start translating.
Localize text in code behind
StringResources.xaml is a Resource Dictionary example for translated strings:<ResourceDictionaryUsage as easy as:
x:Uid="ResourceDictionary_1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- String resource that can be localized -->
<system:String x:Uid="system:String_1"
x:Key="TestString1">Test</system:String>
<system:String x:Uid="system:String_2"
x:Key="MainWindow">Main Window</system:String>
</ResourceDictionary>
this.Title = (string)FindResource("MainWindow");
Links and credits
WPF Localization Guidance
WPF Globalization and Localization Overview
LocBaml + MsBuild + ClickOnce Deployment
Downloads
Localizable WPF Project
Hi!
ReplyDeleteThank you for your article!
Can you explain pls how to use this template if there is a WPF window in some subfolder within a project?
How we can change UI then?
IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
DeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai Project Centers in Chennai
To easily manage software localization projects, I recommend this collaborative online tool: https://poeditor.com/
ReplyDeleteSpeaking about internet and technologies these days. It helps us live easier. Like now I store my paperwork in an electronic data room. I know it's safe for sure.
ReplyDeletehow to make money online
ReplyDeleteKeep it up!! You have done the nice job having provided the latest information.EarnHoney
ReplyDeletehat an awesome giveaway! Thanks for hosting! Can't wait to check out these two :)EarnHoney
ReplyDeleteSoftware House in Hyderabad
ReplyDelete1st news web site this site provide a news information so more gain information. 1st news
ReplyDeleteBachelor developer this site a provider a All IT Service and Web Design and software design and SEO search engine optimizetion Service Provider So Then See Our Site And Gain Information And Service for Web Design and software design Our Software Company Our Clint’s For Spatial Discount see our site bachelordeveloper.com and Gain Information.
ReplyDeletebachelor developer
This comment has been removed by the author.
ReplyDeleteI'm really impressed about the info you provide in your articles. If you want to invest in suits and be stress-free, then you should shake hands with us. We are providing great clothing in the most reasonable price range that you wouldn’t find anywhere else. Put your trust in us as your supplier since we are the prominent custom stickers printing You can rely on us for the clothing problems we assure you we will never let our customers down.
ReplyDeleteLearn Quran online
ReplyDeleteI’m curious to find out what blog system you’re utilizing? I’m having some small security problems with my latest website and I’d like to find something more safe. Do you have any suggestions? And Bet Numbers
ReplyDeletehome salon service
ReplyDelete