复数
fbt:plural
为你提供了一种复数变体的简写方式。
<fbt desc="复数示例">
你有
<fbt:plural
count={getLikeCount()}
name="点赞数"
showCount="ifMany"
many="赞">
一个赞
</fbt:plural>
在你的
<fbt:plural
count={getPhotoCount()}
showCount="no">
照片
</fbt:plural>。
</fbt>
或者
fbt(
'你有 ' +
fbt.plural('一个赞', getLikeCount(), {
name: '点赞数',
showCount: 'ifMany',
many: '赞',
}) +
' 在你的 ' +
fbt.plural('照片', getPhotoCount()),
'复数示例',
);
以上两个示例在集合期间生成以下内容。
"phrases": [
{
"hashToLeaf": {
"bae7d2f1abd57d08a9dca0b5d05edee8": {
"text": "你有 {点赞数} 赞 在你的照片上",
"desc": "复数示例",
},
"3306b396e08398f28d921b46039f008c": {
"text": "你有 {点赞数} 赞 在你的照片上",
"desc": "复数示例",
},
"c9e4b5b48f38634ffecaf34956a4b186": {
"text": "你在你的照片上有一个赞",
"desc": "复数示例",
},
"cb49d6d764ea8aabdca0e9db7f10ba34": {
"text": "你在你的照片上有一个赞"
"desc": "复数示例",
},
},
"type": "table",
...
}
]
必需的参数:
- 单数短语
string
:<fbt:plural>
中的 JSX 子元素和fbt.plural
中的参数 1 - count
number
:<fbt:plural>
中的count
和fbt.plural
中的参数 2
可选参数:
many
string
:表示英文字符串的复数形式。默认值为{singular} + 's'
showCount
"yes"|"no"|"ifMany"
:是否在字符串中显示{number}
。请注意,单数短语永远没有令牌,而是内联为1
。这是为了考虑像希伯来语这样的语言,在这些语言中,显示实际数字是不合适的- "no":(默认)不显示计数
- "ifMany":仅在复数情况下显示计数
- "yes":在所有情况下都显示计数
name
string
:计数显示的令牌的名称。(默认:"number"
)value
mixed
:用于覆盖显示的number