Info Node: (python2.1-lib.info)GNUTranslations class
(python2.1-lib.info)GNUTranslations class
The `GNUTranslations' class
...........................
The `gettext' module provides one additional class derived from
`NullTranslations': `GNUTranslations'. This class overrides `_parse()'
to enable reading GNU `gettext' format `.mo' files in both big-endian
and little-endian format.
It also parses optional meta-data out of the translation catalog. It
is convention with GNU `gettext' to include meta-data as the
translation for the empty string. This meta-data is in RFC 822 -style
`key: value' pairs. If the key `Content-Type' is found, then the
`charset' property is used to initialize the "protected" `_charset'
instance variable. The entire set of key/value pairs are placed into a
dictionary and set as the "protected" `_info' instance variable.
If the `.mo' file's magic number is invalid, or if other problems occur
while reading the file, instantiating a `GNUTranslations' class can
raise `IOError'.
The other usefully overridden method is `ugettext()', which returns a
Unicode string by passing both the translated message string and the
value of the "protected" `_charset' variable to the builtin `unicode()'
function.