我使用复数来编译 Android 应用程序的数量字符串。我完全按照教程中可以找到的内容进行操作:
res.getQuantityString(
R.plurals.number_of_comments, commentsCount, commentsCount);
以下是复数的定义:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals name="number_of_comments">
<item quantity="zero">No comments</item>
<item quantity="one">One comment</item>
<item quantity="other">%d comments</item>
</plurals>
</resources>
有趣的是,输出字符串与我定义的很奇怪:
commentsCount = 0 => "0 comments"
commentsCount = 1 => "One comment"
commentsCount = 2 => "2 comments"
我想这是因为文档说明When the language requires special treatment of the number 0 (as in Arabic).
了zero
数量。有没有办法强制我的定义?