Skip to main content

npgettext_lazy

Returns a lazy-evaluated version of npgettext, allowing for pluralized translations with a specific context that are resolved only when the result is accessed as a string.

def npgettext_lazy(
context: str,
singular: str,
plural: str,
number: int
) - > LazyString

Lazily resolves a pluralized translation within a specific context, deferring the lookup until the string is actually used in a rendering context.

Parameters

NameTypeDescription
contextstrThe translation context used to disambiguate identical strings (e.g., 'verb' vs 'noun').
singularstrThe default singular form of the message to be translated.
pluralstrThe default plural form of the message to be translated.
numberintThe variable used to determine which form (singular or plural) to use based on language-specific pluralization rules.

Returns

TypeDescription
LazyStringA proxy object that evaluates to the translated string corresponding to the provided context and count when accessed.