Tuesday, April 16, 2013

Localization and Translation

If you aren't writing multi-language apps, you should be!  If you set it up from the start, it's not too difficult, and the rewards are great.  Unfortunately, it's a huge pain if you wait until far into development to get started.  For Windows Phone, here are things to keep in mind for translation:

  • All strings in text (message box text, message box options, string comparisons)
  • Captions on app bar menus/buttons (since they aren't bindable, it's extra work)
  • Strings in XAML (button captions, text block labels, etc.)
  • Images (some images will require changes to be relevant in different lanugages or cultures.  careful of things like a dollar sign for money)
  • Sort order, currency/numeric/date formatting (if done right, this is almost zero work)
Even once you have all strings pulled out to resource files and all the right logic in place, managing the strings can be challenging.  Fortunately, Microsoft released a great Visual Studio plugin, the Multilingual App Toolkit, to make it easy to create translated resource files using Bing, manual work, or submitting to various online human sources.  It's a great help that makes it really manageable.
Also, be sure to set the Language property of each page using the culture name property of the CurrentCulture.  
this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
With that in place, you will get all string formatting to be locale-based for free!  I don't know why it doesn't happen automatically, but it's an easy enough fix.  I use my own base page class to make that easier.

Finally, remember that testing doesn't require that you change the language of your phone.  You can manually change the Thread.Current.CurrentCulture and CurrentUICulture properties to force any language regardless of system settings.


Link: http://msdn.microsoft.com/library/windows/apps/jj569303.aspx

No comments:

Post a Comment