node147





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:
node144
node14
node145
node141
node140
node142 HMOAZYBI4SZXFYSHOPGFIAPWE2KM6XTYPAPQODY
node14
node14
node142
node141 EKAPKT6JNUJTRA5TRV5S4M3EVIIA3NDIHGINLOA
node146
node14 TOEAHAI3F3A7FKHLKZHFDMZIWT6B6M3IIHCAFFA
node146 CLWZNY3SU62WRPZ2EMJIMOOECQ5XDFP7SX744PY

więcej podobnych podstron