Android 字符串数组区域设置验证
我想知道是否有人找到了验证 res/values 目录中字符串数组的好方法。
我使用默认区域设置通过代码创建,并且可能拥有类似的资源
<string-array name="array_example1">
<item>One</item>
<item>Two</item>
<item>Three</item>
</string-array>
然后,当应用程序的翻译人员进行翻译时,他们还会创建一个字符串数组。有时,如果一个翻译落后于另一个资源文件,则数组中的条目可能没有那么多(可能只有上面示例中的“一”和“二”)
是否有任何简单的方法来验证数量是否不匹配条目数?不匹配可能会导致代码出现问题,但由于应用程序有 10 个多种语言的字符串数组,检查它们是否全部匹配非常耗时。
其他人对此有什么方法?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了更好的方法来阻止崩溃。我没有意识到字符串数组可以通过以下方式引用字符串资源:
然后添加
因此,如果存在不匹配,则默认语言将只显示该选项并停止由于不同大小的列表而导致的崩溃
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:
Then add
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