Share this: Twitter

LinkedIn

Skype

Facebook

Reddit

More

Pinterest

Tumblr



Email

Print



Pocket



Sure, you’re a good dev and you know that you should be putting all your strings in a RESX file if for no other reason than to centralize them so you only have to update them in one place. And maybe you do get some translations to other languages (good for you!). But what if you could harness the power of Microsoft and Bing to bring the Translation Portal and Bing Translator right in to your app? Now you can. And it couldn’t be easier.

The Multilingual App Toolkit integrates right in to Visual Studio to give you on-the-fly machine translations for your strings immediately upon build. Not only that, but it also takes care of updating your app’s Manifest file so when you submit your app to the store the languages are shown as supported. In short: it saves you boatloads of time.

In this post I’ll show you not only how to use the MAT, but also how to continue to take advantage of it even if you are getting help from real-live people with your translations, as I am for my latest app Upload to YouTube.

The first step is to install the Multilingual App Toolkit extension from the Visual Studio Gallery. For my examples I’ll be showing what it looks like in VS 2013 on a Windows Phone 8.1 Silverlight project.

Once installed, setting your app up to work with MAT is as simple as:

The primary result of doing this is that for each language you wish to support now, beyond your app’s neutral language, you’ll get an XLF file added to your project. These XLF files are transformed at build time in to RESX files which then serve as the resource table for your strings as you add other languages (like you’re used to). MAT automatically adds a “pseudo-language” to the project which you can set at run-time via code to be used to test your app’s capabilities w/ translations that may expand text boxes, etc – I never use this personally (so it won’t be addressed in this post).

Once you’ve got MAT set up, languages can be added to your WP app in one of two ways after MAT is enabled:

The “Add translation languages” option will pop up a dialog of all the WP 8.1 languages to choose from. Checking them off automatically adds their corresponding XLF (and generated RESX) files to your project:

The other way is to simply drag-and-drop an XLF or RESX file in to the project. MAT detects this add and wires it up in the manifest and, in the case of dropping a RESX file in place, will auto-create the XLF that goes with it.

Once you have your XLF files and MAT wired in, the magic can really begin. Let’s say, for my Upload to YouTube app, I had no real translations, but I know from my analytics that Portuguese and Vietnamese are very popular for my app. I’d go thru the above steps, adding on those two languages. Now that I’ve done that, how can I go about getting machine translations for my app from Bing & the Translation portal? Cake:

Select the languages you want to get translations for:

Right click, and smile:

Then watch the magic happen:

Now run a build (executes the RESX generation), and check out your XLF or RESX files for the other languages. Lo-and-behold:

The first screenshot here is one of the Multilingual Editor that ships with MAT. It’s used for the XLF files and really makes apparent why XLFs are purpose-build for translating. Notice how certain strings are specifically marked that they were machine translated. Also as “Needs Review.” This is what makes XLFs great files to use if you are passing them back and forth to translators manually (and not managing translations through a service, etc) as they allow state-keeping for various strings and give your translators a way to filter & focus their efforts.

Once you have this all in place you’re basically DONE as far as localizing an app goes. It really couldn’t get much easier!

But what if you want real translations from real people, and they’re being generated & given to you in RESX format? Here’s where I had to work through a few kinks, so I thought I’d share these tricks and tips with you.

RESX files for all languages other than the neutral one are regenerated at build time. This means changes to the resx files are overwritten by the contents of the XLF files when you build your project (or choose “run custom tool” on an XLF file) If an XLF isn’t present for a file dropped in to the project (like a RESX file), one is created from the contents of the RESX file. “Generate Machine Translations…” only translates strings that are marked as needing translation based on the various states available in the XLF file schema.

It’s keeping in mind these points that I developed a workflow to incorporate the translations I get from the great service GetLocalization.com for my Windows Phone projects. When you download the updated string files from GetLocalization, they’re given to you as RESX files. However, looking at the points above, there would be no way to “update” the strings in my app. So I had to figure something out. Here’s what you do:

Delete all the XLF files that will be updated by the newly-pulled RESX files you’ve received from your translator(s). This removes the language from your manifest as well, thanks to MAT’s hooks. Drag & drop the new RESX files in to your project. MAT will auto-create new XLF files from these RESX files – using the new translations – and also add the new language to your app manifest. Change the state of all the strings in the new XLF files so ‘Generate Machine Translations’ when run at a future date won’t overwrite these “good” ones you just got from translators.

Step #3 is the critical part. If you *don’t* do this, then the next time you add a new string to your neutral language, which then shows up in the XLF, and you translate w/ the ‘generate’ option, you’ll lose all the REAL translations you previously received from your translators. No bueno.

To accomplish this, I take all the XLF files, pull them in to Notepad++ and Search & Replace

state=”translated”

with

state=”final”

across “all open documents.” The ‘generate’ option won’t touch ones marked as ‘final’. So now in VS you’re all good from there on out; I use the ‘generate’ option in the time periods between adding new strings to my app and when the translators update the project on GetLocalization.

Hope this helps you get some more usage out of your apps as Windows Phone continues to gain popularity worldwide! Good luck!

Share this: Twitter

LinkedIn

Skype

Facebook

Reddit

More

Pinterest

Tumblr



Email

Print



Pocket



Like this: Like Loading...