问题
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