L20n 复数复数

L20n complex plurals

根据 documentation example,库可以支持“复杂语言复数”。

In the Firefox download panel, a string like this shows up while downloading file:

4 hours, 1 minute and 26 seconds remaining.

不幸的是,给定的示例似乎不适用于 3.0.4 版本。

HTML 标记:

<span data-l10n-id="minutesAgo" data-l10n-args="{'minutes':52}">⁨</span>

语言文件(en-US.l20n):

# Date time
<pluralDateTime($n) {
  $n == 0 ? "zero" :
  $n % 100 == 1 ? "one" :
  $n % 100 == 2 ? "two" :
  $n % 100 == 3 || $n % 100 == 4 ? "few" :
  "many"
}>
<_minutes {
  one: "minute",
  two: "minutes",
  few: "minutes",
  many: "minutes"
}>

<minutesAgo "{{ $minutes }} {{ _minutes[pluralDateTime($minutes)] }} ago">

当前结果:

52 undefined ago

预期结果:

52 minutes ago

复数的当前语法是什么?

自定义复数宏目前仅在 v1.x 分支上可用。在 3.x 中,我们缩小了语法支持的范围,并专注于与 HTML 和 webstack 的集成。

在3.x中,您可以使用@cldr.plural全局下可用的内置复数宏。检查 the en-US file in the examples/ folder to see what the usage looks like, or my fork of the L20n Tinker using the v3.x branch: http://stasm.github.io/tinker/.

我们有一个待办事项来记录 v3.x 上语法支持的当前范围。完成后我会更新这个答案。