Package babel :: Module support :: Class Translations

# Class Translations

    gettext.NullTranslations --+
                               |
         gettext.GNUTranslations --+
                                   |
                                  Translations

An extended translation catalog class.

Instance Methods

__init__(self, fileobj=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`) Initialize the translations catalog. |

Translations

merge(self, translations) Merge the given translations into the catalog. |

__repr__(self) |

Inherited from `gettext.GNUTranslations`: `gettext`, `lgettext`, `lngettext`, `ngettext`, `ugettext`, `ungettext` Inherited from `gettext.NullTranslations`: `add_fallback`, `charset`, `info`, `install`, `output_charset`, `set_output_charset`

Class Methods

Translations

load(cls, dirname=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`, locales=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`, domain=`'``messages``'`) Load translations from the given directory. |

Class Variables
| DEFAULT_DOMAIN = ``'``messages``'``
Inherited from `gettext.GNUTranslations`: `BE_MAGIC`, `LE_MAGIC`

Method Details

### __init__(self, fileobj=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`)
(Constructor)

Initialize the translations catalog.

Parameters:
  - `fileobj` - the file-like object the translation should be read from
Overrides: gettext.NullTranslations.__init__

### load(cls, dirname=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`, locales=`{``'``territory_zones``'``:` `{``'``001``'``:` `[``'``Etc/GMT``'``,` `'``Etc/GMT-1``'``,` `'``Etc/GMT-``...`, domain=`'``messages``'`)
Class Method

Load translations from the given directory.

Parameters:
  - `dirname` - the directory containing the `MO` files
  - `locales` - the list of locales in order of preference (items in this list can be either Locale objects or locale strings)
  - `domain` - the message domain
Returns: Translations
  the loaded catalog, or a `NullTranslations` instance if no matching translations were found

### merge(self, translations)

Merge the given translations into the catalog.

Message translations in the specfied catalog override any messages with the same identifier in the existing catalog.

Parameters:
  - `translations` - the Translations instance with the messages to merge
Returns: Translations
  the Translations instance (`self`) so that merge calls can be easily chained