How does Android handle unsupported languages?

社会主义新天地 提交于 2020-01-03 00:53:29

问题


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?


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/32989147/how-does-android-handle-unsupported-languages

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