Android string-array locale verification
I was wondering if anybody had come across a good way to validate string-arrays in the res/values directory.
I create by code using the default locale and may have a resource of something like
<string-array name="array_example1">
<item>One</item>
<item>Two</item>
<item>Three</item>
</string-array>
Then when the translators for the app make their translations they also create a string-array. Occasionally if one translation lags behind another one of the开发者_Python百科 resource files may have not as many entries in the array (maybe only "One" and "Two" from the above example)
Is there any easy way to validate whether there's a mismatch in the number of entries? Having a mismatch can cause problems in the code, but as the app has 10's of string-arrays in several languages checking they all match up is time consuming.
What approach do others have for this?
I've found a better way to stop the crashes. I hadn't realised that string-arrays could reference string resources in the following way:
<string-array name="array_example1">
<item>@string/resOne</item>
<item>@string/resTwo</item>
<item>@string/resThree</item>
</string-array>
Then add
<string name="resOne">One</string>
<string name="resTwo">Two</string>
<string name="resThree">Three</string>
Therefore this way if there is a mismatch the default language will just get shown for that option and stop crashes due to different sized lists
精彩评论