Skip to main content

npgettext

Translates a message with a specific context and handles pluralization by prepending the context to the singular and plural strings before looking up the translation.

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

Translates a message with a specific context, providing pluralization support based on the provided count.

Parameters

NameTypeDescription
contextstringThe translation context used to disambiguate identical strings 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 numerical value used to determine whether to use the singular or plural form of the translation.

Returns

TypeDescription
stringThe translated string in the appropriate singular or plural form for the given context, or the original source string if no translation is found.