class documentation

class Translations(NullTranslations, gettext.GNUTranslations):

View In Hierarchy

An extended translation catalog class.
Class Method load Load translations from the given directory.
Method add Add the given translations to the catalog.
Method merge Merge the given translations into the catalog.
Constant DEFAULT​_DOMAIN Undocumented
Method __init__ Initialize the translations catalog.
Method __repr__ Undocumented
Instance Variable domain Undocumented

Inherited from NullTranslations:

Constant CONTEXT​_ENCODING Undocumented
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 No summary
Method pgettext No summary
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 No summary
Method upgettext No summary
Instance Variable ​_catalog Undocumented
Instance Variable ​_domains Undocumented
Instance Variable files Undocumented
Instance Variable plural Undocumented
@classmethod
def load(cls, dirname=None, locales=None, domain=None):
Load translations from the given directory.
Parameters
dirnamethe directory containing the MO files
localesthe list of locales in order of preference (items in this list can be either Locale objects or locale strings)
domainthe message domain (default: 'messages')
def add(self, translations, merge=True):

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.

Parameters
translationsthe Translations instance with the messages to add
mergewhether translations for message domains that have already been added should be merged with the existing translations
def merge(self, 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.

Parameters
translationsthe Translations instance with the messages to merge
DEFAULT_DOMAIN: str =

Undocumented

Value
'messages'
def __init__(self, fp=None, domain=None):
Initialize the translations catalog.
Parameters
fpthe file-like object the translation should be read from
domainthe message domain (default: 'messages')
def __repr__(self):

Undocumented

domain =

Undocumented