internationalisation in android

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 20:26:41

问题


I am making an app in which I want to implement internationalization. I have created alternative resources like

res/values-fr/strings.xml which Contains French text for all the strings, including title

Can anyone tell me what to do next...

thanks


回答1:


You should always have default strings in res/values/strings.xml, because Android tries to use the most specific resource available. If you have for example res/values-fr/strings.xml and res/values-de/strings.xml and the users phone is set to English, your app will crash because neither de nor fr are applicable for English there are no fallback resources.

After you have specified your default strings and any translations in their respective subfolders, you can use the strings by their qualifiers. For example R.string.some_string. Android will then use the most appropriate translation that is available for the users current device language.

All that and more is explained here: Localizing with Resources




回答2:


Device will load locale automatically based on system languge. No extra steps required unless you want to change locale in your app independently.



来源:https://stackoverflow.com/questions/7441000/internationalisation-in-android

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