Skip to main content

_n

Translates a plural message.

info

Shorthand for L10n._n.

Signature

_n(message: string, messagePlural: string, count: number, ...arguments: string[]): string

Parameters

NameTypeOptionalDescription
messagestringNoSpecifies the message to translate.
messagePluralstringNoSpecifies the plural message to translate.
countnumberNoSpecifies the count for the plural (can be reference in the message with %1).
argumentsstring[]YesOptional string arguments which can be referenced in the message using the percent sign followed by the argument index %n. The count value is automatically included as the first argument (%1).

Return value

Returns the translated message.

Example

import { _n } from "@tripetto/builder";

// Outputs `1 car` to the console.
console.log(_n("1 car", "%1 cars", 1));

// Outputs `2 cars` to the console.
console.log(_n("1 car", "%1 cars", 2));