Skip to main content

npgettext

Returns the plural form of a message in a specific context by calling the ngettext function.

def npgettext(
context: string,
singular: string,
plural: string,
number: integer
) - > string

Translates a message with a specific context and handles pluralization based on a numeric value.

Parameters

NameTypeDescription
contextstringThe context string used to disambiguate identical messages in different parts of the application.
singularstringThe default singular form of the message to be translated.
pluralstringThe default plural form of the message to be translated.
numberintegerThe numeric value used to determine whether the singular or plural form of the message should be returned.

Returns

TypeDescription
stringThe translated string in either singular or plural form, appropriate for the provided count and context.