1

According to the documentation example, the library can support "complex language plurals".

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

4 hours, 1 minute and 26 seconds remaining.

Unfortunately, the given example seems not work with the 3.0.4 release.

HTML markup:

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

Language file (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">

Current Result:

52 undefined ago

Expected result:

52 minutes ago

What is the current syntax for plurals?

4

1 回答 1

2

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

@cldr.plural在 3.x 中,您可以使用全局下可用的内置复数宏。检查示例/文件夹中的 en-US 文件以查看使用情况,或者我使用 v3.x 分支的 L20n Tinker 的分支:http ://stasm.github.io/tinker/ 。

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

于 2015-08-17T15:32:20.353 回答