1 | n/a | import os |
---|
2 | n/a | import base64 |
---|
3 | n/a | import gettext |
---|
4 | n/a | import unittest |
---|
5 | n/a | |
---|
6 | n/a | from test import support |
---|
7 | n/a | |
---|
8 | n/a | |
---|
9 | n/a | # TODO: |
---|
10 | n/a | # - Add new tests, for example for "dgettext" |
---|
11 | n/a | # - Remove dummy tests, for example testing for single and double quotes |
---|
12 | n/a | # has no sense, it would have if we were testing a parser (i.e. pygettext) |
---|
13 | n/a | # - Tests should have only one assert. |
---|
14 | n/a | |
---|
15 | n/a | GNU_MO_DATA = b'''\ |
---|
16 | n/a | 3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj |
---|
17 | n/a | AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD |
---|
18 | n/a | AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh |
---|
19 | n/a | eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU |
---|
20 | n/a | aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u |
---|
21 | n/a | CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh |
---|
22 | n/a | Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51 |
---|
23 | n/a | ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt |
---|
24 | n/a | MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k |
---|
25 | n/a | YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN |
---|
26 | n/a | SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4 |
---|
27 | n/a | NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0 |
---|
28 | n/a | ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0 |
---|
29 | n/a | d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo |
---|
30 | n/a | eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn |
---|
31 | n/a | IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1 |
---|
32 | n/a | ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA== |
---|
33 | n/a | ''' |
---|
34 | n/a | |
---|
35 | n/a | # This data contains an invalid major version number (5) |
---|
36 | n/a | # An unexpected major version number should be treated as an error when |
---|
37 | n/a | # parsing a .mo file |
---|
38 | n/a | |
---|
39 | n/a | GNU_MO_DATA_BAD_MAJOR_VERSION = b'''\ |
---|
40 | n/a | 3hIElQAABQAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj |
---|
41 | n/a | AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD |
---|
42 | n/a | AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh |
---|
43 | n/a | eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU |
---|
44 | n/a | aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u |
---|
45 | n/a | CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh |
---|
46 | n/a | Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51 |
---|
47 | n/a | ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt |
---|
48 | n/a | MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k |
---|
49 | n/a | YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN |
---|
50 | n/a | SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4 |
---|
51 | n/a | NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0 |
---|
52 | n/a | ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0 |
---|
53 | n/a | d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo |
---|
54 | n/a | eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn |
---|
55 | n/a | IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1 |
---|
56 | n/a | ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA== |
---|
57 | n/a | ''' |
---|
58 | n/a | |
---|
59 | n/a | # This data contains an invalid minor version number (7) |
---|
60 | n/a | # An unexpected minor version number only indicates that some of the file's |
---|
61 | n/a | # contents may not be able to be read. It does not indicate an error. |
---|
62 | n/a | |
---|
63 | n/a | GNU_MO_DATA_BAD_MINOR_VERSION = b'''\ |
---|
64 | n/a | 3hIElQcAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj |
---|
65 | n/a | AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD |
---|
66 | n/a | AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh |
---|
67 | n/a | eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU |
---|
68 | n/a | aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u |
---|
69 | n/a | CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh |
---|
70 | n/a | Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51 |
---|
71 | n/a | ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt |
---|
72 | n/a | MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k |
---|
73 | n/a | YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN |
---|
74 | n/a | SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4 |
---|
75 | n/a | NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0 |
---|
76 | n/a | ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0 |
---|
77 | n/a | d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo |
---|
78 | n/a | eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn |
---|
79 | n/a | IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1 |
---|
80 | n/a | ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA== |
---|
81 | n/a | ''' |
---|
82 | n/a | |
---|
83 | n/a | |
---|
84 | n/a | UMO_DATA = b'''\ |
---|
85 | n/a | 3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABAAAAFEAAAAPAQAAVgAAAAQAAABm |
---|
86 | n/a | AQAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAYWLDngBQcm9qZWN0LUlkLVZlcnNpb246IDIuMApQTy1S |
---|
87 | n/a | ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy |
---|
88 | n/a | eSBBLiBXQXJzYXcgPGJhcnJ5QHB5dGhvbi5vcmc+Ckxhbmd1YWdlLVRlYW06IFhYIDxweXRob24t |
---|
89 | n/a | ZGV2QHB5dGhvbi5vcmc+Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFp |
---|
90 | n/a | bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl |
---|
91 | n/a | ZC1CeTogbWFudWFsbHkKAMKkeXoA |
---|
92 | n/a | ''' |
---|
93 | n/a | |
---|
94 | n/a | MMO_DATA = b'''\ |
---|
95 | n/a | 3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA |
---|
96 | n/a | UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk |
---|
97 | n/a | IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6 |
---|
98 | n/a | NTgrMDA6MDAKTGFzdC1UcmFuc2xhdG9yOiBKb2huIERvZSA8amRvZUBleGFtcGxlLmNvbT4KSmFu |
---|
99 | n/a | ZSBGb29iYXIgPGpmb29iYXJAZXhhbXBsZS5jb20+Ckxhbmd1YWdlLVRlYW06IHh4IDx4eEBleGFt |
---|
100 | n/a | cGxlLmNvbT4KTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFy |
---|
101 | n/a | c2V0PWlzby04ODU5LTE1CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFi |
---|
102 | n/a | bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA= |
---|
103 | n/a | ''' |
---|
104 | n/a | |
---|
105 | n/a | LOCALEDIR = os.path.join('xx', 'LC_MESSAGES') |
---|
106 | n/a | MOFILE = os.path.join(LOCALEDIR, 'gettext.mo') |
---|
107 | n/a | MOFILE_BAD_MAJOR_VERSION = os.path.join(LOCALEDIR, 'gettext_bad_major_version.mo') |
---|
108 | n/a | MOFILE_BAD_MINOR_VERSION = os.path.join(LOCALEDIR, 'gettext_bad_minor_version.mo') |
---|
109 | n/a | UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo') |
---|
110 | n/a | MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo') |
---|
111 | n/a | |
---|
112 | n/a | |
---|
113 | n/a | class GettextBaseTest(unittest.TestCase): |
---|
114 | n/a | def setUp(self): |
---|
115 | n/a | if not os.path.isdir(LOCALEDIR): |
---|
116 | n/a | os.makedirs(LOCALEDIR) |
---|
117 | n/a | with open(MOFILE, 'wb') as fp: |
---|
118 | n/a | fp.write(base64.decodebytes(GNU_MO_DATA)) |
---|
119 | n/a | with open(MOFILE_BAD_MAJOR_VERSION, 'wb') as fp: |
---|
120 | n/a | fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MAJOR_VERSION)) |
---|
121 | n/a | with open(MOFILE_BAD_MINOR_VERSION, 'wb') as fp: |
---|
122 | n/a | fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MINOR_VERSION)) |
---|
123 | n/a | with open(UMOFILE, 'wb') as fp: |
---|
124 | n/a | fp.write(base64.decodebytes(UMO_DATA)) |
---|
125 | n/a | with open(MMOFILE, 'wb') as fp: |
---|
126 | n/a | fp.write(base64.decodebytes(MMO_DATA)) |
---|
127 | n/a | self.env = support.EnvironmentVarGuard() |
---|
128 | n/a | self.env['LANGUAGE'] = 'xx' |
---|
129 | n/a | gettext._translations.clear() |
---|
130 | n/a | |
---|
131 | n/a | def tearDown(self): |
---|
132 | n/a | self.env.__exit__() |
---|
133 | n/a | del self.env |
---|
134 | n/a | support.rmtree(os.path.split(LOCALEDIR)[0]) |
---|
135 | n/a | |
---|
136 | n/a | GNU_MO_DATA_ISSUE_17898 = b'''\ |
---|
137 | n/a | 3hIElQAAAAABAAAAHAAAACQAAAAAAAAAAAAAAAAAAAAsAAAAggAAAC0AAAAAUGx1cmFsLUZvcm1z |
---|
138 | n/a | OiBucGx1cmFscz0yOyBwbHVyYWw9KG4gIT0gMSk7CiMtIy0jLSMtIyAgbWVzc2FnZXMucG8gKEVk |
---|
139 | n/a | WCBTdHVkaW8pICAjLSMtIy0jLSMKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVU |
---|
140 | n/a | Ri04CgA= |
---|
141 | n/a | ''' |
---|
142 | n/a | |
---|
143 | n/a | class GettextTestCase1(GettextBaseTest): |
---|
144 | n/a | def setUp(self): |
---|
145 | n/a | GettextBaseTest.setUp(self) |
---|
146 | n/a | self.localedir = os.curdir |
---|
147 | n/a | self.mofile = MOFILE |
---|
148 | n/a | gettext.install('gettext', self.localedir) |
---|
149 | n/a | |
---|
150 | n/a | def test_some_translations(self): |
---|
151 | n/a | eq = self.assertEqual |
---|
152 | n/a | # test some translations |
---|
153 | n/a | eq(_('albatross'), 'albatross') |
---|
154 | n/a | eq(_('mullusk'), 'bacon') |
---|
155 | n/a | eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') |
---|
156 | n/a | eq(_(r'nudge nudge'), 'wink wink') |
---|
157 | n/a | |
---|
158 | n/a | def test_double_quotes(self): |
---|
159 | n/a | eq = self.assertEqual |
---|
160 | n/a | # double quotes |
---|
161 | n/a | eq(_("albatross"), 'albatross') |
---|
162 | n/a | eq(_("mullusk"), 'bacon') |
---|
163 | n/a | eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') |
---|
164 | n/a | eq(_(r"nudge nudge"), 'wink wink') |
---|
165 | n/a | |
---|
166 | n/a | def test_triple_single_quotes(self): |
---|
167 | n/a | eq = self.assertEqual |
---|
168 | n/a | # triple single quotes |
---|
169 | n/a | eq(_('''albatross'''), 'albatross') |
---|
170 | n/a | eq(_('''mullusk'''), 'bacon') |
---|
171 | n/a | eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') |
---|
172 | n/a | eq(_(r'''nudge nudge'''), 'wink wink') |
---|
173 | n/a | |
---|
174 | n/a | def test_triple_double_quotes(self): |
---|
175 | n/a | eq = self.assertEqual |
---|
176 | n/a | # triple double quotes |
---|
177 | n/a | eq(_("""albatross"""), 'albatross') |
---|
178 | n/a | eq(_("""mullusk"""), 'bacon') |
---|
179 | n/a | eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') |
---|
180 | n/a | eq(_(r"""nudge nudge"""), 'wink wink') |
---|
181 | n/a | |
---|
182 | n/a | def test_multiline_strings(self): |
---|
183 | n/a | eq = self.assertEqual |
---|
184 | n/a | # multiline strings |
---|
185 | n/a | eq(_('''This module provides internationalization and localization |
---|
186 | n/a | support for your Python programs by providing an interface to the GNU |
---|
187 | n/a | gettext message catalog library.'''), |
---|
188 | n/a | '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba |
---|
189 | n/a | fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH |
---|
190 | n/a | trggrkg zrffntr pngnybt yvoenel.''') |
---|
191 | n/a | |
---|
192 | n/a | def test_the_alternative_interface(self): |
---|
193 | n/a | eq = self.assertEqual |
---|
194 | n/a | # test the alternative interface |
---|
195 | n/a | with open(self.mofile, 'rb') as fp: |
---|
196 | n/a | t = gettext.GNUTranslations(fp) |
---|
197 | n/a | # Install the translation object |
---|
198 | n/a | t.install() |
---|
199 | n/a | eq(_('nudge nudge'), 'wink wink') |
---|
200 | n/a | # Try unicode return type |
---|
201 | n/a | t.install() |
---|
202 | n/a | eq(_('mullusk'), 'bacon') |
---|
203 | n/a | # Test installation of other methods |
---|
204 | n/a | import builtins |
---|
205 | n/a | t.install(names=["gettext", "lgettext"]) |
---|
206 | n/a | eq(_, t.gettext) |
---|
207 | n/a | eq(builtins.gettext, t.gettext) |
---|
208 | n/a | eq(lgettext, t.lgettext) |
---|
209 | n/a | del builtins.gettext |
---|
210 | n/a | del builtins.lgettext |
---|
211 | n/a | |
---|
212 | n/a | |
---|
213 | n/a | class GettextTestCase2(GettextBaseTest): |
---|
214 | n/a | def setUp(self): |
---|
215 | n/a | GettextBaseTest.setUp(self) |
---|
216 | n/a | self.localedir = os.curdir |
---|
217 | n/a | # Set up the bindings |
---|
218 | n/a | gettext.bindtextdomain('gettext', self.localedir) |
---|
219 | n/a | gettext.textdomain('gettext') |
---|
220 | n/a | # For convenience |
---|
221 | n/a | self._ = gettext.gettext |
---|
222 | n/a | |
---|
223 | n/a | def test_bindtextdomain(self): |
---|
224 | n/a | self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir) |
---|
225 | n/a | |
---|
226 | n/a | def test_textdomain(self): |
---|
227 | n/a | self.assertEqual(gettext.textdomain(), 'gettext') |
---|
228 | n/a | |
---|
229 | n/a | def test_bad_major_version(self): |
---|
230 | n/a | with open(MOFILE_BAD_MAJOR_VERSION, 'rb') as fp: |
---|
231 | n/a | with self.assertRaises(OSError) as cm: |
---|
232 | n/a | gettext.GNUTranslations(fp) |
---|
233 | n/a | |
---|
234 | n/a | exception = cm.exception |
---|
235 | n/a | self.assertEqual(exception.errno, 0) |
---|
236 | n/a | self.assertEqual(exception.strerror, "Bad version number 5") |
---|
237 | n/a | self.assertEqual(exception.filename, MOFILE_BAD_MAJOR_VERSION) |
---|
238 | n/a | |
---|
239 | n/a | def test_bad_minor_version(self): |
---|
240 | n/a | with open(MOFILE_BAD_MINOR_VERSION, 'rb') as fp: |
---|
241 | n/a | # Check that no error is thrown with a bad minor version number |
---|
242 | n/a | gettext.GNUTranslations(fp) |
---|
243 | n/a | |
---|
244 | n/a | def test_some_translations(self): |
---|
245 | n/a | eq = self.assertEqual |
---|
246 | n/a | # test some translations |
---|
247 | n/a | eq(self._('albatross'), 'albatross') |
---|
248 | n/a | eq(self._('mullusk'), 'bacon') |
---|
249 | n/a | eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove') |
---|
250 | n/a | eq(self._(r'nudge nudge'), 'wink wink') |
---|
251 | n/a | |
---|
252 | n/a | def test_double_quotes(self): |
---|
253 | n/a | eq = self.assertEqual |
---|
254 | n/a | # double quotes |
---|
255 | n/a | eq(self._("albatross"), 'albatross') |
---|
256 | n/a | eq(self._("mullusk"), 'bacon') |
---|
257 | n/a | eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove') |
---|
258 | n/a | eq(self._(r"nudge nudge"), 'wink wink') |
---|
259 | n/a | |
---|
260 | n/a | def test_triple_single_quotes(self): |
---|
261 | n/a | eq = self.assertEqual |
---|
262 | n/a | # triple single quotes |
---|
263 | n/a | eq(self._('''albatross'''), 'albatross') |
---|
264 | n/a | eq(self._('''mullusk'''), 'bacon') |
---|
265 | n/a | eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove') |
---|
266 | n/a | eq(self._(r'''nudge nudge'''), 'wink wink') |
---|
267 | n/a | |
---|
268 | n/a | def test_triple_double_quotes(self): |
---|
269 | n/a | eq = self.assertEqual |
---|
270 | n/a | # triple double quotes |
---|
271 | n/a | eq(self._("""albatross"""), 'albatross') |
---|
272 | n/a | eq(self._("""mullusk"""), 'bacon') |
---|
273 | n/a | eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove') |
---|
274 | n/a | eq(self._(r"""nudge nudge"""), 'wink wink') |
---|
275 | n/a | |
---|
276 | n/a | def test_multiline_strings(self): |
---|
277 | n/a | eq = self.assertEqual |
---|
278 | n/a | # multiline strings |
---|
279 | n/a | eq(self._('''This module provides internationalization and localization |
---|
280 | n/a | support for your Python programs by providing an interface to the GNU |
---|
281 | n/a | gettext message catalog library.'''), |
---|
282 | n/a | '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba |
---|
283 | n/a | fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH |
---|
284 | n/a | trggrkg zrffntr pngnybt yvoenel.''') |
---|
285 | n/a | |
---|
286 | n/a | |
---|
287 | n/a | class PluralFormsTestCase(GettextBaseTest): |
---|
288 | n/a | def setUp(self): |
---|
289 | n/a | GettextBaseTest.setUp(self) |
---|
290 | n/a | self.mofile = MOFILE |
---|
291 | n/a | |
---|
292 | n/a | def test_plural_forms1(self): |
---|
293 | n/a | eq = self.assertEqual |
---|
294 | n/a | x = gettext.ngettext('There is %s file', 'There are %s files', 1) |
---|
295 | n/a | eq(x, 'Hay %s fichero') |
---|
296 | n/a | x = gettext.ngettext('There is %s file', 'There are %s files', 2) |
---|
297 | n/a | eq(x, 'Hay %s ficheros') |
---|
298 | n/a | |
---|
299 | n/a | def test_plural_forms2(self): |
---|
300 | n/a | eq = self.assertEqual |
---|
301 | n/a | with open(self.mofile, 'rb') as fp: |
---|
302 | n/a | t = gettext.GNUTranslations(fp) |
---|
303 | n/a | x = t.ngettext('There is %s file', 'There are %s files', 1) |
---|
304 | n/a | eq(x, 'Hay %s fichero') |
---|
305 | n/a | x = t.ngettext('There is %s file', 'There are %s files', 2) |
---|
306 | n/a | eq(x, 'Hay %s ficheros') |
---|
307 | n/a | |
---|
308 | n/a | # Examples from http://www.gnu.org/software/gettext/manual/gettext.html |
---|
309 | n/a | |
---|
310 | n/a | def test_ja(self): |
---|
311 | n/a | eq = self.assertEqual |
---|
312 | n/a | f = gettext.c2py('0') |
---|
313 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
314 | n/a | eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") |
---|
315 | n/a | |
---|
316 | n/a | def test_de(self): |
---|
317 | n/a | eq = self.assertEqual |
---|
318 | n/a | f = gettext.c2py('n != 1') |
---|
319 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
320 | n/a | eq(s, "10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") |
---|
321 | n/a | |
---|
322 | n/a | def test_fr(self): |
---|
323 | n/a | eq = self.assertEqual |
---|
324 | n/a | f = gettext.c2py('n>1') |
---|
325 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
326 | n/a | eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") |
---|
327 | n/a | |
---|
328 | n/a | def test_lv(self): |
---|
329 | n/a | eq = self.assertEqual |
---|
330 | n/a | f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2') |
---|
331 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
332 | n/a | eq(s, "20111111111111111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111111111111110111111111011111111101111111110111111111011111111101111111110111111111011111111") |
---|
333 | n/a | |
---|
334 | n/a | def test_gd(self): |
---|
335 | n/a | eq = self.assertEqual |
---|
336 | n/a | f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2') |
---|
337 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
338 | n/a | eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") |
---|
339 | n/a | |
---|
340 | n/a | def test_gd2(self): |
---|
341 | n/a | eq = self.assertEqual |
---|
342 | n/a | # Tests the combination of parentheses and "?:" |
---|
343 | n/a | f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)') |
---|
344 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
345 | n/a | eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") |
---|
346 | n/a | |
---|
347 | n/a | def test_ro(self): |
---|
348 | n/a | eq = self.assertEqual |
---|
349 | n/a | f = gettext.c2py('n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2') |
---|
350 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
351 | n/a | eq(s, "10111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222") |
---|
352 | n/a | |
---|
353 | n/a | def test_lt(self): |
---|
354 | n/a | eq = self.assertEqual |
---|
355 | n/a | f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2') |
---|
356 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
357 | n/a | eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111") |
---|
358 | n/a | |
---|
359 | n/a | def test_ru(self): |
---|
360 | n/a | eq = self.assertEqual |
---|
361 | n/a | f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') |
---|
362 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
363 | n/a | eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222") |
---|
364 | n/a | |
---|
365 | n/a | def test_cs(self): |
---|
366 | n/a | eq = self.assertEqual |
---|
367 | n/a | f = gettext.c2py('(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2') |
---|
368 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
369 | n/a | eq(s, "20111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222") |
---|
370 | n/a | |
---|
371 | n/a | def test_pl(self): |
---|
372 | n/a | eq = self.assertEqual |
---|
373 | n/a | f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2') |
---|
374 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
375 | n/a | eq(s, "20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222") |
---|
376 | n/a | |
---|
377 | n/a | def test_sl(self): |
---|
378 | n/a | eq = self.assertEqual |
---|
379 | n/a | f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3') |
---|
380 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
381 | n/a | eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333") |
---|
382 | n/a | |
---|
383 | n/a | def test_ar(self): |
---|
384 | n/a | eq = self.assertEqual |
---|
385 | n/a | f = gettext.c2py('n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5') |
---|
386 | n/a | s = ''.join([ str(f(x)) for x in range(200) ]) |
---|
387 | n/a | eq(s, "01233333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444445553333333344444444444444444444444444444444444444444444444444444444444444444444444444444444444444444") |
---|
388 | n/a | |
---|
389 | n/a | def test_security(self): |
---|
390 | n/a | raises = self.assertRaises |
---|
391 | n/a | # Test for a dangerous expression |
---|
392 | n/a | raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)") |
---|
393 | n/a | # issue28563 |
---|
394 | n/a | raises(ValueError, gettext.c2py, '"(eval(foo) && ""') |
---|
395 | n/a | raises(ValueError, gettext.c2py, 'f"{os.system(\'sh\')}"') |
---|
396 | n/a | # Maximum recursion depth exceeded during compilation |
---|
397 | n/a | raises(ValueError, gettext.c2py, 'n+'*10000 + 'n') |
---|
398 | n/a | self.assertEqual(gettext.c2py('n+'*100 + 'n')(1), 101) |
---|
399 | n/a | # MemoryError during compilation |
---|
400 | n/a | raises(ValueError, gettext.c2py, '('*100 + 'n' + ')'*100) |
---|
401 | n/a | # Maximum recursion depth exceeded in C to Python translator |
---|
402 | n/a | raises(ValueError, gettext.c2py, '('*10000 + 'n' + ')'*10000) |
---|
403 | n/a | self.assertEqual(gettext.c2py('('*20 + 'n' + ')'*20)(1), 1) |
---|
404 | n/a | |
---|
405 | n/a | def test_chained_comparison(self): |
---|
406 | n/a | # C doesn't chain comparison as Python so 2 == 2 == 2 gets different results |
---|
407 | n/a | f = gettext.c2py('n == n == n') |
---|
408 | n/a | self.assertEqual(''.join(str(f(x)) for x in range(3)), '010') |
---|
409 | n/a | f = gettext.c2py('1 < n == n') |
---|
410 | n/a | self.assertEqual(''.join(str(f(x)) for x in range(3)), '100') |
---|
411 | n/a | f = gettext.c2py('n == n < 2') |
---|
412 | n/a | self.assertEqual(''.join(str(f(x)) for x in range(3)), '010') |
---|
413 | n/a | f = gettext.c2py('0 < n < 2') |
---|
414 | n/a | self.assertEqual(''.join(str(f(x)) for x in range(3)), '111') |
---|
415 | n/a | |
---|
416 | n/a | def test_decimal_number(self): |
---|
417 | n/a | self.assertEqual(gettext.c2py('0123')(1), 123) |
---|
418 | n/a | |
---|
419 | n/a | def test_invalid_syntax(self): |
---|
420 | n/a | invalid_expressions = [ |
---|
421 | n/a | 'x>1', '(n>1', 'n>1)', '42**42**42', '0xa', '1.0', '1e2', |
---|
422 | n/a | 'n>0x1', '+n', '-n', 'n()', 'n(1)', '1+', 'nn', 'n n', |
---|
423 | n/a | ] |
---|
424 | n/a | for expr in invalid_expressions: |
---|
425 | n/a | with self.assertRaises(ValueError): |
---|
426 | n/a | gettext.c2py(expr) |
---|
427 | n/a | |
---|
428 | n/a | def test_nested_condition_operator(self): |
---|
429 | n/a | self.assertEqual(gettext.c2py('n?1?2:3:4')(0), 4) |
---|
430 | n/a | self.assertEqual(gettext.c2py('n?1?2:3:4')(1), 2) |
---|
431 | n/a | self.assertEqual(gettext.c2py('n?1:3?4:5')(0), 4) |
---|
432 | n/a | self.assertEqual(gettext.c2py('n?1:3?4:5')(1), 1) |
---|
433 | n/a | |
---|
434 | n/a | def test_division(self): |
---|
435 | n/a | f = gettext.c2py('2/n*3') |
---|
436 | n/a | self.assertEqual(f(1), 6) |
---|
437 | n/a | self.assertEqual(f(2), 3) |
---|
438 | n/a | self.assertEqual(f(3), 0) |
---|
439 | n/a | self.assertEqual(f(-1), -6) |
---|
440 | n/a | self.assertRaises(ZeroDivisionError, f, 0) |
---|
441 | n/a | |
---|
442 | n/a | def test_plural_number(self): |
---|
443 | n/a | f = gettext.c2py('n != 1') |
---|
444 | n/a | self.assertEqual(f(1), 0) |
---|
445 | n/a | self.assertEqual(f(2), 1) |
---|
446 | n/a | self.assertEqual(f(1.0), 0) |
---|
447 | n/a | self.assertEqual(f(2.0), 1) |
---|
448 | n/a | self.assertEqual(f(1.1), 1) |
---|
449 | n/a | self.assertRaises(TypeError, f, '2') |
---|
450 | n/a | self.assertRaises(TypeError, f, b'2') |
---|
451 | n/a | self.assertRaises(TypeError, f, []) |
---|
452 | n/a | self.assertRaises(TypeError, f, object()) |
---|
453 | n/a | |
---|
454 | n/a | |
---|
455 | n/a | class GNUTranslationParsingTest(GettextBaseTest): |
---|
456 | n/a | def test_plural_form_error_issue17898(self): |
---|
457 | n/a | with open(MOFILE, 'wb') as fp: |
---|
458 | n/a | fp.write(base64.decodebytes(GNU_MO_DATA_ISSUE_17898)) |
---|
459 | n/a | with open(MOFILE, 'rb') as fp: |
---|
460 | n/a | # If this runs cleanly, the bug is fixed. |
---|
461 | n/a | t = gettext.GNUTranslations(fp) |
---|
462 | n/a | |
---|
463 | n/a | |
---|
464 | n/a | class UnicodeTranslationsTest(GettextBaseTest): |
---|
465 | n/a | def setUp(self): |
---|
466 | n/a | GettextBaseTest.setUp(self) |
---|
467 | n/a | with open(UMOFILE, 'rb') as fp: |
---|
468 | n/a | self.t = gettext.GNUTranslations(fp) |
---|
469 | n/a | self._ = self.t.gettext |
---|
470 | n/a | |
---|
471 | n/a | def test_unicode_msgid(self): |
---|
472 | n/a | unless = self.assertTrue |
---|
473 | n/a | unless(isinstance(self._(''), str)) |
---|
474 | n/a | unless(isinstance(self._(''), str)) |
---|
475 | n/a | |
---|
476 | n/a | def test_unicode_msgstr(self): |
---|
477 | n/a | eq = self.assertEqual |
---|
478 | n/a | eq(self._('ab\xde'), '\xa4yz') |
---|
479 | n/a | |
---|
480 | n/a | |
---|
481 | n/a | class WeirdMetadataTest(GettextBaseTest): |
---|
482 | n/a | def setUp(self): |
---|
483 | n/a | GettextBaseTest.setUp(self) |
---|
484 | n/a | with open(MMOFILE, 'rb') as fp: |
---|
485 | n/a | try: |
---|
486 | n/a | self.t = gettext.GNUTranslations(fp) |
---|
487 | n/a | except: |
---|
488 | n/a | self.tearDown() |
---|
489 | n/a | raise |
---|
490 | n/a | |
---|
491 | n/a | def test_weird_metadata(self): |
---|
492 | n/a | info = self.t.info() |
---|
493 | n/a | self.assertEqual(len(info), 9) |
---|
494 | n/a | self.assertEqual(info['last-translator'], |
---|
495 | n/a | 'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>') |
---|
496 | n/a | |
---|
497 | n/a | |
---|
498 | n/a | class DummyGNUTranslations(gettext.GNUTranslations): |
---|
499 | n/a | def foo(self): |
---|
500 | n/a | return 'foo' |
---|
501 | n/a | |
---|
502 | n/a | |
---|
503 | n/a | class GettextCacheTestCase(GettextBaseTest): |
---|
504 | n/a | def test_cache(self): |
---|
505 | n/a | self.localedir = os.curdir |
---|
506 | n/a | self.mofile = MOFILE |
---|
507 | n/a | |
---|
508 | n/a | self.assertEqual(len(gettext._translations), 0) |
---|
509 | n/a | |
---|
510 | n/a | t = gettext.translation('gettext', self.localedir) |
---|
511 | n/a | |
---|
512 | n/a | self.assertEqual(len(gettext._translations), 1) |
---|
513 | n/a | |
---|
514 | n/a | t = gettext.translation('gettext', self.localedir, |
---|
515 | n/a | class_=DummyGNUTranslations) |
---|
516 | n/a | |
---|
517 | n/a | self.assertEqual(len(gettext._translations), 2) |
---|
518 | n/a | self.assertEqual(t.__class__, DummyGNUTranslations) |
---|
519 | n/a | |
---|
520 | n/a | # Calling it again doesn't add to the cache |
---|
521 | n/a | |
---|
522 | n/a | t = gettext.translation('gettext', self.localedir, |
---|
523 | n/a | class_=DummyGNUTranslations) |
---|
524 | n/a | |
---|
525 | n/a | self.assertEqual(len(gettext._translations), 2) |
---|
526 | n/a | self.assertEqual(t.__class__, DummyGNUTranslations) |
---|
527 | n/a | |
---|
528 | n/a | |
---|
529 | n/a | class MiscTestCase(unittest.TestCase): |
---|
530 | n/a | def test__all__(self): |
---|
531 | n/a | blacklist = {'c2py', 'ENOENT'} |
---|
532 | n/a | support.check__all__(self, gettext, blacklist=blacklist) |
---|
533 | n/a | |
---|
534 | n/a | |
---|
535 | n/a | def test_main(): |
---|
536 | n/a | support.run_unittest(__name__) |
---|
537 | n/a | |
---|
538 | n/a | if __name__ == '__main__': |
---|
539 | n/a | test_main() |
---|
540 | n/a | |
---|
541 | n/a | |
---|
542 | n/a | # For reference, here's the .po file used to created the GNU_MO_DATA above. |
---|
543 | n/a | # |
---|
544 | n/a | # The original version was automatically generated from the sources with |
---|
545 | n/a | # pygettext. Later it was manually modified to add plural forms support. |
---|
546 | n/a | |
---|
547 | n/a | ''' |
---|
548 | n/a | # Dummy translation for the Python test_gettext.py module. |
---|
549 | n/a | # Copyright (C) 2001 Python Software Foundation |
---|
550 | n/a | # Barry Warsaw <barry@python.org>, 2000. |
---|
551 | n/a | # |
---|
552 | n/a | msgid "" |
---|
553 | n/a | msgstr "" |
---|
554 | n/a | "Project-Id-Version: 2.0\n" |
---|
555 | n/a | "PO-Revision-Date: 2003-04-11 14:32-0400\n" |
---|
556 | n/a | "Last-Translator: J. David Ibanez <j-david@noos.fr>\n" |
---|
557 | n/a | "Language-Team: XX <python-dev@python.org>\n" |
---|
558 | n/a | "MIME-Version: 1.0\n" |
---|
559 | n/a | "Content-Type: text/plain; charset=iso-8859-1\n" |
---|
560 | n/a | "Content-Transfer-Encoding: 8bit\n" |
---|
561 | n/a | "Generated-By: pygettext.py 1.1\n" |
---|
562 | n/a | "Plural-Forms: nplurals=2; plural=n!=1;\n" |
---|
563 | n/a | |
---|
564 | n/a | #: test_gettext.py:19 test_gettext.py:25 test_gettext.py:31 test_gettext.py:37 |
---|
565 | n/a | #: test_gettext.py:51 test_gettext.py:80 test_gettext.py:86 test_gettext.py:92 |
---|
566 | n/a | #: test_gettext.py:98 |
---|
567 | n/a | msgid "nudge nudge" |
---|
568 | n/a | msgstr "wink wink" |
---|
569 | n/a | |
---|
570 | n/a | #: test_gettext.py:16 test_gettext.py:22 test_gettext.py:28 test_gettext.py:34 |
---|
571 | n/a | #: test_gettext.py:77 test_gettext.py:83 test_gettext.py:89 test_gettext.py:95 |
---|
572 | n/a | msgid "albatross" |
---|
573 | n/a | msgstr "" |
---|
574 | n/a | |
---|
575 | n/a | #: test_gettext.py:18 test_gettext.py:24 test_gettext.py:30 test_gettext.py:36 |
---|
576 | n/a | #: test_gettext.py:79 test_gettext.py:85 test_gettext.py:91 test_gettext.py:97 |
---|
577 | n/a | msgid "Raymond Luxury Yach-t" |
---|
578 | n/a | msgstr "Throatwobbler Mangrove" |
---|
579 | n/a | |
---|
580 | n/a | #: test_gettext.py:17 test_gettext.py:23 test_gettext.py:29 test_gettext.py:35 |
---|
581 | n/a | #: test_gettext.py:56 test_gettext.py:78 test_gettext.py:84 test_gettext.py:90 |
---|
582 | n/a | #: test_gettext.py:96 |
---|
583 | n/a | msgid "mullusk" |
---|
584 | n/a | msgstr "bacon" |
---|
585 | n/a | |
---|
586 | n/a | #: test_gettext.py:40 test_gettext.py:101 |
---|
587 | n/a | msgid "" |
---|
588 | n/a | "This module provides internationalization and localization\n" |
---|
589 | n/a | "support for your Python programs by providing an interface to the GNU\n" |
---|
590 | n/a | "gettext message catalog library." |
---|
591 | n/a | msgstr "" |
---|
592 | n/a | "Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba\n" |
---|
593 | n/a | "fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH\n" |
---|
594 | n/a | "trggrkg zrffntr pngnybt yvoenel." |
---|
595 | n/a | |
---|
596 | n/a | # Manually added, as neither pygettext nor xgettext support plural forms |
---|
597 | n/a | # in Python. |
---|
598 | n/a | msgid "There is %s file" |
---|
599 | n/a | msgid_plural "There are %s files" |
---|
600 | n/a | msgstr[0] "Hay %s fichero" |
---|
601 | n/a | msgstr[1] "Hay %s ficheros" |
---|
602 | n/a | ''' |
---|
603 | n/a | |
---|
604 | n/a | # Here's the second example po file example, used to generate the UMO_DATA |
---|
605 | n/a | # containing utf-8 encoded Unicode strings |
---|
606 | n/a | |
---|
607 | n/a | ''' |
---|
608 | n/a | # Dummy translation for the Python test_gettext.py module. |
---|
609 | n/a | # Copyright (C) 2001 Python Software Foundation |
---|
610 | n/a | # Barry Warsaw <barry@python.org>, 2000. |
---|
611 | n/a | # |
---|
612 | n/a | msgid "" |
---|
613 | n/a | msgstr "" |
---|
614 | n/a | "Project-Id-Version: 2.0\n" |
---|
615 | n/a | "PO-Revision-Date: 2003-04-11 12:42-0400\n" |
---|
616 | n/a | "Last-Translator: Barry A. WArsaw <barry@python.org>\n" |
---|
617 | n/a | "Language-Team: XX <python-dev@python.org>\n" |
---|
618 | n/a | "MIME-Version: 1.0\n" |
---|
619 | n/a | "Content-Type: text/plain; charset=utf-8\n" |
---|
620 | n/a | "Content-Transfer-Encoding: 7bit\n" |
---|
621 | n/a | "Generated-By: manually\n" |
---|
622 | n/a | |
---|
623 | n/a | #: nofile:0 |
---|
624 | n/a | msgid "ab\xc3\x9e" |
---|
625 | n/a | msgstr "\xc2\xa4yz" |
---|
626 | n/a | ''' |
---|
627 | n/a | |
---|
628 | n/a | # Here's the third example po file, used to generate MMO_DATA |
---|
629 | n/a | |
---|
630 | n/a | ''' |
---|
631 | n/a | msgid "" |
---|
632 | n/a | msgstr "" |
---|
633 | n/a | "Project-Id-Version: No Project 0.0\n" |
---|
634 | n/a | "POT-Creation-Date: Wed Dec 11 07:44:15 2002\n" |
---|
635 | n/a | "PO-Revision-Date: 2002-08-14 01:18:58+00:00\n" |
---|
636 | n/a | "Last-Translator: John Doe <jdoe@example.com>\n" |
---|
637 | n/a | "Jane Foobar <jfoobar@example.com>\n" |
---|
638 | n/a | "Language-Team: xx <xx@example.com>\n" |
---|
639 | n/a | "MIME-Version: 1.0\n" |
---|
640 | n/a | "Content-Type: text/plain; charset=iso-8859-15\n" |
---|
641 | n/a | "Content-Transfer-Encoding: quoted-printable\n" |
---|
642 | n/a | "Generated-By: pygettext.py 1.3\n" |
---|
643 | n/a | ''' |
---|
644 | n/a | |
---|
645 | n/a | # |
---|
646 | n/a | # messages.po, used for bug 17898 |
---|
647 | n/a | # |
---|
648 | n/a | |
---|
649 | n/a | ''' |
---|
650 | n/a | # test file for http://bugs.python.org/issue17898 |
---|
651 | n/a | msgid "" |
---|
652 | n/a | msgstr "" |
---|
653 | n/a | "Plural-Forms: nplurals=2; plural=(n != 1);\n" |
---|
654 | n/a | "#-#-#-#-# messages.po (EdX Studio) #-#-#-#-#\n" |
---|
655 | n/a | "Content-Type: text/plain; charset=UTF-8\n" |
---|
656 | n/a | ''' |
---|