Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)NullTranslations classThe `NullTranslations' class ............................ Translation classes are what actually implement the translation of original source file message strings to translated message strings. The base class used by all translation classes is `NullTranslations'; this provides the basic interface you can use to write your own specialized translation classes. Here are the methods of `NullTranslations': `__init__([fp])' Takes an optional file object FP, which is ignored by the base class. Initializes "protected" instance variables _INFO and _CHARSET which are set by derived classes. It then calls `self._parse(fp)' if FP is not `None'. `_parse(fp)' No-op'd in the base class, this method takes file object FP, and reads the data from the file, initializing its message catalog. If you have an unsupported message catalog file format, you should override this method to parse your format. `gettext(message)' Return the translated message. Overridden in derived classes. `ugettext(message)' Return the translated message as a Unicode string. Overridden in derived classes. `info()' Return the "protected" `_info' variable. `charset()' Return the "protected" `_charset' variable. `install([unicode])' If the UNICODE flag is false, this method installs `self.gettext()' into the built-in namespace, binding it to `_'. If UNICODE is true, it binds `self.ugettext()' instead. By default, UNICODE is false. Note that this is only one way, albeit the most convenient way, to make the `_' function available to your application. Because it affects the entire application globally, and specifically the built-in namespace, localized modules should never install `_'. Instead, they should use this code to make `_' available to their module: import gettext t = gettext.translation('mymodule', ...) _ = t.gettext This puts `_' only in the module's global namespace and so only affects calls within this module. automatically generated by info2www version 1.2.2.9 |