annotate babel/messages/plurals.py @ 379:1c0915da48c6 stable-0.9.x

Ported [407:415/trunk] back to 0.9.x branch.
author cmlenz
date Tue, 08 Jul 2008 21:01:28 +0000
parents faf0ead3a132
children 6e4905cc919e
rev   line source
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
2 #
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
3 # Copyright (C) 2007 Edgewall Software
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
4 # All rights reserved.
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
5 #
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
9 #
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
13
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents: 54
diff changeset
14 """Plural form definitions."""
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents: 54
diff changeset
15
379
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
16
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
17 from operator import itemgetter
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
18 from babel.core import default_locale, Locale
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
19
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
20
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
21 LC_CTYPE = default_locale('LC_CTYPE')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
22
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
23
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
24 PLURALS = {
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
25 # Afar
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
26 # 'aa': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
27 # Abkhazian
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
28 # 'ab': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
29 # Avestan
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
30 # 'ae': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
31 # Afrikaans - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
32 'af': (2, '(n != 1)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
33 # Akan
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
34 # 'ak': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
35 # Amharic
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
36 # 'am': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
37 # Aragonese
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
38 # 'an': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
39 # Arabic - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
40 'ar': (6, '(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n>=3 && n<=10 ? 3 : n>=11 && n<=99 ? 4 : 5)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
41 # Assamese
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
42 # 'as': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
43 # Avaric
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
44 # 'av': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
45 # Aymara
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
46 # 'ay': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
47 # Azerbaijani
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
48 # 'az': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
49 # Bashkir
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
50 # 'ba': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
51 # Belarusian
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
52 # 'be': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
53 # Bulgarian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
54 'bg': (2, '(n != 1)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
55 # Bihari
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
56 # 'bh': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
57 # Bislama
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
58 # 'bi': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
59 # Bambara
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
60 # 'bm': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
61 # Bengali - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
62 'bn': (2, '(n != 1)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
63 # Tibetan - as discussed in private with Andrew West
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
64 'bo': (1, '0'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
65 # Breton
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
66 # 'br': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
67 # Bosnian
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
68 # 'bs': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
69 # Catalan - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
70 'ca': (2, '(n != 1)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
71 # Chechen
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
72 # 'ce': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
73 # Chamorro
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
74 # 'ch': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
75 # Corsican
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
76 # 'co': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
77 # Cree
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
78 # 'cr': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
79 # Czech
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
80 'cs': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
81 # Church Slavic
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
82 # 'cu': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
83 # Chuvash
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
84 'cv': (1, '0'),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
85 # Welsh
346
faf0ead3a132 Merged revisions [358:360], [364:370], [373:378], [380:382] from [source:trunk].
cmlenz
parents: 318
diff changeset
86 'cy': (5, '(n==1 ? 1 : n==2 ? 2 : n==3 ? 3 : n==6 ? 4 : 0)'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
87 # Danish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
88 'da': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
89 # German
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
90 'de': (2, '(n != 1)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
91 # Divehi
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
92 # 'dv': (),
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
93 # Dzongkha
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
94 'dz': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
95 # Greek
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
96 'el': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
97 # English
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
98 'en': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
99 # Esperanto
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
100 'eo': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
101 # Spanish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
102 'es': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
103 # Estonian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
104 'et': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
105 # Basque - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
106 'eu': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
107 # Persian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
108 'fa': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
109 # Finnish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
110 'fi': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
111 # French
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
112 'fr': (2, '(n > 1)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
113 # Friulian - From Pootle's PO's
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
114 'fur': (2, '(n > 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
115 # Irish
346
faf0ead3a132 Merged revisions [358:360], [364:370], [373:378], [380:382] from [source:trunk].
cmlenz
parents: 318
diff changeset
116 'ga': (3, '(n==1 ? 0 : n==2 ? 1 : 2)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
117 # Galician - From Pootle's PO's
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
118 'gl': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
119 # Hausa - From Pootle's PO's
346
faf0ead3a132 Merged revisions [358:360], [364:370], [373:378], [380:382] from [source:trunk].
cmlenz
parents: 318
diff changeset
120 'ha': (2, '(n != 1)'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
121 # Hebrew
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
122 'he': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
123 # Hindi - From Pootle's PO's
346
faf0ead3a132 Merged revisions [358:360], [364:370], [373:378], [380:382] from [source:trunk].
cmlenz
parents: 318
diff changeset
124 'hi': (2, '(n != 1)'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
125 # Croatian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
126 'hr': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
127 # Hungarian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
128 'hu': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
129 # Armenian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
130 'hy': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
131 # Icelandic - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
132 'is': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
133 # Italian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
134 'it': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
135 # Japanese
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
136 'ja': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
137 # Georgian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
138 'ka': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
139 # Kongo - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
140 'kg': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
141 # Khmer - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
142 'km': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
143 # Korean
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
144 'ko': (1, '0'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
145 # Kurdish - From Pootle's PO's
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
146 'ku': (2, '(n != 1)'),
318
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
147 # Lao - Another member of the Tai language family, like Thai.
e7e6eb212628 Ported [335:338], [345], and [351] to 0.9.x stable branch.
cmlenz
parents: 300
diff changeset
148 'lo': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
149 # Lithuanian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
150 'lt': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
151 # Latvian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
152 'lv': (3, '(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
153 # Maltese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
154 'mt': (4, '(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
155 # Norwegian Bokmål
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
156 'nb': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
157 # Dutch
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
158 'nl': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
159 # Norwegian Nynorsk
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
160 'nn': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
161 # Norwegian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
162 'no': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
163 # Punjabi - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
164 'pa': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
165 # Polish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
166 'pl': (3, '(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
167 # Portuguese
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
168 'pt': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
169 # Brazilian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
170 'pt_BR': (2, '(n > 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
171 # Romanian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
172 'ro': (3, '(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
173 # Russian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
174 'ru': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
175 # Slovak
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
176 'sk': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
177 # Slovenian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
178 'sl': (4, '(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
179 # Serbian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
180 'sr': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10< =4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
181 # Southern Sotho - From Pootle's PO's
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
182 'st': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
183 # Swedish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
184 'sv': (2, '(n != 1)'),
300
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
185 # Thai
dbda490814c8 Ported [328:333] back to 0.9.x stable branch.
cmlenz
parents: 56
diff changeset
186 'th': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
187 # Turkish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
188 'tr': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
189 # Ukrainian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
190 'uk': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
191 # Venda - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
192 've': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
193 # Vietnamese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
194 'vi': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
195 # Xhosa - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
196 'xh': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
197 # Chinese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
198 'zh_CN': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
199 'zh_HK': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
200 'zh_TW': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
201 }
379
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
202
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
203
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
204 DEFAULT_PLURAL = (2, '(n != 1)')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
205
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
206
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
207 class _PluralTuple(tuple):
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
208 """A tuple with plural information."""
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
209
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
210 __slots__ = ()
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
211 num_plurals = property(itemgetter(0), doc="""
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
212 The number of plurals used by the locale.""")
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
213 plural_expr = property(itemgetter(1), doc="""
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
214 The plural expression used by the locale.""")
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
215 plural_forms = property(lambda x: 'npurals=%s; plural=%s' % x, doc="""
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
216 The plural expression used by the catalog or locale.""")
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
217
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
218 def __str__(self):
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
219 return self.plural_forms
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
220
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
221
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
222 def get_plural(locale=LC_CTYPE):
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
223 """A tuple with the information catalogs need to perform proper
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
224 pluralization. The first item of the tuple is the number of plural
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
225 forms, the second the plural expression.
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
226
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
227 >>> get_plural(locale='en')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
228 (2, '(n != 1)')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
229 >>> get_plural(locale='ga')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
230 (3, '(n==1 ? 0 : n==2 ? 1 : 2)')
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
231
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
232 The object returned is a special tuple with additional members:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
233
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
234 >>> tup = get_plural("ja")
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
235 >>> tup.num_plurals
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
236 1
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
237 >>> tup.plural_expr
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
238 '0'
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
239 >>> tup.plural_forms
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
240 'npurals=1; plural=0'
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
241
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
242 Converting the tuple into a string prints the plural forms for a
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
243 gettext catalog:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
244
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
245 >>> str(tup)
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
246 'npurals=1; plural=0'
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
247 """
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
248 locale = Locale.parse(locale)
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
249 try:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
250 tup = PLURALS[str(locale)]
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
251 except KeyError:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
252 try:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
253 tup = PLURALS[locale.language]
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
254 except KeyError:
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
255 tup = DEFAULT_PLURAL
1c0915da48c6 Ported [407:415/trunk] back to 0.9.x branch.
cmlenz
parents: 346
diff changeset
256 return _PluralTuple(tup)
Copyright (C) 2012-2017 Edgewall Software