Internationalization (or i18n) basically describes the process of preparing your app for localization (or l10n). It is all about adjusting your code and design in a way to make all the text easily exchangeable. To do so, save all your text in separate resource files and reference them in your code.

If you are using Android Studio and the implemented Android SDK Tools to develop your application it is a breeze to set your project up for internationalization.

After this quick overview of the basics on how to reference your resource file, you will find a step by step tutorial, tips & tricks and common mistakes to avoid when internationalizing your project.

When using Studio the necessary default resource file is already created for you and can be found under YourProject/res/values/strings.xml. Define all your strings in this .xml file and continue with referring directly to them for the code or other .xml files using their name attribute.

Here is a simple strings.xml followed by several examples of how to refer to the resource file:

<?xml version="1.0" encoding="UTF-8"?>
 <string name="app_name">HelloWorld</string>
 <string name="action_settings">Settings</string>
 <string name="hello_world">Hello World!</string>
 <string name="sign_up">Sign Up</string>

Example String

String test = "Sign Up";


String test = getResources().getString(R.string.sign_up);

Example Method

TextView textView = new TextView(this);
TextView.setText(“Sign Up”);


TextView textView = new TextView(this);

Example XML

 android:text="Hello World!" />


 android:text="@string/hello_world" />


Let’s say you finished coding your Android app and want to expand globally. First you need to internationalize your app for further localization.
Just extract all your hard coded text to the default resource file and then reference to them. It’s easy and fast. Just follow the step by step guide below!

Step 1: Click on the text you want to extract and press Alt/Option + Enter.

Step 2: Click Extract string resource.

Android i18n - extract string resource

Step 3: Pick a resource name and hit OK.

android i18n - pick a resource name

That’s it! Observe your new code and the strings.xml file to see the results.



  android:id="@+id/textView" />


<?xml version="1.0" encoding="UTF-8"?>
  <string name="app_name">HelloWorld</string>
  <string name="action_settings">Settings</string>
  <string name="hello_world">Hello World!</string>

From now on you can reference this string using the examples provided above. Once you’re done with all the text in your application you can start localization!

Tips and Tricks

Provide Context in Comments

Once your text is in your resource file start localizing. However, these files might be hard for translators to interpret, which can cause fuzzy or incorrect translations. So an important aspect of internationalization is to provide necessary information for future translations. This information can be put into comments within the strings.xml file.

Here are some examples for relevant info you can provide within comments: What’s the string for? Where is it located on the screen? What limitations have to be considered?

This can be done by adding a comment line above the element:

<!-- Sign Up button in the top right corner of the website, max. 20 characters -->
<string name="sign_up">Sign Up</string>

These comments will be automatically detected by LingoHub and imported as a description into the Editor to give the translator the information needed for a correct translation. When using LingoHub these comments become even more valuable, because you can add LingoChecks, which will automatically activate certain checks like character limits in the LingoHub Editor.
More information on LingoChecks and how to use them effectively can be found in our documentation.

<!-- lh-check: {min: 20} -->
<string name="sign_up">Sign Up</string>

Add RTL Support

RTL (right to left) support describes the support of languages like Arabic, which are written and read from right to left.
If you are developing for Android 4.2 upwards, adding RTL support is simple and will prepare your app for further localization.

Android 4.2 added a full native support for RTL layouts, so with a few simple steps your app will have a basic RTL layout mirroring which, even without further localization, satisfies the needs of the majority of RTL users.

Just follow these two steps to add RTL support:

1. Add android:supportsRtl attribute to the <application> element in your manifest file and set it to true. This enables the RTL support.

2. Convert left and right layout properties to start and end. For example: android:paddingLeft becomes android:paddingStart.

Have a complete set of default Resources

Keeping the default resources complete is necessary to prevent the app from misbehaving or even crashing if a user has his Android device set to a language which is not supported by your application. In this case the default resource will be used.

This might seem self explanatory, but once you have translated your application to different languages don’t remove or rename your default resources. For example: If you wrote your application in English, do not rename the default values folder to values-en.

Key Structure

Naming keys is hard, so it is best not to overthink it. Making up complicated names for your keys will not be beneficial if you don’t know what the key is for the next day.

A good way of naming keys is naming them after their purpose and not just using an underscored version of the text. This makes it easy to know what it stands for and it will stay relevant even if the text itself gets changed during development.

<string name="signUp_success">We’ve just sent you an email with a confirmation link. Click it to activate your account.</string>

<string name="signUp_error">Your registration failed. Please review the information you entered and fix any errors.</string>

It is common practice to use either underscores as separators or mixedCase when naming your keys, or even a mix of these two.

Don’t concatenate strings

When setting up your project for localization do not fall into the pitfall of thinking your source language will translate 1:1 into any target language.

Here is an example: A user can set his favorite browser in the user settings. Afterwards a message is displayed.
You are using Chrome to browse the Internet.

In the code it might look like this:

String browser = "You are using " + browser.getBrowser() + " to browse the Internet.";

Here it would be wrong to concatenate the string:
R.string.browserSentence_start = "You are using "
R.string.browserSentence_end = " to browse the Internet."

String browser = getString(R.string.browserSentence_start) + browser.getBrowser() + getString(R.string.browserSentence_end);

This will not translate correctly into other languages. You have to translate the whole sentence at once to keep the structure and context in tact.

You can avoid this by using format args:

R.string.browserSentence = "You are using $1%s to browse the Internet.";

String browser = getString(R.string.browserSentence, browser.getBrowser());

This will return the same sentence and make it easier to translate correctly. $1%s is a format arg where $1 means it’s the first arg and %s means it’s a string. In this case the arg will be replaced with browser.getBrowser();.

These placeholders will be automatically detected when a resource file is uploaded to LingoHub. Placeholders are marked within our editor to avoid that translators get confused and remove them.

Make your Layout flexible

Different languages are more or less succinct than others. Design your app in a way that it can hold all the text of target languages or adjust itself accordingly.
There is a rule of thumb for English applications: Other languages take up around 30 % more space.

Don’t forget your Numbers

This might already drift into the topic of localization, but it is good to name it right away, so you are well prepared.
If your application is used worldwide, you have to consider users accessing your application while being located in a different timezone than you are. It is best to save all your timestamps in UTC format to have a unified format and display any kind of related information correctly.

How dates and time are shown also varies throughout the world. If you decide to display the current date and time, it also has to be adjusted to the locale, whatever the format might be (MM/DD/YY, DD/MM/YY or YYYY/MM/DD).

Gather more localization hints in our iOS i18n with Xcode7 and Windows i18n with Visual Studio tutorials or discover helpful tips and country insights on our blog.

Quick Summary

  • Replace all hard coded content with references to resources.
  • Use the Alt/Option + Enter keyboard shortcut.
  • Provide additional information in comments.
  • Name keys after purpose not content.
  • Keep verbose languages in mind when designing.

Try LingoHub 14 Days for free

Start your language project and get access to unlimited features.