6.23.2.2 The GNUTranslations class
Python Library Reference
Previous: 6.23.2.1 The NullTranslations class
Up: 6.23.2 Class-based API
Next: 6.23.2.3 Solaris message catalog
6.23.2.2 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.
Python Library Reference
Previous: 6.23.2.1 The NullTranslations class
Up: 6.23.2 Class-based API
Next: 6.23.2.3 Solaris message catalog
See About this document... for information on suggesting changes.
Wyszukiwarka
Podobne podstrony:
node144node14node145node141node140node142 HMOAZYBI4SZXFYSHOPGFIAPWE2KM6XTYPAPQODYnode14node14node142node141 EKAPKT6JNUJTRA5TRV5S4M3EVIIA3NDIHGINLOAnode146node14 TOEAHAI3F3A7FKHLKZHFDMZIWT6B6M3IIHCAFFAnode146 CLWZNY3SU62WRPZ2EMJIMOOECQ5XDFP7SX744PYwięcej podobnych podstron