Android strings.xml length

孤者浪人 提交于 2019-12-25 02:26:52

问题


Is there a way to get the number of strings in my strings.xml or to check if all strings are available in the selected language?


回答1:


I don't think there is something in the public api. You can try with reflection since from strings.xml the R.string class is generated..

try this:

Field[] f = R.string.class.getDeclaredFields();



回答2:


I don't think your approach is the best. If you are going to provide multiple languages, then probably the best way to store these in android is as alternative resources (see http://developer.android.com/guide/topics/resources/providing-resources.html and http://developer.android.com/guide/topics/resources/localization.html).

If you are going to do that, than you should be having translated resources of everything you need, so there isn't a question of partly translated content.

I think you'd be better off using a 3rd party crowd-sourced translation service and just prompt your users to that service for any languages that aren't yet ready to be included. Look at crowdin for an example of such a service. I know Friendcaster, for example, used this service to translate to multiple languages and it worked very well (e.g. https://crowdin.com/project/f-plus).



来源:https://stackoverflow.com/questions/9586065/android-strings-xml-length

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