Skip to content

plural() ​

ts
function plural(
   count: number | undefined, 
   forms: PluralForms, 
   locale?: string
): string;

Picks the form fitting a count by the plural rules of a locale.

Parameters ​

count ​

number | undefined

The count; none picks other.

forms ​

PluralForms

The text per plural category.

locale? ​

string

Defaults to the document's lang, then the runtime's locale.

Returns ​

string

The fitting form.

Example ​

ts
plural(count, { one: msg('device'), other: msg('devices') })