class Translations(NullTranslations, gettext.GNUTranslations): (source)
An extended translation catalog class.
Class Method | load |
Load translations from the given directory. |
Method | __init__ |
Initialize the translations catalog. |
Method | __repr__ |
Undocumented |
Method | add |
Add the given translations to the catalog. |
Method | merge |
Merge the given translations into the catalog. |
Constant | DEFAULT |
Undocumented |
Instance Variable | domain |
Undocumented |
Inherited from NullTranslations
:
Method | dgettext |
Like ``gettext()``, but look the message up in the specified domain. |
Method | dngettext |
Like ``ngettext()``, but look the message up in the specified domain. |
Method | dnpgettext |
Like ``npgettext``, but look the message up in the specified `domain`. |
Method | dpgettext |
Like `pgettext()`, but look the message up in the specified `domain`. |
Method | ldgettext |
Like ``lgettext()``, but look the message up in the specified domain. |
Method | ldngettext |
Like ``lngettext()``, but look the message up in the specified domain. |
Method | ldnpgettext |
Equivalent to ``dnpgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. |
Method | ldpgettext |
Equivalent to ``dpgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. |
Method | lnpgettext |
Equivalent to ``npgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. |
Method | lpgettext |
Equivalent to ``pgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. |
Method | npgettext |
Do a plural-forms lookup of a message id. `singular` is used as the message id for purposes of lookup in the catalog, while `num` is used to determine which plural form to use. The returned message string is an 8-bit string encoded with the catalog's charset encoding, if known. |
Method | pgettext |
Look up the `context` and `message` id in the catalog and return the corresponding message string, as an 8-bit string encoded with the catalog's charset encoding, if known. If there is no entry in the catalog for the `message` id and `context` , and a fallback has been set, the look up is forwarded to the fallback's ``pgettext()`` method... |
Method | udgettext |
Like ``ugettext()``, but look the message up in the specified domain. |
Method | udngettext |
Like ``ungettext()`` but look the message up in the specified domain. |
Method | udnpgettext |
Like ``unpgettext``, but look the message up in the specified `domain`. |
Method | udpgettext |
Like `upgettext()`, but look the message up in the specified `domain`. |
Method | unpgettext |
Do a plural-forms lookup of a message id. `singular` is used as the message id for purposes of lookup in the catalog, while `num` is used to determine which plural form to use. The returned message string is a Unicode string. |
Method | upgettext |
Look up the `context` and `message` id in the catalog and return the corresponding message string, as a Unicode string. If there is no entry in the catalog for the `message` id and `context`, and a fallback has been set, the look up is forwarded to the fallback's ``upgettext()`` method... |
Constant | CONTEXT |
Undocumented |
Instance Variable | files |
Undocumented |
Instance Variable | plural |
Undocumented |
Class Variable | _fallback |
Undocumented |
Class Variable | _info |
Undocumented |
Instance Variable | _catalog |
Undocumented |
Instance Variable | _domains |
Undocumented |
def load(cls, dirname:
(str|os.PathLike[ str])|None
= None, locales: ((list[ str]|tuple[ str, ...])|str)|None
= None, domain: str|None
= None) -> NullTranslations
:
(source)
¶
Load translations from the given directory. :param dirname: the directory containing the ``MO`` files :param locales: the list of locales in order of preference (items in this list can be either `Locale` objects or locale strings) :param domain: the message domain (default: 'messages')
gettext._TranslationsReader|None
= None, domain: str|None
= None):
(source)
¶
babel.support.NullTranslations.__init__
Initialize the translations catalog. :param fp: the file-like object the translation should be read from :param domain: the message domain (default: 'messages')
Add the given translations to the catalog. If the domain of the translations is different than that of the current catalog, they are added as a catalog that is only accessible by the various ``d*gettext`` functions. :param translations: the `Translations` instance with the messages to add :param merge: whether translations for message domains that have already been added should be merged with the existing translations
Merge the given translations into the catalog. Message translations in the specified catalog override any messages with the same identifier in the existing catalog. :param translations: the `Translations` instance with the messages to merge