3
How to apply internationalization to an Android app? On the app’s play store publishing page, is there a tab on translations, just enough? How to apply? Or is there another way? I’m in doubt because I’m a beginner in the area.
3
How to apply internationalization to an Android app? On the app’s play store publishing page, is there a tab on translations, just enough? How to apply? Or is there another way? I’m in doubt because I’m a beginner in the area.
15
No, it’s not just how you do it i18n in an Android app. This way is only relative to the language in which your app is shown in Google Play, does not affect how your app texts will vary for each language.
You can internationalize the elements that describe your app on Google Play, and they are:
In these three categories you define elements (text, images, videos) in each of the languages you set your app to be displayed in Google Play.
This would be an example of how is defined the languages in which the elements describing your app will be presented in Google Play:
As you may know, every Android app has resources (s).
The features of an Android app are files, which stay hierarchically from the path /res/
. And they can be of various kinds:
Activity
, one Fragment
or item of a ListView
). They stay in the briefcase /res/layout
;/res/drawable
;/res/anim
;/res/values
, in them are placed any resource that can be used in the application (Strings
, Integers
, Dimensions
, Styles
, Colors
, Attributes
).There are many others, I will not extend myself too much not to deviate from the main subject. For more details take a look at the documentation on Resources
.
And these features can be "qualified" for certain properties of the device on which it will run, they are not required. The most common properties are:
ldpi
, mdpi
, hdpi
, xhdpi
and among others.land
(for Landscape), port
(for Portrait).sw600dp
, w600dp
, sw720dp
, w720p
and many others.vN
, where N is any Android (1, 2, 3 and etc...)An example would be: /res/drawable-ldpi
, /res/drawable-mdpi
, /res/values-pt
.
There is the precedence of qualifiers, where the locale has the highest precedence among others.
This one is an example of the organization of features and codes of an Android app, of course it can vary depending on various factors:
To begin to internationalize, the correct thing is never to have Strings
Hardcoded, neither in Layouts nor in code, but within a Resource of String
. That’s one of the Location check-list items.
Combining the recovery of String
of Resources and the language qualifiers is that it is possible to internationalize an app.
A Resource of String
(for example: /res/values/strings.xml
) that’s how:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Nome do App</string>
<string name="action_settings">Settings</string>
// Demais strings
</resources>
OBS: It is worth noting that you can give the name you want to the file, for example /res/values/qualquercoisa.xml
, but there is good practice in giving meaningful names. Android does not see file names in folders (the folders are that important) when going to compile your Resources (is aapt who does the processing and creation of the binary file that is embedded in apk).
To recover one of those String's
in a code, just use the Context
:
String appName = context.getString(R.string.app_name);
The Context
may be a Activity
, Application
, Service
, BroadcastReceiver
among others...
To use one of these String's
in another Resource, just use a reference:
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name" /> <!-- Aqui você referencia a String da chave app_name.
When using language qualifiers in a values
for Portuguese and French would be:
- /res
- /values
- strings.xml
- outros...
- /values-pt
- strings.xml
- outros...
- /values-fr
- strings.xml
- outros...
- Demais resources
In this case, when your app runs on a device that is from one of these languages (Portuguese or French), it will retrieve the Resource of String
(strings.xml
) that best qualifies for the device language (/res/values-pt/strings.xml
or /res/values-fr/strings.xml
). In that case, you will recover the String
in the right language.
When there is none Resource qualify (someone from the United States for example) for a particular key, he will choose the standard (/values/strings.xml
). If not, it will generate a RuntimeException
during the run.
For more information, take a look at Localizing with Resources.
In addition, the Google Play has a professional translation service, where he receives his Resources of String
and returns it in the language you wish, but is paid.
0
Well, to translate the apps, you should work with your app’s string files. For each desired language a file containing the translated text can be created. This way you can work with the location your app is running in and use the most appropriate word/phrase dictionary for the region. Here you can check some recommendations and ways to work with this functionality.
As for the translation service that is offered on Google Play, you will have to submit your text file and select the languages you want to translate, however you will have to pay for this service.
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
Thanks @Paulohenriqueneryoliveira, passed unnoticed more than once :/ Thanks for the touch.
– Wakim
@wakim
now it’s all right! if you can vote on my questions and answers I thank you already!– user28366
Spectacular response.
– Piovezan