Python Glossary Русский

all Python 3gettextterm

gettext.NullTranslations

translation catalogs

A translation catalog with no translations: it returns the original strings. The base class of catalogs and the fallback when no .mo file exists.

Syntax

t = gettext.NullTranslations(fp=None)

This is what translation(..., fallback=True) returns when no catalog is found — the program does not crash, it simply speaks the source language. It counts plurals the English way: 1 is singular and everything else, including 0, is plural. add_fallback() chains a backup catalog that receives untranslated strings.

Examples

import gettext
t = gettext.NullTranslations()
print(t.gettext('Hello'))  # → Hello
print(t.ngettext('file', 'files', 1), t.ngettext('file', 'files', 0))  # → file files

See also

Open in the full glossarydocs.python.orgReport an inaccuracy