This document discusses cross-platform localization for mobile apps using .NET. It introduces Xamarin, a tool that allows developers to write native mobile apps for Android and iOS using C# and shared code bases. It also discusses the Multilingual App Toolkit, which helps manage localized string resources across platforms. Localization involves translating text, images, and other resources to support multiple languages and locales. The document provides tips on effective localization strategies and managing localized resources in Xamarin, Xamarin.Forms, Android and iOS apps.
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
MVP Virtual Conference - Americas 2015 - Cross platform localization for mobile apps
1. Cross-Platform Localization for Mobile Apps Using .NET
Chris Miller, Tyler Technologies
James Montemagno, Xamarin
May 15th, 2015
May 14 – 15, 2015
2015
Microsoft
MVP Virtual
Conference
2. Who we are : Chris Miller
Chris is a Senior R&D Engineer for Tyler Technologies,
Currently working on mobile apps for the K-12
transportation market. He leads the Tech Valley .NET
User Group in Albany, NY.
@anotherlab
http://www.rajapet.com
3. Who we are: James Montemagno
James Montemagno is a Developer Evangelist at
Xamarin. He has been a .NET developer for over a
decade working in a wide range of industries including
game development, printer software, and web services.
Previously, James was a professional mobile developer
on the Xamarin platform for over 3 years, with several
published apps on iOS, Android, and Windows.
@JamesMontemagno
http://motzcod.es/
4. What is localization?
Localization is the process that you follow to allow your web site or
application to support multiple languages and locales.
5. Why should you localize your app?
• Greater Exposure
• Easy Deployment
• Business or Legal requirements
10. Know the localization problem
• What are the localization requirements for your app?
• How many languages do you need to support?
• Do you need to use right-to-left languages like Arabic or
Hebrew?
• Does your application have it's own or an industry specific set of
terminology?
11. Common terminology
Locale - The culture for the user
Language - The language used by the user. The same language in
different countries can have different spelling and grammar rules.
Culture/UICulture - The .NET representation of a locale. Culture is
the locale, UICulture the language.
15. Plural Forms
• The common pattern in English is the singular/plural form
• Asian languages typically use just a single from
• French and Brazilian Portuguese use a different singular/plural
form.
• Then it gets complicated. See https://developer.mozilla.org/en-
US/docs/Mozilla/Localization/Localization_and_Plurals#List_of_Plu
ral_Rules for a long list of rules.
• Use the “Noun : Pattern” instead
• New Messages: 1
16. The tools that I use
• Visual Studio 2013/2015
• Xamarin (both on OS X and as a VS plugin)
• Multilingual App Toolkit (MAT)
17. Create native iOS, Android, Mac and
Windows apps in Visual Studio and C#
About Xamarin
18. Xamarin’s Unique Approach
• Native User Interface
• Native Performance
• Shared code across
platforms
• C# & .NET Framework
• Full API Coverage
20. Xamarin
First
release of
Xamarin.Mac
Launch
Partner
Program
200,000
Developers
Xamarin
Founded
First release of
Xamarin.Android
Xamarin.iOS
launches (originally
known as
MonoTouch)
Ximian
Founded
Over a Decade of Enterprise Production Use
2001 2003 2009 2011 2012 2013
Mono
Launches
Ximian Acquired
by Novell
Xamarin 2.0
Component Store
Xamarin Test Cloud
Evolve 2013
Microsoft Partnership
500,000
Developers
100+ Partners
100+ Components
2014
//
Xamarin 3
2000
SAP Partnership
Fire TV Support
Salesforce partnership
Visionary in Gartner
Magic Quadrant
Google Glass Support
Visual Studio Partner
of the Year
Android Wear Support
Xamarin Evolve 2014
800,000
Developers
200+ Partners
200+ Components
21. Xamarin
• Provides a .NET development environment for C# and F# on iOS
and Android.
• Supports PCL libraries and shared projects.
• Compiles to native code and provides full access to native APIs.
• Xamarin.Forms provides an abstraction layer that lets you write
for that will compile and run as
• Has a plugin for Visual Studio and their own IDE called Xamarin
Studio for Windows and OS X.
• iOS development still requires an OS X machine for the
compilation and debugging.
22. Xamarin – Two Ways
• Xamarin.iOS and Xamarin.Android
• Xamarin.Forms
23. How to manage the language files
• Pick one application as the source for the string resources. This
works best for Xamarin.Forms applications. It can be done for
Xamarin.Android and Xamarin.iOS but requires some extra work
to generate the Android and iOS resource files from the Windows
RESX files.
• Have app specific sets of resource files and use tooling to
manage the language files.
24. Windows Store & Windows Phone
• We just need to create the .resx files for the locales to support
and let the .NET Runtime do the heavy lifting.
• Use the Multilingual App Toolkit in Visual Studio to manage the
resource files.
25. Xamarin.iOS
• Create the resource string files and put them in the proper
location.
• File should be named Localizable.strings and placed in a folders
for each language, with the folder name using the language code
+ .lproj. To localize the app name, set CFBundleDisplayName
in InfoPlist.strings
– en.lproj for English
– es.lproj for Spanish
• Prior to iOS 8, only the language code was supported. iOS 8
added support for locales.
26. Xamarin.iOS
• In Xamarin.iOS, we need to call LocalizedString, which maps to
iOS’s localizedStringForKey method to do the language look up.
• That’s too much work.
• Let’s add a string extension method to make it easy to use.
29. Xamarin.Android
Create the default resource files, plus additional resources for each
language supported. Strings, layouts, images, any resource can be
localized.
While you can create alternate layouts for more verbose languages
(e.g. German), this will make your app harder to maintain.
30. Converting RESX to iOS & Android
• iOS & Android use text files for string resources.
– iOS uses flat text file
– Android uses a XML format similar to RESX
• Use the same constants for each platform for shared resources.
33. Xamarin.Forms
• Single UI to target Android, iOS, and Windows Phone apps.
• Common set of controls that map to native controls at runtime.
• UI can be built from XAML markup or C# code.
• Can be mixed with Xamarin.iOS & Xamarin.Android.
34. Multilingual App Toolkit
• Is XLIFF based, an industry standard file format for resource
translations. Provides a basic audit trail of translated text values.
• Will make language specific versions of your string RESX files.
• Knows about Xamarin.iOS and Xamarin.Android and generates
their string resource files.
• Can machine translate resource files using Bing.
• Get it from https://dev.windows.com/en-us/develop/multilingual-
app-toolkit
35. Localization with Xamarin.Forms
• Not explicitly supported out of the box, but easy to implement.
• Xamarin has posted examples using RESX and Vernacular in their
forums.
• Works great with Multilingual App Toolkit
36. Multilingual App Toolkit
• Enable MAT for the project from the Tools menu
• Right-click on the project and select “Add translation languages…”
39. Localization with Xamarin.Forms
• Move the AppResources.resx from Windows Phone project to
shared PCL or create a new one in the PCL
• Create the localized versions of the RESX file with MAT
• Create an IMarkupExtension to do translations in the XAML
40. Getting the localized text in XAML
• Add your namespace
• Use the databinding to call the markup converter
41. Getting the localized text in code behind
• Just reference the resource file and resource id string
42. Right to Left (RTL) Support
• Target Android 4.2 or later.
– add android:supportsRtl="true" to the <application> element in
your manifest file
– Change all of your app's "left/right" layout properties to new
"start/end" equivalents
• iOS uses the Unicode Implicit Direction Mark Right-To-Left mark
(#200F) to set RTL in the UILabel control as a string prefix.
• Windows Phone uses FlowControl property, set automatically by
current culture.
• Xamarin.Forms does not have explicit support for RTL, it has to be
done manually.
44. General Tips
• Do one platform a time and using tooling to transform the
language resource files to the other platforms.
• Only do the languages that you need to do.
• Use a fake language to test coverage and layout. Scott
Hanselman has a tool to create a fake language.
(http://www.hanselman.com/blog/PsuedoInternationalizationAnd
YourASPNETApplication.aspx)
• Multilingual App Toolkit also generates a pseudo language.
45. General Tips
• To test different languages, set CurrentCulture and
CurrentUICulture in code.
• If you change the language on the device, use an emulator. It’s
not always easy to set the language back to your native choice.
• Language not showing up for Windows Phone? Make sure it’s
checked of under Supported Cultures
• To localize the app & tile title for Windows Phone you need to
create a separate resource dll. See
https://msdn.microsoft.com/library/windows/apps/ff967550%28v
=vs.105%29.aspx
• To localize the launcher name in Android, you will need to use
strings.xml in Resourcesvalues-xx-XX
46. General Tips
• Send the RESX or XLF to a commercial translation service.
• Hire someone to translate the resource files. Make sure that they
understand the domain and industry standard terms.
• If you can't afford a paid translation, Bing translate basic
terminology and crowd source it. Remember, you get what you
pay for.
47. General Tips
• If you are using 3rd party components, make sure that they can
be localized.
• Make sure to translate App Store text.
48. Thank You! …Questions?
The sample code from this presentation can be found on
https://github.com/anotherlab/TheDoctors
Chris Miller can be reached via
@anotherlab
http://www.rajapet.com
James Montemagno can be reached via
@JamesMontemagno
http://motzcod.es/
49. Resources - Platform
• Android
http://developer.android.com/guide/topics/resources/localization.
html
• Apple
https://developer.apple.com/internationalization/
• Windows Phone
http://msdn.microsoft.com/en-
us/library/windowsphone/develop/ff637522(v=vs.105).aspx
• Windows Store
http://msdn.microsoft.com/en-
us/library/windows/apps/hh710212.aspx
51. Resources - Multilingual App Toolkit
• Blog
http://blogs.msdn.com/b/matdev/
• User Voice
http://multilingualapptoolkit.uservoice.com/
• Installation
https://dev.windows.com/en-us/develop/multilingual-app-toolkit
Editor's Notes
Hi, I am Chris Miller and I’ll be your presenter for this session. I’m a 2 year MVP and I work on mobile apps using .NET
James Montemagno will be our moderator today. James is a developer evangelist for Xamarin and a first year MVP
In addition to the language, this includes how dates and times are presented. It also determines how numbers are displayed.
Greater Exposure: The app stores are world wide, why only target one culture?
App stores give you a single click deployment to 150 countries.
Business or Legal requirements: Some markets may require bi-lingual apps.
Canada, must do French and English
The top market for iOS apps is now China
Canada, must do French and English
Canada, must do French and English
You see Android and Windows Phone have growing percentages in markets where the phones are not subsidized by the carriers
Do you even need to localized your
What markets do you need to target
RTL requires additional work
Terminology is import. A given word or phrase can be translated differently, entirely on the context
Locale: This is the language matched to the country. It also includes how dates, numbers, and currency are displayed.
Language: The same language in different countries can have different spelling and grammar rules.
Why have two separate setting? Sometimes the user’s language may not have translated text, but the locale settings are available. Some people may prefer to have to have their app displayed in English, but use their own locale. Canada has two languages for one locale.
Having added a section that refers to manually setting CurrentCulture and CurrentUICulture,
It’s more than just text. The same visual asset could require images specific to the locale. If you take a look at the stop, it’s a universal symbol. But is it? The stop sign in the US and the stop sign in France have the same shape and color, but the text is very different. If you go to another country, it could have a completely different shape.
While the color stayed the same, the shape and text are completely different
Color has cultural significance
Be careful when using color to indicate a state. In Western cultures, the color red is often used to indicate an error or as a danger signal. In China, the color red indicates good news.
In English, the definite article “the” is gender neutral. Many languages, such as French and Spanish, assign a gender to a noun and their equivalent of “the” depends on the gender of that noun.
Press the button.
Edit the photo.
In French, they could be translated as:
Pressez le bouton
Modifier la photo
For these examples, you translate the entire sentence. If you’re creating the sentence at runtime and the noun is selected by the users, you need a way of determining the gender of the noun.
f you can avoid having to use plural forms, your code will be simpler. Instead of using the singular and plural forms for the number of emails, put the number at the end like this:
New messages: 1
That works for any quantity, including 0. Another reason to use this method is that it uses less screen real estate, which is always a premium on a mobile phone.
The Multilingual App Toolkit works with Visual Studio to streamline your localization workflow for mobile, web, and desktop apps. The toolkit helps you localize your apps with localization file management, translation support, and editing tools.
Since the last session was all about Xamarin, I’m going to jump over the “this is Xamarin” part of the presentation. If you have any questions about Xamarin, please ask
We are going to whip through the Xamarin slides at high speed
UI build natively per platform, leveraging C#
C# + XAML
C# + XML
C# + XIB
One shared app logic code base, iOS, Android, Mac, Windows Phone, Windows Store, Windows
Xamarin recently introduced Xamarin.Forms a new library for cross platform user interface. We will touch up on this later, but this enables you to be highly productive, share code, but build out UI on each platform and access platform APIs.
With Xamarin.Forms you now have a nice Shared UI Code layer, but still access to platform APIs
You can start from native, pick a few screens, or start with forms, and replace with native later
Xamarin recently announced that they have 1 million registered users
Two main ways of writing mobile apps.
Xamarin.iOS and Xamarin.Android, where you write to the native UI for each platform. Windows Phone is done using the Microsoft SDKs.
Xamarin.Forms, where you use a common UI that maps to the native platform UI (Android, iOS, Windows Phone.
Jump to the code
Jump to the code
LocalizedString maps to iOS’s localizedStringForKey method. 2nd & 3rd parameters are for default value and resource table.
LocalizedString maps to iOS’s localizedStringForKey method. 2nd & 3rd parameters are for default value and resource table.
Still a moving target
XML formatted file based on the XLIFF (XML Localization Interchange File Format) specification developed by the OASIS Technical Committee; used as a standard means of exchanging localizable data and related information in a lossless format.
MAT is free and installs in every edition of VS
Vernacular is an open source library and set of tools from RDIO. It’s based on the Liniux GetText
Jump to the code
You can see the list of supported languages with the language and country code
An xlf file will be generated for the selected language
When you build the project the language specific resx file will be generated from the XLF file
An upcoming release of MAT will allow you to export out only new additions to a resource file. If you are paying for commercial translation, it would be easy to just send out the new text to translated,
When you build the app, associated resource files are generated for each platform.
Now it’s time to localize an app
This IMarkupExtension allows us to bind our controls and not have to worry about the mechanics
ResourceManager is a class that allows use to request the culture specific version of the text that we want to look up. In this case the Text field is the resource id of the text to look up. If a culture specific string can’t be located, it will use the default language.
And the great thing here is that you get full Intellisense
For anyone that is curious about what this line of code does: The iOS version of the app looked odd with a page title. Device.OnPlatform is a method with Xamarin.Forms that takes a value for iOS, Android, and Windows Phone. It returns the value for the platform that is running the code. In other words on iOS, we get an empty string, everything else gets the DetailsTitle
This is mainly for Xamarin.Android, Xamarin.iOS, Windows Phone.
Not sure how XF handles this
Run the Android 5 version of the app to show it in English
Jump back to VS and show English resx
Gen the French resx
Show the iMarkup converter
Show the XAML
Show the plist for ios and strings for Android