Android provides a quite comfortable way of defining localized String arrays via providing one or more arrays.xml in the res/values folder (values, values-de, values-fr, …) e.g.
We experienced some disadvantages doing so:
- you have to maintain two or more arrays.xml, if you have a lot of languages that can be quite an effort (and memory overhead)
- when adding, removing or changing the order you need to that in each arrays.xml which is quite error-prone
- you have to maintain two files per language in your favoured localization tool
With one arrays.xml containing only links to the localized strings.xml you can
- easily add or remove or change the order within an array in a single arrays.xml without the need to do that for all language arrays.xml
- maintain only the strings.xml in your favoured localization tool (online or custom offline)
For moving the localization content from the arrays.xml to the strings.xml we wrote a little Python SCRIPT creating String keys (with optional prefix, e.g. list_) for all items within an array, replacing the string with the key and providing the keys in a new strings.xml, e.g.
Conent of new strings.xml
- you have to handle special characters yourself if it is included in one of your strings since Android does not allow all characters within String keys (e.g. “-”, “(“, …)
- it currently works only on one language, we try to that for all languages at once