How does Android handle unsupported languages?

2019-06-02 09:53发布

I've made an app that runs in multiple languages, but if the user runs it in an unsupported language, will it display the main one? If it is the case, how can I make it display in English instead?

5条回答
老娘就宠你
2楼-- · 2019-06-02 10:16

In fact when you run your app, the app will check if the locale is available thanks to the string.xml contains in the value-locale folder. If nothing is found the string.xml in values is used so just put english traduction in your string.xml. I hope to be clear.

查看更多
贪生不怕死
3楼-- · 2019-06-02 10:17

if the user runs it in a not supported language, will it display the main one?

The default language, yes See the docs for detailed information.

Whenever the application runs in a locale for which you have not provided locale-specific text, Android will load the default strings from res/values/strings.xml. If this default file is absent, or if it is missing a string that your application needs, then your application will not run and will show an error.


how can I make it to display English instead?

Also see the docs for that, you should use english in the default strings.xml

How to Create Default Resources

Put the application's default text in a file with the following location and name:

res/values/strings.xml (required directory)

The text strings in res/values/strings.xml should use the default language, which is the language that you expect most of your application's users to speak.

查看更多
神经病院院长
4楼-- · 2019-06-02 10:17

Language which you want to load by default then put that strings.xml in values folder without any suffix with values folder

查看更多
虎瘦雄心在
5楼-- · 2019-06-02 10:21

Language strings in Android Studio

Depends really what language are you using in your string.xml (main one). If there is no language case for what the user selects in the Settings, the app will load in the default values from the strings.xml

查看更多
老娘就宠你
6楼-- · 2019-06-02 10:25

You are right.

Just put your english strings on the strings.xml file, so it will be loaded by default if no other language matches the phone lang.

Hope this helps.

查看更多
登录 后发表回答