Is there a way to retrieve ALL localised versions of an Android application's label?
If an application label is localised, I have a requirement to retrieve all localisation variants. Effectively I need to know if the android:label points to a string reference and, if so, all the locale values present in the string resources. Any id开发者_如何学Pythoneas?
I don't have a full answer but here's what I came up with.
Localization - Here is the official documentation for android localization. You can ensure that your android:label points to a string reference if you have it point to a key in the /res/values/strings.xml. Specific localization strings can be overridden by using qualifiers on the directory, for instance for French versions you can put them in /res/values-fr/strings.xml. Any values not found in the French version will default to the previous unqualified file.
I'm not sure about getting all the locale strings for a specific resource but there is getAssets().getLocales() which will return a string array of the locales the asset manager has resources for (I'd assume for any resource, not just a particular resource)
Lastly, if you don't need to do this at run time you could try to write a script/program to examine all the localization directories under /res and compile a list of all resources with their localized values.
精彩评论