Skip to main content

lazy_number

Creates a lazy proxy object that delays the evaluation of a numeric-dependent string until it is formatted or interpolated, allowing for dynamic pluralization based on provided arguments.

def lazy_number(
func: callable,
resultclass: type,
number: int | str | None = null,
**kwargs: dict
) - > lazy object

Creates a lazy translation object that delays evaluation until a numeric value is provided for pluralization. This is used to handle strings that depend on a count that is not known at the time of definition.

Parameters

NameTypeDescription
funccallableThe translation function to be called lazily, typically a gettext variant.
resultclasstypeThe class type that the lazy object should mimic, usually a string type.
number`intstr
**kwargsdictAdditional keyword arguments passed to the translation function.

Returns

TypeDescription
lazy objectA lazy proxy object that evaluates to a translated string once a numeric value is supplied via formatting or mapping.