Plural rules
If activeLanguage = 'en', then these translation texts:
// l10n.en.json
{
"updated": "This page has been updated " +
"{{ 0 | plural : 0=just now; 1=one minute ago; 2~10=# minutes ago; other=formerly }}."
}
And this employ will produce the indicated output:
<ng-container *translate="let t; node: 'l10n'">
<div>{{ t('updated', 0) }}</div>
<div>{{ t('updated', 1) }}</div>
<div>{{ t('updated', 5) }}</div>
<div>{{ t('updated', 20) }}</div>
</ng-container>
|
|
// HTML output
It has been updated just now.
It has been updated one minute ago.
It has been updated 5 minutes ago.
It has been updated formerly.
|
Each option determines a text to be displayed depending on the value passed.
- option key
-
number
The option value is displayed if the key matches the value passed.
number~number
If the option key defines a range, the option value is displayed when
the value passed is in the range. The boundaries of the range are separated
by a tilde (~
),
"other"
The option value is displayed when none of the option keys matches
the value passed.
- option value
-
Represents a text to be displayed when the option key matches the value passed.
If the text contains a hashmark (
#
), it is replaced by the value passed.