Skip to Content

Add New Languages to Your Android Application

test
0 %
Add New Languages to Your Android Application
Details
// Explore More Tutorials

Add New Languages to Your Android Application

See how the SAP Translation Hub can be used to quickly add support for a new language to your app.

You will learn

  • An overview of how the generated app supports different languages
  • How to sign up for the SAP Translation Hub
  • How to use the SAP Translation Hub from within an Android Studio Project

Step 1: Language Support in the Generated App

The wizard generates an Android app that contains translated strings for multiple languages as shown below.

Languages Localized

The language codes (ar, cs, da, de, en, es etc.) can be looked up at Codes for the Representation of Names of Languages.

When a string is used within the app, it reads the string from the appropriate version of the strings_localized or strings.xml file. The strings.xml file contains strings that are provided at design time such as the screen names from the metadata.xml or the app name. Android Studio provides a Translations Editor that can be used to view the values from across the localized strings files. Right-click on the strings.xml file and choose Open Translations Editor.

Notice in the screenshot below that the resources that are from the strings.xml file such as Suppliers are not translated. These will get translated in Step 3.

Translations Editor

The below code in the class LogonActivity, in the method startLaunchScreen, is an example of the code used to read from a strings file.

launchScreenSettings.setLaunchScreenHeadline(getString(R.string.welcome_screen_headline_label));

The getString method determines what the current local is on the device or emulator and then reads from the matching strings file.

The language can be set on an Android device or emulator via Settings > System > Languages & input > Language preferences. A second language such as French can be added.

Additional Languages

The default language can be selected by long pressing on a language and dragging it to the top of the list.

Default Language

When the app is restarted, it now shows strings in the preferred language if that language is supported by the app.

French Welcome Screen

See also the following links.

Localize your app

Support different languages and cultures

Localize the UI with Translations Editor

How many languages does the wizard generated app provide support for?
×
Step 2: Sign Up for the SAP Translation Hub

The SAP Translation Hub enables translation of resources to specified languages.

In the SAP Cloud Platform management cockpit, enable SAP Translation Hub.

Enable SAP Translation Hub

Click on the tile and then choose Go to UI for Translation Workflow.

Go To Translation Hub UI

Notice below that there are no existing translation projects. In the next section, a wizard integrated into Android Studio will create a translation project and request new language files for Italian which is not one of the languages the generated app already contains.

Translation Hub UI

Note that the SAP Translation Hub wizard in the SAP Cloud Platform SDK for Android is currently not compatible with the SAP Translation Hub in the SAP Cloud Platform Trial. It is possible to press the + icon in the above UI to create a new translation project, upload strings_localized.xml and request a translation. One of the benefits of this is that feedback is provided on the expected quality of the translation as shown below.

File upload translation
Log on to answer question
Step 3: Add a new Language to your Project

Right-click on a file in the Project Explorer and choose Translate Resources with SAP Translation Hub.

Translation wizard Context MenuTranslation Wizard Page 1

Choose Create new SAP Translation Hub project.

Translation Wizard Page 2

Choose the Domain of the application, specify the source language as English and the target language to add.

Translation Wizard Page 2

Select the two source files to be used for the translation.

Translation Wizard Page 2

After pressing finish and waiting for a few moments, the Event Log should print Success: Project translated successfully.

There should now be two additional files, strings_localized_it.xml and strings_it.xml.

Translation Result

In the emulator or device, set the preferred language to be Italian, then run the app and notice that the app now displays Italian strings.

Translation Result in App

Some of the strings in the app are part of the foundation or Fiori library and their strings are not easily accessible to be localized. A couple of examples are the basic authentication screen and the passcode screen.

Further information on this feature can be found at SAP Translation Hub.

Congratulations! You have learned how to use the SAP Translation Hub to quickly add translations to your application!

Log on to answer question

Next Steps

Back to top