Barry Warsaw | 9e03592 | 2000-08-25 19:14:25 +0000 | [diff] [blame] | 1 | import os |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 2 | import base64 |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 3 | import shutil |
Barry Warsaw | 9e03592 | 2000-08-25 19:14:25 +0000 | [diff] [blame] | 4 | import gettext |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 5 | import unittest |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 7 | from test import test_support |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 8 | |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 9 | |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 10 | # TODO: |
| 11 | # - Add new tests, for example for "dgettext" |
| 12 | # - Remove dummy tests, for example testing for single and double quotes |
| 13 | # has no sense, it would have if we were testing a parser (i.e. pygettext) |
| 14 | # - Tests should have only one assert. |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 15 | |
Guido van Rossum | 39478e8 | 2007-08-27 17:23:59 +0000 | [diff] [blame] | 16 | GNU_MO_DATA = b'''\ |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 17 | 3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj |
| 18 | AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD |
| 19 | AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh |
| 20 | eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU |
| 21 | aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u |
| 22 | CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh |
| 23 | Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51 |
| 24 | ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt |
| 25 | MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k |
| 26 | YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN |
| 27 | SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4 |
| 28 | NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0 |
| 29 | ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0 |
| 30 | d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo |
| 31 | eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn |
| 32 | IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1 |
| 33 | ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA== |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 34 | ''' |
| 35 | |
Guido van Rossum | 39478e8 | 2007-08-27 17:23:59 +0000 | [diff] [blame] | 36 | UMO_DATA = b'''\ |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 37 | 3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABAAAAFEAAAAPAQAAVgAAAAQAAABm |
| 38 | AQAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAYWLDngBQcm9qZWN0LUlkLVZlcnNpb246IDIuMApQTy1S |
| 39 | ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy |
| 40 | eSBBLiBXQXJzYXcgPGJhcnJ5QHB5dGhvbi5vcmc+Ckxhbmd1YWdlLVRlYW06IFhYIDxweXRob24t |
| 41 | ZGV2QHB5dGhvbi5vcmc+Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFp |
| 42 | bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl |
| 43 | ZC1CeTogbWFudWFsbHkKAMKkeXoA |
| 44 | ''' |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 45 | |
Guido van Rossum | 39478e8 | 2007-08-27 17:23:59 +0000 | [diff] [blame] | 46 | MMO_DATA = b'''\ |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 47 | 3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA |
| 48 | UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk |
| 49 | IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6 |
| 50 | NTgrMDA6MDAKTGFzdC1UcmFuc2xhdG9yOiBKb2huIERvZSA8amRvZUBleGFtcGxlLmNvbT4KSmFu |
| 51 | ZSBGb29iYXIgPGpmb29iYXJAZXhhbXBsZS5jb20+Ckxhbmd1YWdlLVRlYW06IHh4IDx4eEBleGFt |
| 52 | cGxlLmNvbT4KTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFy |
| 53 | c2V0PWlzby04ODU5LTE1CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFi |
| 54 | bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA= |
| 55 | ''' |
| 56 | |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 57 | LOCALEDIR = os.path.join('xx', 'LC_MESSAGES') |
| 58 | MOFILE = os.path.join(LOCALEDIR, 'gettext.mo') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 59 | UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo') |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 60 | MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo') |
Brett Cannon | 4aebbb0 | 2003-04-27 19:42:41 +0000 | [diff] [blame] | 61 | try: |
| 62 | LANG = os.environ['LANGUAGE'] |
| 63 | except: |
| 64 | LANG = 'en' |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 65 | |
| 66 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 67 | class GettextBaseTest(unittest.TestCase): |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 68 | def setUp(self): |
Neal Norwitz | a0e0cd3 | 2004-07-19 00:08:59 +0000 | [diff] [blame] | 69 | if not os.path.isdir(LOCALEDIR): |
| 70 | os.makedirs(LOCALEDIR) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 71 | fp = open(MOFILE, 'wb') |
| 72 | fp.write(base64.decodestring(GNU_MO_DATA)) |
| 73 | fp.close() |
| 74 | fp = open(UMOFILE, 'wb') |
| 75 | fp.write(base64.decodestring(UMO_DATA)) |
| 76 | fp.close() |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 77 | fp = open(MMOFILE, 'wb') |
| 78 | fp.write(base64.decodestring(MMO_DATA)) |
| 79 | fp.close() |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 80 | os.environ['LANGUAGE'] = 'xx' |
| 81 | |
| 82 | def tearDown(self): |
Brett Cannon | 4aebbb0 | 2003-04-27 19:42:41 +0000 | [diff] [blame] | 83 | os.environ['LANGUAGE'] = LANG |
| 84 | shutil.rmtree(os.path.split(LOCALEDIR)[0]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 85 | |
| 86 | |
| 87 | class GettextTestCase1(GettextBaseTest): |
| 88 | def setUp(self): |
| 89 | GettextBaseTest.setUp(self) |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 90 | self.localedir = os.curdir |
| 91 | self.mofile = MOFILE |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 92 | gettext.install('gettext', self.localedir) |
| 93 | |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 94 | def test_some_translations(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 95 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 96 | # test some translations |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 97 | eq(_('albatross'), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 98 | eq(_('mullusk'), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 99 | eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 100 | eq(_(r'nudge nudge'), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 101 | |
| 102 | def test_double_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 103 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 104 | # double quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 105 | eq(_("albatross"), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 106 | eq(_("mullusk"), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 107 | eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 108 | eq(_(r"nudge nudge"), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 109 | |
| 110 | def test_triple_single_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 111 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 112 | # triple single quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 113 | eq(_('''albatross'''), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 114 | eq(_('''mullusk'''), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 115 | eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 116 | eq(_(r'''nudge nudge'''), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 117 | |
| 118 | def test_triple_double_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 119 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 120 | # triple double quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 121 | eq(_("""albatross"""), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 122 | eq(_("""mullusk"""), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 123 | eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 124 | eq(_(r"""nudge nudge"""), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 125 | |
| 126 | def test_multiline_strings(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 127 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 128 | # multiline strings |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 129 | eq(_('''This module provides internationalization and localization |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 130 | support for your Python programs by providing an interface to the GNU |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 131 | gettext message catalog library.'''), |
| 132 | '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 133 | fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 134 | trggrkg zrffntr pngnybt yvoenel.''') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 135 | |
| 136 | def test_the_alternative_interface(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 137 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 138 | # test the alternative interface |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 139 | fp = open(self.mofile, 'rb') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 140 | t = gettext.GNUTranslations(fp) |
| 141 | fp.close() |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 142 | # Install the translation object |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 143 | t.install() |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 144 | eq(_('nudge nudge'), 'wink wink') |
| 145 | # Try unicode return type |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 146 | t.install(str=True) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 147 | eq(_('mullusk'), 'bacon') |
Georg Brandl | 602b9ba | 2006-02-19 13:26:36 +0000 | [diff] [blame] | 148 | # Test installation of other methods |
Georg Brandl | 1a3284e | 2007-12-02 09:40:06 +0000 | [diff] [blame] | 149 | import builtins |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 150 | t.install(str=True, names=["gettext", "lgettext"]) |
Georg Brandl | 602b9ba | 2006-02-19 13:26:36 +0000 | [diff] [blame] | 151 | eq(_, t.ugettext) |
Georg Brandl | 1a3284e | 2007-12-02 09:40:06 +0000 | [diff] [blame] | 152 | eq(builtins.gettext, t.ugettext) |
Georg Brandl | 602b9ba | 2006-02-19 13:26:36 +0000 | [diff] [blame] | 153 | eq(lgettext, t.lgettext) |
Georg Brandl | 1a3284e | 2007-12-02 09:40:06 +0000 | [diff] [blame] | 154 | del builtins.gettext |
| 155 | del builtins.lgettext |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 156 | |
| 157 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 158 | class GettextTestCase2(GettextBaseTest): |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 159 | def setUp(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 160 | GettextBaseTest.setUp(self) |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 161 | self.localedir = os.curdir |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 162 | # Set up the bindings |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 163 | gettext.bindtextdomain('gettext', self.localedir) |
| 164 | gettext.textdomain('gettext') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 165 | # For convenience |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 166 | self._ = gettext.gettext |
| 167 | |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 168 | def test_bindtextdomain(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 169 | self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir) |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 170 | |
| 171 | def test_textdomain(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 172 | self.assertEqual(gettext.textdomain(), 'gettext') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 173 | |
| 174 | def test_some_translations(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 175 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 176 | # test some translations |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 177 | eq(self._('albatross'), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 178 | eq(self._('mullusk'), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 179 | eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 180 | eq(self._(r'nudge nudge'), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 181 | |
| 182 | def test_double_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 183 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 184 | # double quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 185 | eq(self._("albatross"), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 186 | eq(self._("mullusk"), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 187 | eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 188 | eq(self._(r"nudge nudge"), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 189 | |
| 190 | def test_triple_single_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 191 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 192 | # triple single quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 193 | eq(self._('''albatross'''), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 194 | eq(self._('''mullusk'''), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 195 | eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 196 | eq(self._(r'''nudge nudge'''), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 197 | |
| 198 | def test_triple_double_quotes(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 199 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 200 | # triple double quotes |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 201 | eq(self._("""albatross"""), 'albatross') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 202 | eq(self._("""mullusk"""), 'bacon') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 203 | eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 204 | eq(self._(r"""nudge nudge"""), 'wink wink') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 205 | |
| 206 | def test_multiline_strings(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 207 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 208 | # multiline strings |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 209 | eq(self._('''This module provides internationalization and localization |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 210 | support for your Python programs by providing an interface to the GNU |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 211 | gettext message catalog library.'''), |
| 212 | '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 213 | fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 214 | trggrkg zrffntr pngnybt yvoenel.''') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 215 | |
| 216 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 217 | class PluralFormsTestCase(GettextBaseTest): |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 218 | def setUp(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 219 | GettextBaseTest.setUp(self) |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 220 | self.mofile = MOFILE |
| 221 | |
| 222 | def test_plural_forms1(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 223 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 224 | x = gettext.ngettext('There is %s file', 'There are %s files', 1) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 225 | eq(x, 'Hay %s fichero') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 226 | x = gettext.ngettext('There is %s file', 'There are %s files', 2) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 227 | eq(x, 'Hay %s ficheros') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 228 | |
| 229 | def test_plural_forms2(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 230 | eq = self.assertEqual |
| 231 | fp = open(self.mofile, 'rb') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 232 | t = gettext.GNUTranslations(fp) |
| 233 | fp.close() |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 234 | x = t.ngettext('There is %s file', 'There are %s files', 1) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 235 | eq(x, 'Hay %s fichero') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 236 | x = t.ngettext('There is %s file', 'There are %s files', 2) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 237 | eq(x, 'Hay %s ficheros') |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 238 | |
| 239 | def test_hu(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 240 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 241 | f = gettext.c2py('0') |
| 242 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 243 | eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 244 | |
| 245 | def test_de(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 246 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 247 | f = gettext.c2py('n != 1') |
| 248 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 249 | eq(s, "10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 250 | |
| 251 | def test_fr(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 252 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 253 | f = gettext.c2py('n>1') |
| 254 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 255 | eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 256 | |
| 257 | def test_gd(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 258 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 259 | f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2') |
| 260 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 261 | eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 262 | |
| 263 | def test_gd2(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 264 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 265 | # Tests the combination of parentheses and "?:" |
| 266 | f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)') |
| 267 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 268 | eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 269 | |
| 270 | def test_lt(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 271 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 272 | f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2') |
| 273 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 274 | eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 275 | |
| 276 | def test_ru(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 277 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 278 | f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') |
| 279 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 280 | eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 281 | |
| 282 | def test_pl(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 283 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 284 | f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') |
| 285 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 286 | eq(s, "20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 287 | |
| 288 | def test_sl(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 289 | eq = self.assertEqual |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 290 | f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3') |
| 291 | s = ''.join([ str(f(x)) for x in range(200) ]) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 292 | eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 293 | |
| 294 | def test_security(self): |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 295 | raises = self.assertRaises |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 296 | # Test for a dangerous expression |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 297 | raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)") |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 298 | |
| 299 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 300 | class UnicodeTranslationsTest(GettextBaseTest): |
| 301 | def setUp(self): |
| 302 | GettextBaseTest.setUp(self) |
| 303 | fp = open(UMOFILE, 'rb') |
| 304 | try: |
Barry Warsaw | edb155f | 2003-04-24 18:08:13 +0000 | [diff] [blame] | 305 | self.t = gettext.GNUTranslations(fp) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 306 | finally: |
| 307 | fp.close() |
| 308 | self._ = self.t.ugettext |
| 309 | |
| 310 | def test_unicode_msgid(self): |
| 311 | unless = self.failUnless |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 312 | unless(isinstance(self._(''), str)) |
| 313 | unless(isinstance(self._(''), str)) |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 314 | |
| 315 | def test_unicode_msgstr(self): |
| 316 | eq = self.assertEqual |
Guido van Rossum | ef87d6e | 2007-05-02 19:09:54 +0000 | [diff] [blame] | 317 | eq(self._('ab\xde'), '\xa4yz') |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 318 | |
| 319 | |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 320 | class WeirdMetadataTest(GettextBaseTest): |
| 321 | def setUp(self): |
| 322 | GettextBaseTest.setUp(self) |
| 323 | fp = open(MMOFILE, 'rb') |
| 324 | try: |
| 325 | try: |
| 326 | self.t = gettext.GNUTranslations(fp) |
| 327 | except: |
| 328 | self.tearDown() |
| 329 | raise |
| 330 | finally: |
| 331 | fp.close() |
| 332 | |
| 333 | def test_weird_metadata(self): |
| 334 | info = self.t.info() |
Christian Heimes | 6ae5d7f | 2007-10-31 18:53:44 +0000 | [diff] [blame] | 335 | self.assertEqual(len(info), 9) |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 336 | self.assertEqual(info['last-translator'], |
| 337 | 'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>') |
| 338 | |
| 339 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 340 | def test_main(): |
Guido van Rossum | d8faa36 | 2007-04-27 19:54:29 +0000 | [diff] [blame] | 341 | test_support.run_unittest(__name__) |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 342 | |
| 343 | if __name__ == '__main__': |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 344 | test_main() |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 345 | |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 346 | |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 347 | # For reference, here's the .po file used to created the GNU_MO_DATA above. |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 348 | # |
| 349 | # The original version was automatically generated from the sources with |
| 350 | # pygettext. Later it was manually modified to add plural forms support. |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 351 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 352 | ''' |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 353 | # Dummy translation for the Python test_gettext.py module. |
Barry Warsaw | 1914873 | 2001-08-24 19:11:57 +0000 | [diff] [blame] | 354 | # Copyright (C) 2001 Python Software Foundation |
| 355 | # Barry Warsaw <barry@python.org>, 2000. |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 356 | # |
| 357 | msgid "" |
| 358 | msgstr "" |
| 359 | "Project-Id-Version: 2.0\n" |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 360 | "PO-Revision-Date: 2003-04-11 14:32-0400\n" |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 361 | "Last-Translator: J. David Ibanez <j-david@noos.fr>\n" |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 362 | "Language-Team: XX <python-dev@python.org>\n" |
| 363 | "MIME-Version: 1.0\n" |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 364 | "Content-Type: text/plain; charset=iso-8859-1\n" |
| 365 | "Content-Transfer-Encoding: 8bit\n" |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 366 | "Generated-By: pygettext.py 1.1\n" |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 367 | "Plural-Forms: nplurals=2; plural=n!=1;\n" |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 368 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 369 | #: test_gettext.py:19 test_gettext.py:25 test_gettext.py:31 test_gettext.py:37 |
| 370 | #: test_gettext.py:51 test_gettext.py:80 test_gettext.py:86 test_gettext.py:92 |
| 371 | #: test_gettext.py:98 |
| 372 | msgid "nudge nudge" |
| 373 | msgstr "wink wink" |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 374 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 375 | #: test_gettext.py:16 test_gettext.py:22 test_gettext.py:28 test_gettext.py:34 |
| 376 | #: test_gettext.py:77 test_gettext.py:83 test_gettext.py:89 test_gettext.py:95 |
| 377 | msgid "albatross" |
| 378 | msgstr "" |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 379 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 380 | #: test_gettext.py:18 test_gettext.py:24 test_gettext.py:30 test_gettext.py:36 |
| 381 | #: test_gettext.py:79 test_gettext.py:85 test_gettext.py:91 test_gettext.py:97 |
| 382 | msgid "Raymond Luxury Yach-t" |
| 383 | msgstr "Throatwobbler Mangrove" |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 384 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 385 | #: test_gettext.py:17 test_gettext.py:23 test_gettext.py:29 test_gettext.py:35 |
| 386 | #: test_gettext.py:56 test_gettext.py:78 test_gettext.py:84 test_gettext.py:90 |
| 387 | #: test_gettext.py:96 |
| 388 | msgid "mullusk" |
| 389 | msgstr "bacon" |
Barry Warsaw | ff6d813 | 2000-08-25 19:50:38 +0000 | [diff] [blame] | 390 | |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 391 | #: test_gettext.py:40 test_gettext.py:101 |
| 392 | msgid "" |
| 393 | "This module provides internationalization and localization\n" |
| 394 | "support for your Python programs by providing an interface to the GNU\n" |
| 395 | "gettext message catalog library." |
| 396 | msgstr "" |
| 397 | "Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba\n" |
| 398 | "fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH\n" |
| 399 | "trggrkg zrffntr pngnybt yvoenel." |
Martin v. Löwis | d899605 | 2002-11-21 21:45:32 +0000 | [diff] [blame] | 400 | |
| 401 | # Manually added, as neither pygettext nor xgettext support plural forms |
| 402 | # in Python. |
| 403 | msgid "There is %s file" |
| 404 | msgid_plural "There are %s files" |
| 405 | msgstr[0] "Hay %s fichero" |
| 406 | msgstr[1] "Hay %s ficheros" |
Barry Warsaw | 64dab46 | 2000-08-30 03:32:07 +0000 | [diff] [blame] | 407 | ''' |
Barry Warsaw | a1ce93f | 2003-04-11 18:36:43 +0000 | [diff] [blame] | 408 | |
| 409 | # Here's the second example po file example, used to generate the UMO_DATA |
| 410 | # containing utf-8 encoded Unicode strings |
| 411 | |
| 412 | ''' |
| 413 | # Dummy translation for the Python test_gettext.py module. |
| 414 | # Copyright (C) 2001 Python Software Foundation |
| 415 | # Barry Warsaw <barry@python.org>, 2000. |
| 416 | # |
| 417 | msgid "" |
| 418 | msgstr "" |
| 419 | "Project-Id-Version: 2.0\n" |
| 420 | "PO-Revision-Date: 2003-04-11 12:42-0400\n" |
| 421 | "Last-Translator: Barry A. WArsaw <barry@python.org>\n" |
| 422 | "Language-Team: XX <python-dev@python.org>\n" |
| 423 | "MIME-Version: 1.0\n" |
| 424 | "Content-Type: text/plain; charset=utf-8\n" |
| 425 | "Content-Transfer-Encoding: 7bit\n" |
| 426 | "Generated-By: manually\n" |
| 427 | |
| 428 | #: nofile:0 |
| 429 | msgid "ab\xc3\x9e" |
| 430 | msgstr "\xc2\xa4yz" |
| 431 | ''' |
Barry Warsaw | e960e22 | 2003-05-20 17:28:54 +0000 | [diff] [blame] | 432 | |
| 433 | # Here's the third example po file, used to generate MMO_DATA |
| 434 | |
| 435 | ''' |
| 436 | msgid "" |
| 437 | msgstr "" |
| 438 | "Project-Id-Version: No Project 0.0\n" |
| 439 | "POT-Creation-Date: Wed Dec 11 07:44:15 2002\n" |
| 440 | "PO-Revision-Date: 2002-08-14 01:18:58+00:00\n" |
| 441 | "Last-Translator: John Doe <jdoe@example.com>\n" |
| 442 | "Jane Foobar <jfoobar@example.com>\n" |
| 443 | "Language-Team: xx <xx@example.com>\n" |
| 444 | "MIME-Version: 1.0\n" |
| 445 | "Content-Type: text/plain; charset=iso-8859-15\n" |
| 446 | "Content-Transfer-Encoding: quoted-printable\n" |
| 447 | "Generated-By: pygettext.py 1.3\n" |
| 448 | ''' |