INTRODUCTION TO ANDROID LOCALIZATION

Lecture Three: Best Practices



So far we have discussed the basic concepts and common problems of Android localization. In this article we will focus on l10n best practices and answer some FAQs about the localization process.



Providing Context

Apps can contain hundreds, or even thousands, of strings. The best way to differentiate and get them translated is to provide as much context as possible to the strings. There are two ways to achieve this:

1) Due to the Android string name convention, it would be best to label the string something meaningful. For example, your login button’s string should be:

<string name="login_button">LOG IN</string>

2) Add comments to the strings.

<!-- This is the login page’s button -->
<string name="login_button">LOG IN</string>


Untranslatable Text

Some texts of a string do not need to be translated, such as the name of a company. There are two ways to preserve these texts in your strings.xml:

1) Encase your text with <xliff:g> tags:

<string name="onesky_name">
  <xliff:g id="company">OneSky</xliff:g>is a localization company.
</string>

2) Add the translatable="false" attribute:

<string name="onesky_name" translatable="false">
  OneSky is a localization company.
</string>


Styling

Is l10n just about getting the right language translations? Absolutely not! An important but often overlooked part of l10n is the visual styling and overall UI. Here are some common UI best practices:

1) Provide context in the comments:

<!-- This is the login page’s button, limit to 10 characters-->
<string name="login_button">LOG IN</string>

2) Different languages have different visual needs. For example, in the following English phrase E-mail: hello@oneskyapp.com, a space is needed after the colon. But in Chinese, 電郵:hello@oneskyapp.com, colons have a natural space. Therefore, any extra spaces should be included in the strings’ resource file for languages that need it:

<string name="email">E-mail: </string>

3) Because some phrases need a preserved trailing space, Android XML requires those strings to be encased in double quotes:

<string name="email">"E-mail: "</string>

Whereas for Chinese, the double quotes are unnecessary since there is no need for trailing spaces:

<string name="email">電郵:</string>

Note: There is actually no extra space added to the Chinese translation.



Conclusion

Now that you’ve localized your first Android app, you can start applying these concepts to your own app!

Check out our iOS Localization Academy to localize your iOS app.

Subscribe to our OneSky Localization Blog for more localization insights and contact support@oneskyapp.com for any questions!

 



Download sample file for Android Localization Lectures!

Android Localization Guide-sample file



<  Go to Lecture Two: Format Strings and Plurals

<  Go to Lecture One: A Beginner’s Guide

 

Learn localization and reach global markets like these do.

  • Tango
  • Viber
  • Day One
  • Hootsuite
  • 500px
  • Truecaller
  • Glide
  • Wish
  • Secret