Traduction

Afin de traduire les libellés, vous pouvez utilisez les services de https://mymemory.translated.net et du fichier PHP situé ici

Malheureusement, après plusieurs connexions, le serveur qui fait tourner le script a été banni, ce qui m’a obligé à me rabattre sur Google Traduction. Pour l’activer et obtenir une clef d’API, suivre https://codelabs.developers.google.com/codelabs/cloud-translation-intro/index.html#4 et utilisez le script PHP situé là, basé sur le tuto https://www.sitepoint.com/using-google-translate-api-php/

Sinon, pour une traduction multilingue en ligne, il est possible d’utiliser : https://translatr.varunmalhotra.xyz/

Le principe est de créer une arborescence dans les ressources \res\values-xx où xx représente la langue

MyProject/
    res/
       values/
           strings.xml
       values-es/
           strings.xml
       values-fr/
           strings.xml

Chaque fichier xml contenant :



    <string name="title">Mon Application
    <string name="hello_world">Bonjour le monde !

Les valeurs par défaut étant contenue dans  le répertoire res/values

Pour les icônes dans \res\drawable

Afin de remplacer les libellés, surligner le libellé puis

  • Eclipse menu selectionnez Refactor -> Android -> Extract Android String.

Sous STUDIO :

  • Go to « Analyze > Run Inspection ..« , and type "Hardcoded strings". Run that in your whole project, and you will get an inspection results panel that will show all the hardcoded text of projects. Then hit Alt + Enter and you’ll get an option to automatically extract that Strings.

Où bien manuellement dans le code :

// Get a string resource from your app's Resources
String hello = getResources().getString(R.string.hello_world);

// Or supply a string resource to a method that requires a string
TextView textView = new TextView(this);
textView.setText(R.string.hello_world);

is_title.setSummary(getResources().getString(R.string.conf_istitle_sum)+ » ON »);

Dans un « static context » pour des ressources system :

Resources.getSystem().getString(android.R.string.cancel)

Pour des ressources traduites :

Resources.getSystem().getString(R.string.message_test)

Dans les fichiers xml :

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />


  Pour tester :

Sur le smartphone : Home > Menu > Settings > Locale & text > Select locale.

Pour traduire des libellés dans les tableaux (exemple pour les settings) :

Créer un tableau de valeurs dans un fichier xml : https://www.homeandlearn.co.uk/android/grid_view_array.html

Puis :

res/values/array.xml
res/values-fr/array.xml
res/values-ja/array.xml

 

Liste des langues supportées :

Language / Locale                 Supported since version

English, US (en_US)               1.1
German, Germany (de_DE)           1.1
Chinese, PRC (zh_CN)              1.5
Chinese, Taiwan (zh_TW)           1.5
Czech, Czech Republic (cs_CZ)     1.5
Dutch, Belgium (nl_BE)            1.5
Dutch, Netherlands (nl_NL)        1.5
English, Australia (en_AU)        1.5
English, Britain (en_GB)          1.5
English, Canada (en_CA)           1.5
English, New Zealand (en_NZ)      1.5
English, Singapore(en_SG)         1.5
French, Belgium (fr_BE)           1.5
French, Canada (fr_CA)            1.5
French, France (fr_FR)            1.5
French, Switzerland (fr_CH)       1.5
German, Austria (de_AT)           1.5
German, Liechtenstein (de_LI)     1.5
German, Switzerland (de_CH)       1.5
Italian, Italy (it_IT)            1.5
Italian, Switzerland (it_CH)      1.5
Japanese (ja_JP)                  1.5
Korean (ko_KR)                    1.5
Polish (pl_PL)                    1.5
Russian (ru_RU)                   1.5
Spanish (es_ES)                   1.5
Arabic, Egypt (ar_EG)             2.3
Arabic, Israel (ar_IL)            2.3
Bulgarian, Bulgaria (bg_BG)       2.3
Catalan, Spain (ca_ES)            2.3
Croatian, Croatia (hr_HR)         2.3
Danish, Denmark(da_DK)            2.3
English, India (en_IN)            2.3
English, Ireland (en_IE)          2.3
English, Zimbabwe (en_ZA)         2.3
Finnish, Finland (fi_FI)          2.3
Greek, Greece (el_GR)             2.3
Hebrew, Israel (iw_IL)*           2.3
Hindi, India (hi_IN)              2.3
Hungarian, Hungary (hu_HU)        2.3
Indonesian, Indonesia (in_ID)*    2.3
Latvian, Latvia (lv_LV)           2.3
Lithuanian, Lithuania (lt_LT)     2.3
Norwegian-Bokmol, Norway(nb_NO)   2.3
Portuguese, Brazil (pt_BR)        2.3
Portuguese, Portugal (pt_PT)      2.3
Romanian, Romania (ro_RO)         2.3
Serbian (sr_RS)                   2.3
Slovak, Slovakia (sk_SK)          2.3
Slovenian, Slovenia (sl_SI)       2.3
Spanish, US (es_US)               2.3
Swedish, Sweden (sv_SE)           2.3
Tagalog, Philippines (tl_PH)      2.3
Thai, Thailand (th_TH)            2.3
Turkish, Turkey (tr_TR)           2.3
Ukrainian, Ukraine (uk_UA)        2.3
Vietnamese, Vietnam (vi_VN)       2.3

de-rDE German / Germany res/values-de/ res/drawable-de-rDE/ 
fr-rFR French / France res/values-fr/ res/drawable-fr-rFR/ 
fr-rCA French / Canada res/values-fr/ res/drawable-fr-rCA/ 
en-rCA English / Canada (res/values/) res/drawable-en-rCA/ 
ja-rJP Japanese / Japan res/values-ja/ res/drawable-ja-rJP/ 
en-rUS English / United States (res/values/) res/drawable-en-rUS/ 
 

Resources :

https://www.ibabbleon.com/android_app_localization_translation.html

http://developer.android.com/training/basics/supporting-devices/languages.html

http://www.icanlocalize.com/site/tutorials/android-application-localization-tutorial/

http://developer.vodafone.com/develop-apps/android/how-support-multiple-languages-android/

Glossaire : https://www.ibabbleon.com/apple-ios-localization-term-glossary.html

Laisser un commentaire

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur la façon dont les données de vos commentaires sont traitées.

Articles récents
Commentaires récents
fatima dans Bienvenue !
AdminDroid dans Bienvenue !
fatima dans Bienvenue !
Archives
Catégories