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.
<item>Unknown</item>
<item>None</item>
<item>New</item>
<item>In Progress</item>
<item>Solved</item>
<item>Closed</item>
<item>Invalid</item>
<item>Reopen</item>
<item>Zombie</item>
</string-array>
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.
<item>@string/status_unknown</item>
<item>@string/status_none</item>
<item>@string/status_new</item>
<item>@string/status_in_progress</item>
<item>@string/status_solved</item>
<item>@string/status_closed</item>
<item>@string/status_invalid</item>
<item>@string/status_reopen</item>
<item>@string/status_zombie</item>
</string-array>
Conent of new strings.xml
<string name="status_unknown">Unknown</string>
<string name="status_none">None</string>
...
Usage example:
Notes:
- 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
