diff options
author | Georg Brandl <georg@python.org> | 2006-02-19 13:26:36 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-02-19 13:26:36 (GMT) |
commit | 602b9ba6b37c4ac4ed445f8c9e9dccd68d631899 (patch) | |
tree | 576f560d4ba24b2c975d35a7718ca1c5a2cfbf57 /Doc/lib | |
parent | e466217ab954c5a53fc2e0b78876385362120900 (diff) | |
download | cpython-602b9ba6b37c4ac4ed445f8c9e9dccd68d631899.zip cpython-602b9ba6b37c4ac4ed445f8c9e9dccd68d631899.tar.gz cpython-602b9ba6b37c4ac4ed445f8c9e9dccd68d631899.tar.bz2 |
Patch #1349274: gettext.install() now optionally installs additional
translation functions other than _() in the builtin namespace.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libgettext.tex | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Doc/lib/libgettext.tex b/Doc/lib/libgettext.tex index 593d964..e41f8bf 100644 --- a/Doc/lib/libgettext.tex +++ b/Doc/lib/libgettext.tex @@ -219,13 +219,16 @@ true. \end{funcdesc} \begin{funcdesc}{install}{domain\optional{, localedir\optional{, unicode - \optional{, codeset}}}} + \optional{, codeset\optional{, names}}}}} This installs the function \function{_} in Python's builtin namespace, based on \var{domain}, \var{localedir}, and \var{codeset} which are passed to the function \function{translation()}. The \var{unicode} flag is passed to the resulting translation object's \method{install} method. +For the \var{names} parameter, please see the description of the +translation object's \method{install} method. + As seen below, you usually mark the strings in your application that are candidates for translation, by wrapping them in a call to the \function{_()} function, like this: @@ -239,6 +242,7 @@ Python's builtin namespace, so it is easily accessible in all modules of your application. \versionchanged[Added the \var{codeset} parameter]{2.4} +\versionchanged[Added the \var{names} parameter]{2.5} \end{funcdesc} \subsubsection{The \class{NullTranslations} class} @@ -332,12 +336,21 @@ defines the encoding used to return translated messages. \versionadded{2.4} \end{methoddesc} -\begin{methoddesc}[NullTranslations]{install}{\optional{unicode}} +\begin{methoddesc}[NullTranslations]{install}{\optional{unicode + \optional{, names}}} If the \var{unicode} flag is false, this method installs \method{self.gettext()} into the built-in namespace, binding it to \samp{_}. If \var{unicode} is true, it binds \method{self.ugettext()} instead. By default, \var{unicode} is false. +If the \var{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 \function{_()}. Supported names are \code{'gettext'} (bound +to \method{self.gettext()} or \method{self.ugettext()} according to the +\var{unicode} flag), \code{'ngettext'} (bound to \method{self.ngettext()} +or \method{self.ungettext()} according to the \var{unicode} flag), +\code{'lgettext'} and \code{'lngettext'}. + Note that this is only one way, albeit the most convenient way, to make the \function{_} function available to your application. Because it affects the entire application globally, and specifically the built-in @@ -353,6 +366,8 @@ _ = t.gettext This puts \function{_} only in the module's global namespace and so only affects calls within this module. + +\versionchanged[Added the \var{names} parameter]{2.5} \end{methoddesc} \subsubsection{The \class{GNUTranslations} class} |