5

I'm developing multi language android app.

I'd like to start app from Android Studio Run button with specified language. Is it possible?

I'm expecting any option.(like Application Language in Xcode Run Options)

Why do I want this?

I'd like to check my app's layout and word, But Launching 'Settings app' is annoy. So I am looking for easy way to change device language setting OR Android Studio Run app options that can specify language each Running.

Thank you.

sekitaka
  • 1,010
  • 2
  • 14
  • 30

1 Answers1

-2

Generic file /values/strings.xml, will be used when locale does not match with one's present in your app. To create locales see these examples.

Please note that you have to create folders for each locale like value-de for German language, then create strings.xml file inside.

Generic strings.xml file:

app/src/main/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name" translatable="false">Spin The Bottle</string>
    <string name="text_hint">Tap on screen to spin the bottle</string>
</resources>

For Arabic language:

app/src/main/res/values-ar/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="text_hint">اضغط على الشاشة لتدور الزجاجة</string>
</resources>

For German language:

app/src/main/res/values-de/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="text_hint">Tippen Sie auf den Bildschirm, um die Flasche zu drehen</string>

Remarks

  1. It is not necessary to translate each and every <string> inside strings.xml.
  2. Notice I have placed translatable="false" on app_name as I wanted my app name to show the same for all locales.
  3. Also app_name is not included in any other locale except generic values folder.
Hamza Rashid
  • 1,329
  • 15
  • 22