comparison babel/messages/tests/pofile.py @ 487:2d1c17275e5b stable-0.9.x

Merged revisions 484-489 via svnmerge from http://svn.edgewall.org/repos/babel/trunk ........ r484 | jruigrok | 2010-02-19 14:16:08 +0100 (vr, 19 feb 2010) | 4 lines Fix testcase name typo. Switch to use a locale that uses a different singular and plural form instead of just one form for both singular and plural. ........ r485 | jruigrok | 2010-02-19 14:38:24 +0100 (vr, 19 feb 2010) | 2 lines Add a test for a locale with one plural form. ........ r486 | jruigrok | 2010-02-19 14:45:25 +0100 (vr, 19 feb 2010) | 3 lines Put the square brackets test after all the normal plural tests. It's more logical. ........ r487 | jruigrok | 2010-02-19 15:12:41 +0100 (vr, 19 feb 2010) | 2 lines More than two plural forms work nowadays. Adjust the test. ........ r488 | jruigrok | 2010-02-19 15:15:56 +0100 (vr, 19 feb 2010) | 2 lines Actually make the msgid_plural be a plural as per typical use case. ........ r489 | jruigrok | 2010-02-24 13:27:32 +0100 (wo, 24 feb 2010) | 2 lines Forgot to bump the copyright line. ........
author jruigrok
date Sun, 11 Apr 2010 09:09:11 +0000
parents 2c6f5e610e86
children dbb70d75718a
comparison
equal deleted inserted replaced
486:58e76e09e705 487:2d1c17275e5b
141 ''') 141 ''')
142 catalog = pofile.read_po(buf, ignore_obsolete=True) 142 catalog = pofile.read_po(buf, ignore_obsolete=True)
143 self.assertEqual(1, len(catalog)) 143 self.assertEqual(1, len(catalog))
144 self.assertEqual(0, len(catalog.obsolete)) 144 self.assertEqual(0, len(catalog.obsolete))
145 145
146 def test_singlular_plural_form(self): 146 def test_single_plural_form(self):
147 buf = StringIO(r'''msgid "foo" 147 buf = StringIO(r'''msgid "foo"
148 msgid_plural "foo" 148 msgid_plural "foos"
149 msgstr[0] "Voh" 149 msgstr[0] "Voh"''')
150 msgstr[1] "Vohs"''') # This is a bad po, ja_JP only uses msgstr[0]
151 catalog = pofile.read_po(buf, locale='ja_JP') 150 catalog = pofile.read_po(buf, locale='ja_JP')
152 self.assertEqual(1, len(catalog)) 151 self.assertEqual(1, len(catalog))
153 self.assertEqual(1, catalog.num_plurals) 152 self.assertEqual(1, catalog.num_plurals)
154 message = catalog['foo'] 153 message = catalog['foo']
155 self.assertEqual(1, len(message.string)) 154 self.assertEqual(1, len(message.string))
156 155
156 def test_singular_plural_form(self):
157 buf = StringIO(r'''msgid "foo"
158 msgid_plural "foos"
159 msgstr[0] "Voh"
160 msgstr[1] "Vohs"''')
161 catalog = pofile.read_po(buf, locale='nl_NL')
162 self.assertEqual(1, len(catalog))
163 self.assertEqual(2, catalog.num_plurals)
164 message = catalog['foo']
165 self.assertEqual(2, len(message.string))
166
157 def test_more_than_two_plural_forms(self): 167 def test_more_than_two_plural_forms(self):
158 buf = StringIO(r'''msgid "foo" 168 buf = StringIO(r'''msgid "foo"
159 msgid_plural "foo" 169 msgid_plural "foos"
160 msgstr[0] "Voh" 170 msgstr[0] "Voh"
161 msgstr[1] "Vohs"''') # last translation form is missing 171 msgstr[1] "Vohs"
162 #msgstr[2] "Vohss"''') 172 msgstr[2] "Vohss"''')
163 catalog = pofile.read_po(buf, locale='lv_LV') 173 catalog = pofile.read_po(buf, locale='lv_LV')
164 self.assertEqual(1, len(catalog)) 174 self.assertEqual(1, len(catalog))
165 self.assertEqual(3, catalog.num_plurals) 175 self.assertEqual(3, catalog.num_plurals)
166 message = catalog['foo'] 176 message = catalog['foo']
167 self.assertEqual(3, len(message.string)) 177 self.assertEqual(3, len(message.string))
168 self.assertEqual('', message.string[2]) 178 self.assertEqual(u'Vohss', message.string[2])
169 179
170 def test_plural_with_square_brackets(self): 180 def test_plural_with_square_brackets(self):
171 buf = StringIO(r'''msgid "foo" 181 buf = StringIO(r'''msgid "foo"
172 msgid_plural "foos" 182 msgid_plural "foos"
173 msgstr[0] "Voh [text]" 183 msgstr[0] "Voh [text]"
Copyright (C) 2012-2017 Edgewall Software