/
Android: Translations

Android: Translations

Android runs on many devices in many regions. To reach the most users, make sure that your app handles text, audio files, numbers, currency, and graphics in ways appropriate to the locales where your app is used.

This page describes one practice for localizing Android apps. The description refers to sample code you can find in “Android: DWG Editor”.

image-20240529-131054.png


Localize and translate Android strings JAVA

It is very simple to localize and translate Android related strings. Strings can be localized by using only a string identifier e.g. R.string.app_name and a predetermined pair of identifier and text. All identifiers can be used in source code and layouts. The pair of identifier and text is stored in a file named strings.xml below folder res. Localized strings can be also saved in files with a custom name to group translations ( string.xml , strings_feature.xml, strings_settings.xml, … ). Folder res can be stored at a custom location. Default location: $APPFOLDER$/main/src/res
A custom location can be specified in build.gradle

sourceSets { main { res{ srcDir '$CUSTOMPATH$' } } }


Every application is supposed to have a source language. The app DWG Editor uses English and offers German as second language. More details here → https://developer.android.com/training/basics/supporting-devices/languages

The default language file is stored in $APPFOLDER$/main/src/res/values

values/strings.xml <resources> <string name="app_name">DWG Editor</string> <string name="action_settings">Settings</string> ... </resources>


Each additional file is stored in $APPFOLDER$/main/src/res/values-$LANGUAGE_CODE$

values-de/strings.xml <resources> <string name="app_name">DWG Editor</string> <string name="action_settings">Einstellugen</string> ... </resources>


How to change SDK language C++

The SDK ships precompiled commands and prompts in 14 different languages. To activate one of these languages the app has to call GetFxSystemServices()->GetHostAppServices()->setLANGUAGE(code). To find the correct code for the matching language please check the table down below.
IMPORTANT: Make sure there is no active document. The new language will take effect when opening a new document.

 

 

Language

Code

Support

Language

Code

Support

System

0

-

German

1

English

2

Turkish

3

Hungarian

4

Polish

5

Japanese

6

French

7

Chinese Traditional

8

Chinese Simplified

9

Italian

10

Spanish

11

Greek

12

Korean

13

Vietnamese

14

Catalan

15

Thai

16

Dutch

17

Russian

18

Portuguese

19

Czech

20

All C++ translations are stored in a special file. This file exists for every supported language. The SDK reads the language code and attempts to load the corresponding file. All files must be stored in folder assets. Folder assets can be stored at a custom location. Default location: $APPFOLDER$/src/main/assets
A custom location can be specified in build.gradle


The sample “Android: DWG Editor” supports English and German. The suitable files and folders can be found in Samples\CFx\ARESSimplified_android\app_editor\src\main\assets\

  • \assets\Support\messages\english\application.qm

  • \assets\Support\messages\german\application.qm

IMPORTANT: The path to the translation files must match exactly the following pattern:
\assets\Support\messages\$LANGUAGE$\application.qm , all supported language packages are shipped with the SDK. See subfolder “Translations”.

How to change app language JAVA

All Java strings require the active activity to be restarted. Calling finish() closes the activity and calling startActivity() starts the activity. App developers may also gently inform the user to restart the app. To finally read the correct translated strings the resource configuration must be updated accordingly.

Related content

Android: Miscellaneous
Android: Miscellaneous
More like this
Android: Sample Project ARESSimplified_android
Android: Sample Project ARESSimplified_android
More like this
Android Developer's Guide
Android Developer's Guide
More like this