How to internationalize Android app?

删除回忆录丶 提交于 2019-12-07 14:33:40

问题


How do I determine the language setting of an Android device. I am doing this to internationalize my app. Thanks!


回答1:


You have to use different string.xml files

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

Refer below link

Supporting Different Languages

And also Read Localization




回答2:


The most common to do this is to keep a string file with the strings you want to localize in the res/values folder. You can then create additional values folders marked with resource qualifiers that will contain localized string files.

For example, if you want to translate to german, you create the res/values-de folder and put your localized string file in the folder. Android will load this folder automatically if the language is set to german. If the current system language has no values folder, it will use the default res/values folder.




回答3:


Create values folder for different language and put this language String.

example : values-ca and put Canada language String in this folder.

So, if user change the phone language then it is show this country language.

Thanks.




回答4:


You have to use different string.xml files

res/ values/ strings.xml values-hi/ strings.xml

<resources>
<string name="welcome">स्वागतम</string>
<string name="email">ईमेल पता</string>
<string name="password">पासवर्ड</string>
<string name="login">लॉगिन</string>
<string name="signup">खाता नहीं है? साइन अप करें</string>

values-gu/strings.xml

<resources>
<string name="welcome">પધારો </string>
<string name="email">ઈમૈલ નું નામ</string>
<string name="password">પાસવોર્ડ</string>
<string name="login">લોગીન</string>
<string name="signup">એકાઉન્ટ નથી ? સાઈન ઉપ કરો</string>

values-ja/strings.xml

<resources>
<string name="welcome">歓迎</string>
<string name="email">電子メールアドレス</string>
<string name="password">パスワード</string>
<string name="login">ログイン</string>
<string name="signup">アカウントをお持ちでない場合は?サインアップ</string>

values-ja/strings.xml

<string name="welcome">Willkommen!</string>
<string name="email">Email Addresse</string>
<string name="password">passowrd</string>
<string name="login">Login</string>
<string name="signup">müssen nicht angemeldet? Anmeldung</string>




回答5:


Do you really need this to do manually? Actually in android are already built-in internationalization mechanizms - resource qualifiers.

All you need to do is add specific strings.xml for each locale.

http://developer.android.com/guide/topics/resources/localization.html



来源:https://stackoverflow.com/questions/11733874/how-to-internationalize-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!