Python 3.8+gettextfunction
gettext.dnpgettext()
contextual translation
The most complete translation function: explicit domain, context and plural form in a single call.
Syntax
text = gettext.dnpgettext(domain, context, singular, plural, n, /)
Five positional arguments in the order domain, context, singular, plural, n — all positional-only, so keyword names are rejected. It is usually reached not directly but through the npgettext method of a translation() object, where the domain is built in. With no catalog found you get the English form for n.
Examples
import gettext
print(gettext.dnpgettext('app', 'cart', 'item', 'items', 3)) # → items
try:
gettext.dnpgettext('app', 'cart', 'item', 'items', n=3)
except TypeError:
print('только позиционно') # → только позиционно
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy