Skip to main content

ngettext_lazy

A lazy version of ngettext that delays the translation of singular and plural strings until they are accessed as a string, typically used for pluralization in translated content.

def ngettext_lazy(
singular: string,
plural: string,
number: integer|string = None
) - > LazyString

Creates a lazy-evaluated version of ngettext for translating strings that vary based on a numeric count. Use this when defining pluralizable strings in global scopes or class attributes where the active language or count is not yet determined.

Parameters

NameTypeDescription
singularstringThe translation key for the singular form of the message.
pluralstringThe translation key for the plural form of the message.
number`integerstring` = None

Returns

TypeDescription
LazyStringA proxy object that evaluates to the translated singular or plural string only when it is accessed or rendered.