Mercurial > p > roundup > code
comparison roundup/i18n.py @ 399:96b0db9ad389
Added dummy hooks for I18N...
...and some preliminary (test) markup of translatable messages
| author | Jürgen Hermann <jhermann@users.sourceforge.net> |
|---|---|
| date | Wed, 21 Nov 2001 22:57:29 +0000 |
| parents | |
| children | bdc2ea127ae9 |
comparison
equal
deleted
inserted
replaced
| 398:bbbcdee47762 | 399:96b0db9ad389 |
|---|---|
| 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.1 2001-11-21 22:57:29 jhermann Exp $ | |
| 19 | |
| 20 """ | |
| 21 RoundUp Internationalization (I18N) | |
| 22 | |
| 23 To use this module, the following code should be used: | |
| 24 | |
| 25 from roundup.i18n import _ | |
| 26 ... | |
| 27 print _("Some text that can be translated") | |
| 28 | |
| 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: | |
| 32 | |
| 33 ... _('Index of %(classname)s') % {'classname': cn} ... | |
| 34 | |
| 35 Also, this eases the job of translators since they have some context what | |
| 36 the dynamic portion of a message really means. | |
| 37 | |
| 38 """ | |
| 39 | |
| 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 | |
| 50 |
