复数字符串资源中文总是获得quantity为other的字符串

来源:互联网 发布:质量问题淘宝怎么陪 编辑:程序博客网 时间:2024/05/21 18:49
<plurals name="unicornCount">    <item quantity="one">One unicorn</item>    <item quantity="other">%d unicorns</item></plurals>
String s = getResources().getQuantityString(R.plurals.unicornCount, 1, 1);Log.d(this.getClass().getName(), s);s = getResources().getQuantityString(R.plurals.unicornCount, 3, 3);Log.d(this.getClass().getName(), s);

因为中文没有复数语法,所以当语言是中文时,将总是获得quantity为other的字符串

Although historically called "quantity strings" (and still called that in API), quantity strings should only be used for plurals. It would be a mistake to use quantity strings to implement something like Gmail's "Inbox" versus "Inbox (12)" when there are unread messages, for example. It might seem convenient to use quantity strings instead of an "if" statement,but it's important to note that some languages (such as Chinese) don't make these grammatical distinctions at all, so you'll always get the "other" string.
0 0
原创粉丝点击