Mercurial > babel > old > babel-test
annotate babel/messages/tests/checkers.py @ 530:85e1beadacb0
Update the copyright line.
author | jruigrok |
---|---|
date | Sat, 05 Mar 2011 15:22:28 +0000 |
parents | 3dd226bb3ec3 |
children |
rev | line source |
---|---|
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
2 # |
530 | 3 # Copyright (C) 2008-2011 Edgewall Software |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
4 # All rights reserved. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
5 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
6 # This software is licensed as described in the file COPYING, which |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
7 # you should have received as part of this distribution. The terms |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
8 # are also available at http://babel.edgewall.org/wiki/License. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
9 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
10 # This software consists of voluntary contributions made by many |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
11 # individuals. For the exact contribution history, see the revision |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
12 # history and logs, available at http://babel.edgewall.org/log/. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
13 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
14 from datetime import datetime |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
15 import time |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
16 import unittest |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
17 from StringIO import StringIO |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
18 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
19 from babel import __version__ as VERSION |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
20 from babel.core import Locale, UnknownLocaleError |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
21 from babel.dates import format_datetime |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
22 from babel.messages import checkers |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
23 from babel.messages.plurals import PLURALS |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
24 from babel.messages.pofile import read_po |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
25 from babel.util import LOCALTZ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
26 |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
27 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
28 class CheckersTestCase(unittest.TestCase): |
371 | 29 # the last msgstr[idx] is always missing except for singular plural forms |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
30 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
31 def test_1_num_plurals_checkers(self): |
371 | 32 for _locale in [p for p in PLURALS if PLURALS[p][0] == 1]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
33 try: |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
34 locale = Locale.parse(_locale) |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
35 except UnknownLocaleError: |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
36 # Just an alias? Not what we're testing here, let's continue |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
37 continue |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
38 po_file = (ur"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
39 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
40 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
41 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
42 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
43 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
44 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
45 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
46 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
47 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
48 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
49 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
50 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
51 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
52 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
53 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
54 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
55 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
56 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
57 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
58 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
59 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
60 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
61 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
62 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
63 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
64 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
65 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
66 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
67 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
68 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
69 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
70 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
71 english_name = locale.english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
72 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
73 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
74 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
75 'yyyy-MM-dd HH:mmZ', |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
76 tzinfo=LOCALTZ, locale=_locale), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
77 num_plurals = PLURALS[_locale][0], |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
78 plural_expr = PLURALS[_locale][0])).encode('utf-8') |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
79 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
80 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
81 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
82 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
83 message = catalog['foobar'] |
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
84 checkers.num_plurals(catalog, message) |
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
85 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
86 def test_2_num_plurals_checkers(self): |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
87 # in this testcase we add an extra msgstr[idx], we should be |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
88 # disregarding it |
371 | 89 for _locale in [p for p in PLURALS if PLURALS[p][0] == 2]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
90 if _locale in ['nn', 'no']: |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
91 _locale = 'nn_NO' |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
92 num_plurals = PLURALS[_locale.split('_')[0]][0] |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
93 plural_expr = PLURALS[_locale.split('_')[0]][1] |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
94 else: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
95 num_plurals = PLURALS[_locale][0] |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
96 plural_expr = PLURALS[_locale][1] |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
97 try: |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
98 locale = Locale(_locale) |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
99 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
100 'yyyy-MM-dd HH:mmZ', |
422 | 101 tzinfo=LOCALTZ, locale=_locale) |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
102 except UnknownLocaleError: |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
103 # Just an alias? Not what we're testing here, let's continue |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
104 continue |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
105 po_file = (ur"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
106 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
107 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
108 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
109 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
110 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
111 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
112 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
113 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
114 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
115 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
116 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
117 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
118 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
119 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
120 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
121 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
122 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
123 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
124 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
125 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
126 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
127 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
128 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
129 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
130 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
131 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
132 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
133 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
134 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
135 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
136 msgstr[1] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
137 msgstr[2] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
138 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
139 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
140 english_name = locale.english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
141 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
142 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
143 date = date, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
144 num_plurals = num_plurals, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
145 plural_expr = plural_expr)).encode('utf-8') |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
146 # we should be adding the missing msgstr[0] |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
147 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
148 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
149 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
150 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
151 message = catalog['foobar'] |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
152 checkers.num_plurals(catalog, message) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
153 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
154 def test_3_num_plurals_checkers(self): |
371 | 155 for _locale in [p for p in PLURALS if PLURALS[p][0] == 3]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
156 po_file = r"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
157 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
158 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
159 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
160 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
161 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
162 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
163 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
164 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
165 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
166 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
167 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
168 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
169 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
170 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
171 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
172 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
173 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
174 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
175 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
176 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
177 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
178 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
179 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
180 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
181 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
182 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
183 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
184 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
185 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
186 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
187 msgstr[1] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
188 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
189 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
190 english_name = Locale.parse(_locale).english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
191 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
192 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
193 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
194 'yyyy-MM-dd HH:mmZ', |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
195 tzinfo=LOCALTZ, locale=_locale), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
196 num_plurals = PLURALS[_locale][0], |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
197 plural_expr = PLURALS[_locale][0]) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
198 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
199 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
200 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
201 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
202 message = catalog['foobar'] |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
203 checkers.num_plurals(catalog, message) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
204 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
205 def test_4_num_plurals_checkers(self): |
371 | 206 for _locale in [p for p in PLURALS if PLURALS[p][0] == 4]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
207 po_file = r"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
208 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
209 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
210 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
211 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
212 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
213 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
214 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
215 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
216 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
217 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
218 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
219 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
220 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
221 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
222 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
223 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
224 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
225 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
226 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
227 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
228 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
229 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
230 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
231 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
232 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
233 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
234 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
235 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
236 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
237 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
238 msgstr[1] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
239 msgstr[2] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
240 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
241 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
242 english_name = Locale.parse(_locale).english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
243 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
244 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
245 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
246 'yyyy-MM-dd HH:mmZ', |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
247 tzinfo=LOCALTZ, locale=_locale), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
248 num_plurals = PLURALS[_locale][0], |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
249 plural_expr = PLURALS[_locale][0]) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
250 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
251 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
252 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
253 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
254 message = catalog['foobar'] |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
255 checkers.num_plurals(catalog, message) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
256 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
257 def test_5_num_plurals_checkers(self): |
371 | 258 for _locale in [p for p in PLURALS if PLURALS[p][0] == 5]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
259 po_file = r"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
260 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
261 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
262 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
263 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
264 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
265 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
266 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
267 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
268 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
269 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
270 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
271 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
272 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
273 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
274 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
275 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
276 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
277 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
278 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
279 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
280 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
281 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
282 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
283 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
284 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
285 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
286 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
287 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
288 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
289 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
290 msgstr[1] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
291 msgstr[2] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
292 msgstr[3] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
293 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
294 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
295 english_name = Locale.parse(_locale).english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
296 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
297 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
298 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
299 'yyyy-MM-dd HH:mmZ', |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
300 tzinfo=LOCALTZ, locale=_locale), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
301 num_plurals = PLURALS[_locale][0], |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
302 plural_expr = PLURALS[_locale][0]) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
303 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
304 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
305 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
306 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
307 message = catalog['foobar'] |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
308 checkers.num_plurals(catalog, message) |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
309 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
310 def test_6_num_plurals_checkers(self): |
371 | 311 for _locale in [p for p in PLURALS if PLURALS[p][0] == 6]: |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
312 po_file = r"""\ |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
313 # %(english_name)s translations for TestProject. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
314 # Copyright (C) 2007 FooBar, Inc. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
315 # This file is distributed under the same license as the TestProject |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
316 # project. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
317 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
318 # |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
319 msgid "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
320 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
321 "Project-Id-Version: TestProject 0.1\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
322 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
323 "POT-Creation-Date: 2007-04-01 15:30+0200\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
324 "PO-Revision-Date: %(date)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
325 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
326 "Language-Team: %(locale)s <LL@li.org>\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
327 "Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
328 "MIME-Version: 1.0\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
329 "Content-Type: text/plain; charset=utf-8\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
330 "Content-Transfer-Encoding: 8bit\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
331 "Generated-By: Babel %(version)s\n" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
332 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
333 #. This will be a translator comment, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
334 #. that will include several lines |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
335 #: project/file1.py:8 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
336 msgid "bar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
337 msgstr "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
338 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
339 #: project/file2.py:9 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
340 msgid "foobar" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
341 msgid_plural "foobars" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
342 msgstr[0] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
343 msgstr[1] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
344 msgstr[2] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
345 msgstr[3] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
346 msgstr[4] "" |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
347 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
348 """ % dict(locale = _locale, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
349 english_name = Locale.parse(_locale).english_name, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
350 version = VERSION, |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
351 year = time.strftime('%Y'), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
352 date = format_datetime(datetime.now(LOCALTZ), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
353 'yyyy-MM-dd HH:mmZ', |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
354 tzinfo=LOCALTZ, locale=_locale), |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
355 num_plurals = PLURALS[_locale][0], |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
356 plural_expr = PLURALS[_locale][0]) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
357 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
358 # This test will fail for revisions <= 406 because so far |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
359 # catalog.num_plurals was neglected |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
360 catalog = read_po(StringIO(po_file), _locale) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
361 message = catalog['foobar'] |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
362 checkers.num_plurals(catalog, message) |
378
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
363 |
d3d862b0d600
Use item access to catalog messages in tests, so that they can be easily ported back to the 0.9.x branch.
cmlenz
parents:
371
diff
changeset
|
364 |
370
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
365 def suite(): |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
366 suite = unittest.TestSuite() |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
367 suite.addTest(unittest.makeSuite(CheckersTestCase)) |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
368 return suite |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
369 |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
370 if __name__ == '__main__': |
6129d2e770bc
We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents:
diff
changeset
|
371 unittest.main(defaultTest='suite') |