Using the Multilingual App Toolkit with WPF Applications
One of the toolkits available to app developers enabling them to reach new audiences is the Multilingual App Toolkit (MAT). Using this toolkit, you can easily add multiple language support to Store apps on Windows 8.1 and Windows Phone 8.1 as well as WPF applications on Windows. The toolkit can also use the Microsoft Translator Service to automatically translate the string resources in your app to other languages.
I would like to walk you through the process of using the MAT with WPF applications, where the process is slightly different than with Windows Store and Phone apps.
- Install Microsoft Visual Studio 2013 Update 4
- Install Microsoft Multilingual App Toolkit
Start Using MAT with WPF Apps
Open the WPF project in Visual Studio
In the project settings, Application…Assembly Info, set the Neutral Language to your language; I selected English (United States)
In the Tools menu, select Enable Multilingual App Toolkit. When you do this, a Resources.qps-ploc.xlf file will be automatically added to the project Properties. This will be used to create “Pseudo” translation. Pseudo Language is an artificial modification of the software product intended to simulate real language localization. The pseudo language can be used to detect potential localizability issues or bugs early in the project cycle, before the actual localization starts.
In the Solution Explorer, open the Properties…..Resources.resx and in the top bar of the editor, change the Access Modifier from Internal to Public
During the build process, the MAT will automatically update the .xlf files, keeping them in sync.
When you add new strings to the Resources.resx file, build the project and then right click on .xlf files in the solution explorer and select Generate machine translations.
For the strings in Xaml, you should use the x:Static extension to have the strings point to the .resx file:
You should use the Resources.resx file for all of the localizable strings in your app.
Add additional languages by right-clicking on the project, and selecting Add translation languages…
You can use the Microsoft Translator Service to generate translations or send the .xlf files to translation services as it is in the localization industry standard XLIFF file format.
In addition to language translations, the MAT also use the Microsoft Terminology APIs (Language Portal Provider). This enables direct access to Microsoft’s product translation memories. See this article for more details: http://blogs.msdn.com/b/matdev/archive/2014/07/01/new-version-of-microsoft-terminology-api-launched.aspx
Testing Pseudo Language
WPF uses the OS language by default so Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture need to be manually set to ‘qps-PLOC’ since it is not a log-in language. Here is how you can easily do that:
/// Interaction logic for App.xaml
public partial class App : Application
private CultureInfo cultureOverride = new CultureInfo("qps-PLOC");
if (Debugger.IsAttached == true && cultureOverride != null)
Thread.CurrentThread.CurrentUICulture = cultureOverride;
Thread.CurrentThread.CurrentCulture = cultureOverride;
The Multilingual App Toolkit along with the Microsoft Translator Service has made a difficult and often expensive process of globalizing and localizing apps easy and straightforward. Now it is easy to localize WPF application as well as Windows Store and Windows Phone apps.
Thanks to Cameron Lerum from the MAT team for helping with this article.