diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
commit | e41251e864e94885d785b5a9bf8f824753316296 (patch) | |
tree | f530db7682d71f4920b22b8d7f84c89727647ab5 /Doc/library/gettext.rst | |
parent | 768db92b438038586c1580b711c528363a97d3f4 (diff) | |
download | cpython-e41251e864e94885d785b5a9bf8f824753316296.zip cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.gz cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.bz2 |
Merged revisions 62490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62490 | benjamin.peterson | 2008-04-24 20:29:10 -0500 (Thu, 24 Apr 2008) | 2 lines
reformat some documentation of classes so methods and attributes are under the class directive
........
Diffstat (limited to 'Doc/library/gettext.rst')
-rw-r--r-- | Doc/library/gettext.rst | 128 |
1 files changed, 65 insertions, 63 deletions
diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst index da8f4f1..fa1271a 100644 --- a/Doc/library/gettext.rst +++ b/Doc/library/gettext.rst @@ -218,7 +218,7 @@ interface you can use to write your own specialized translation classes. Here are the methods of :class:`NullTranslations`: -.. method:: NullTranslations.__init__([fp]) +.. class:: NullTranslations([fp]) Takes an optional file object *fp*, which is ignored by the base class. Initializes "protected" instance variables *_info* and *_charset* which are set @@ -227,105 +227,107 @@ are the methods of :class:`NullTranslations`: ``None``. -.. method:: NullTranslations._parse(fp) + .. method:: _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. + 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. -.. method:: NullTranslations.add_fallback(fallback) + .. method:: add_fallback(fallback) - Add *fallback* as the fallback object for the current translation object. A - translation object should consult the fallback if it cannot provide a - translation for a given message. + Add *fallback* as the fallback object for the current translation + object. A translation object should consult the fallback if it cannot provide a + translation for a given message. -.. method:: NullTranslations.gettext(message) + .. method:: gettext(message) - If a fallback has been set, forward :meth:`gettext` to the fallback. Otherwise, - return the translated message. Overridden in derived classes. + If a fallback has been set, forward :meth:`gettext` to the + fallback. Otherwise, return the translated message. Overridden in derived + classes. -.. method:: NullTranslations.lgettext(message) + .. method:: lgettext(message) - If a fallback has been set, forward :meth:`lgettext` to the fallback. Otherwise, - return the translated message. Overridden in derived classes. + If a fallback has been set, forward :meth:`lgettext` to the + fallback. Otherwise, return the translated message. Overridden in derived + classes. + .. method:: ugettext(message) -.. method:: NullTranslations.ugettext(message) + If a fallback has been set, forward :meth:`ugettext` to the + fallback. Otherwise, return the translated message as a string. Overridden + in derived classes. - If a fallback has been set, forward :meth:`ugettext` to the fallback. Otherwise, - return the translated message as a string. Overridden in derived classes. + .. method:: ngettext(singular, plural, n) -.. method:: NullTranslations.ngettext(singular, plural, n) + If a fallback has been set, forward :meth:`ngettext` to the + fallback. Otherwise, return the translated message. Overridden in derived + classes. - If a fallback has been set, forward :meth:`ngettext` to the fallback. Otherwise, - return the translated message. Overridden in derived classes. + .. method:: lngettext(singular, plural, n) + If a fallback has been set, forward :meth:`ngettext` to the + fallback. Otherwise, return the translated message. Overridden in derived + classes. -.. method:: NullTranslations.lngettext(singular, plural, n) + .. method:: ungettext(singular, plural, n) - If a fallback has been set, forward :meth:`ngettext` to the fallback. Otherwise, - return the translated message. Overridden in derived classes. + If a fallback has been set, forward :meth:`ungettext` to the fallback. + Otherwise, return the translated message as a string. Overridden in + derived classes. + .. method:: info() -.. method:: NullTranslations.ungettext(singular, plural, n) + Return the "protected" :attr:`_info` variable. - If a fallback has been set, forward :meth:`ungettext` to the fallback. - Otherwise, return the translated message as a string. Overridden in - derived classes. + .. method:: charset() -.. method:: NullTranslations.info() + Return the "protected" :attr:`_charset` variable. - Return the "protected" :attr:`_info` variable. + .. method:: output_charset() -.. method:: NullTranslations.charset() + Return the "protected" :attr:`_output_charset` variable, which defines the + encoding used to return translated messages. - Return the "protected" :attr:`_charset` variable. + .. method:: set_output_charset(charset) -.. method:: NullTranslations.output_charset() + Change the "protected" :attr:`_output_charset` variable, which defines the + encoding used to return translated messages. - Return the "protected" :attr:`_output_charset` variable, which defines the - encoding used to return translated messages. + .. method:: install([unicode [, names]]) -.. method:: NullTranslations.set_output_charset(charset) + If the *unicode* flag is false, this method installs :meth:`self.gettext` + into the built-in namespace, binding it to ``_``. If *unicode* is true, + it binds :meth:`self.ugettext` instead. By default, *unicode* is false. - Change the "protected" :attr:`_output_charset` variable, which defines the - encoding used to return translated messages. + If the *names* parameter is given, it must be a sequence containing the + names of functions you want to install in the builtin namespace in + addition to :func:`_`. Supported names are ``'gettext'`` (bound to + :meth:`self.gettext` or :meth:`self.ugettext` according to the *unicode* + flag), ``'ngettext'`` (bound to :meth:`self.ngettext` or + :meth:`self.ungettext` according to the *unicode* flag), ``'lgettext'`` + and ``'lngettext'``. + Note that this is only one way, albeit the most convenient way, to make + the :func:`_` function available to your application. Because it affects + the entire application globally, and specifically the built-in namespace, + localized modules should never install :func:`_`. Instead, they should use + this code to make :func:`_` available to their module:: -.. method:: NullTranslations.install([unicode [, names]]) + import gettext + t = gettext.translation('mymodule', ...) + _ = t.gettext - If the *unicode* flag is false, this method installs :meth:`self.gettext` into - the built-in namespace, binding it to ``_``. If *unicode* is true, it binds - :meth:`self.ugettext` instead. By default, *unicode* is false. - - If the *names* parameter is given, it must be a sequence containing the names of - functions you want to install in the builtin namespace in addition to :func:`_`. - Supported names are ``'gettext'`` (bound to :meth:`self.gettext` or - :meth:`self.ugettext` according to the *unicode* flag), ``'ngettext'`` (bound to - :meth:`self.ngettext` or :meth:`self.ungettext` according to the *unicode* - flag), ``'lgettext'`` and ``'lngettext'``. - - Note that this is only one way, albeit the most convenient way, to make the - :func:`_` function available to your application. Because it affects the entire - application globally, and specifically the built-in namespace, localized modules - should never install :func:`_`. Instead, they should use this code to make - :func:`_` available to their module:: - - import gettext - t = gettext.translation('mymodule', ...) - _ = t.gettext - - This puts :func:`_` only in the module's global namespace and so only affects - calls within this module. + This puts :func:`_` only in the module's global namespace and so only + affects calls within this module. The :class:`GNUTranslations` class |