Skip to content

Most visited

Recently visited

navigation

Localize the UI with Translations Editor

Use the Translations Editor when you have an app that supports multiple languages. Translations Editor provides a consolidated and editable view of all of your default and translated app text (string resources) so that you can view, manage, and localize all of your string resources in one place.

String resources

The string resources for a project are contained in strings.xml files. Your project has a default strings.xml file that contains string resources in the default language for your app, which is the language you expect most of your app users to speak. You can also have translated strings.xml files that contain string resources for other languages that you want your app to accommodate.

Once you have your default strings.xml file completed, you can add the translations yourself, or pay a professional service to do the translations. For information about professional translation services, see Order translation services.

Open the Translations Editor

You can access the Translations Editor from the following places in Android Studio.

Open from the Android view

  1. In the Project > Android panel on the left, select ModuleName > res > values.
  2. Right-click the strings.xml file, and select Open Translations Editor.

    The Translations Editor displays the key and value pairs from the strings.xml file.

    Note: When you have translated strings.xml files, your project has multiple corresponding values folders with suffixes that indicate the language, such as values-es for Spanish. Your default strings.xml file is always in the values (no suffix) folder.

Figure 1 shows the default app text (in this case, English) in the Translations Editor for a simple app before translation work has been done. The contents of translated strings.xml files will appear to the right of the Untranslatable column with one column per language as shown in figure 2.

Figure 1. The Translations Editor showing app text before translation

Open from within strings.xml

You can access the Translations Editor from within any of your strings.xml files.

  1. In the Project > Android panel on the left, select ModuleName > res > values.
  2. Double-click strings.xml to open it for editing.
  3. In strings.xml, click the Open editor link in the upper-right corner.

Note: If you click the Hide notification link, the Open editor link goes away. To bring it back, close and reopen the project.

Open from the Design Editor

You can open the Translations Editor from the Layout Editor's Design Editor to edit your default and translated text to better fit your layout. For information about switching languages in the Design Editor, see Display translated text in the Design Editor.

  1. In the Project > Android panel on the left, select ModuleName > res > layout.
  2. Double-click content_main.xml to open it for editing.
  3. Click the Design tab in the lower-left corner to display the Design Editor.
  4. In the Design Editor, select the Language drop-down list.
  5. Select Edit Translations .

Configure untranslatable rows

In the Translations Editor, you can select Unstranslatable to indicate that you do not want the text in this row to be translated. Text that you would not want translated might be product-specific text like trade names and trade marks, or technical terms that do not have a translation.

When you check Untranslatable, the corresponding line in the default strings.xml file adds translatable="false". In the following example, EasyApp in the top line is not translated because it is the product name.

<resources>
    <string name="app_name" translatable="false">EasyApp</string>
    <string name="action_settings">Settings</string>
    <string name="easy_app">I am a Simple App!</string>
    <string name="next_page">Next Page</string>
    <string name="second_page_message">I am the Second Page!</string>
    <string name="title_activity_second">SecondActivity</string>
</resources>

Add and delete languages

The Translations Editor supports BCP 47 and combines locale and region (country) codes into a single selection for targeted localizations. A locale defines more than the language. A locale includes country-dependent formatting for things like the date and time, currencies, and decimals.

To add a language, do the following:

  1. In the Translations Editor, click the globe icon .
  2. From the drop-down list, select the language you want to add.

    The new language appears in the Translations Editor, and a values-* folder with a strings.xml file is added to the project. For example, values-es for Spanish.

To delete a language, do the following:

You can delete a language in the Translations Editor by deleting every value in the column (see Edit, add, or delete text), or you can delete the project folder for that language, as follows:

  1. In the Project > Android panel on the left, select ModuleName > res.
  2. Right click the values-* folder for the language you want to delete. For example, values-hi for Hindi.
  3. From the drop-down list, select Delete to delete the folder and its strings.xml file.

Edit, add, and delete text

You can operate on the text settings directly in the strings.xml file or through the Translations Editor. This section describes the Translations Editor approach. In the Translations Editor, you can edit, add, or delete text through the list view or through the Translation field at the bottom of the Translations Editor.

