Code

Added module docstrings to all modules.
[roundup.git] / roundup / i18n.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: i18n.py,v 1.2 2001-11-22 15:46:42 jhermann Exp $
20 __doc__ = """
21 RoundUp Internationalization (I18N)
23 To use this module, the following code should be used:
25     from roundup.i18n import _
26     ...
27     print _("Some text that can be translated")
29 Note that to enable re-ordering of inserted texts in formatting strings
30 (which can easily happen if a sentence has to be re-ordered due to
31 grammatical changes), translatable formats should use named format specs:
33     ... _('Index of %(classname)s') % {'classname': cn} ...
35 Also, this eases the job of translators since they have some context what
36 the dynamic portion of a message really means.
38 """
40 # first, we try to import gettext; this probably never fails, but we make
41 # sure we survive this anyway
42 try:
43     import gettext
44 except ImportError:
45     # fall-back to dummy on errors (returning the english text)
46     _ = lambda text: text
47 else:
48     # and for now, we JUST implement the dummy in any case
49     _ = lambda text: text