颤振国际支持ICU号码占位符"#



根据ICU文件,在像

这样的复数形式消息中
The film won {n, plural,
one {# award}
other {# awards}}

特殊的#符号将显示当前区域设置的数字系统中的给定计数。

目前看来

flutterw pub run intl_utils:generate

不会将#替换为给定的数字参数。

例如:

{number, plural, one {Temporarily inactive (# day left)} other {Temporarily inactive (# days left)}}

将生成

String InactiveDaysLeft(num number) {
return Intl.plural(
number,
one: 'Temporarily inactive (# day left)',
other: 'Temporarily inactive (# days left)',
name: 'Events_MeetingRoom_InactiveDaysLeft',
desc: '',
args: [number],
);
}

使用此消息时,flutter intl也不支持此功能。如果将数字2传递给此消息,它将直接返回

Temporarily inactive (# days left)

有谁知道这是故意的还是因为我在实践中做错了什么?

请查看下面的示例。这有点类似于您对动态数据的需求。

String howManyPeople(int numberOfPeople, String place) => Intl.plural(
numberOfPeople,
zero: 'I see no one at all in $place.',
one: 'I see $numberOfPeople other person in $place.',
other: 'I see $numberOfPeople other people in $place.',
name: 'howManyPeople',
args: [numberOfPeople, place],
desc: 'Description of how many people are seen in a place.',
examples: const {'numberOfPeople': 3, 'place': 'London'},
);

如果您使用基于arb文件的本地化:

"msg": "The film won {n, plural, =1{{n} award} other{{n} awards}}",
@"msg": {
"description": "A generic description",
"placeholders": {
"count": {
"type": "int"
}
}

最新更新