Figure 2. List view on the top and the Translation field on the bottom.

List view

To edit or add text, do the following:

  1. Double-click the cell where you want to edit or add text.
  2. Do a keyboard copy-paste, or if you have a keyboard that supports diacritic marks, type directly into the list view.
  3. Tab or move the cursor out of the field.

To delete text, do the following:

  1. Double-click the cell you want to delete.
  2. In the list view, select the text and press Delete.
  3. Tab or move the cursor out of the field.

Translation field

To edit or add text, do the following:

  1. In the list view, single-click the cell where you want to edit or add text.
  2. In the Translation field, do a keyboard copy-paste, or if you have a keyboard that supports diacritic marks, type directly into the Translation field.
  3. Tab or move the cursor out of the field.

To delete text, do the following:

  1. Single-click the cell you want to delete.
  2. In the Translation field, select the text and press Delete.

Add and delete keys

In the Translations Editor, the Key column lists the unique identifiers for each data item in your strings.xml files. You can add and delete keys through the Translations Editor. When you delete a key, the Translations Editor deletes it and all of its associated translations. The Translations Editor uses the Safe Delete refactoring to delete a key so you know if the key text is used elsewhere and have a chance to make necessary adjustments before you delete the key. The Safe Delete refatoring ensures that your code still compiles after you delete the key.

To add a key, do the following:

  1. In the Translations Editor, click Add Key .
  2. In the dialog, enter a key name, default value, and the location of the default strings.xml file.

    Figure 3. Add a key.

To delete a key, do the following:

  1. In the Translations Editor, select the key you want to delete.
  2. Click Remove Keys .
  3. In the Safe Delete dialog, decide if you want to include comments and strings in the search for the key text usages, and click OK.

    If there are no references (usages) to the deleted key, or if all references are safely collapsible, the key is deleted. Otherwise, the Translations Editor displays the Usages Detected dialog with all of the usages that are not safe to delete so you can edit your corresponding code.

    Figure 4. Unsafe usages.

  4. In the Usages Detected dialog, select View Usages.
  5. In the Find Safe Delete Conflicts panel, review the usages.
  6. Right-click a usage to display the context menu and select Jump to Source so you can make the needed changes.
  7. In the Find Safe Delete Conflicts panel, select Rerun Safe Delete to make sure there are no other usages that need attention.
  8. When the usages are cleaned up, click Do Refactor to delete the key.

Correct errors

Figure 5 shows the Translations Editor displaying the contents of the English, Spanish, and French strings.xml files. The red text indicates lines that have errors.

Figure 5. Red text indicates an error condition that you must fix.

To correct an error, do the following:

  1. Hover over the red text to display an explanation of the problem and its resolution.
  2. To correct an error, hover over the red text to display an explanation of the problem and its resolution.

When you make changes in the Translations Editor, the underlying strings.xml files update with your changes. When you make changes in a strings.xml file, the corresponding column in the Translations Editor updates with your changes.

Example Translations Editor corrections:

Display translated text in the Design Editor

To see how the translated text displays in your app layout, toggle the text between the default and translated versions in the Design Editor, as follows:

  1. In the Project > Android panel on the left, select ModuleName > res > layout.
  2. Double-click content_main.xml to open it for editing.
  3. Click the Design tab in the lower-left corner to display the Design Editor.
  4. In the Design Editor, select the Language drop-down list.
  5. Select Edit Translations .
  6. Select the language you want to use to view your app.

    Figure 6. The language drop-down list with Spanish selected.

The Design Editor displays your app layout in the selected language, which in this case is Spanish.

Figure 7. The Design Editor displaying translated text in Spanish.

Set the Design Editor to the default language

To set the language back to the default, select es > Language .

Figure 8. Set to the default language.

Order translation services

  1. In the Translations Editor, click the Order a translation link in the upper-right corner.

    The Android Studio page for ordering translations opens.

  2. Follow the instructions on the ordering page to upload your default strings.xml file, select the target languages, select a vendor, and pay.

Note: App translation services are also available from Google Play and other vendors. See the Google Play App Translation Service announcement.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.