annotate babel/messages/plurals.py @ 530:85e1beadacb0

Update the copyright line.
author jruigrok
date Sat, 05 Mar 2011 15:22:28 +0000
parents 540cbe76f413
children
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 #
530
85e1beadacb0 Update the copyright line.
jruigrok
parents: 527
diff changeset
3 # Copyright (C) 2007-2011 Edgewall Software
51
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
373
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
16 from babel.core import default_locale, Locale
527
540cbe76f413 Get rid of the utility code for itemgetter(), we now simply import this
jruigrok
parents: 489
diff changeset
17 from operator import itemgetter
373
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
18
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
19
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
20 LC_CTYPE = default_locale('LC_CTYPE')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
21
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
22
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
23 PLURALS = {
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
24 # Afar
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
25 # 'aa': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
26 # Abkhazian
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
27 # 'ab': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
28 # Avestan
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
29 # 'ae': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
30 # Afrikaans - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
31 'af': (2, '(n != 1)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
32 # Akan
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
33 # 'ak': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
34 # Amharic
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
35 # 'am': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
36 # Aragonese
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
37 # 'an': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
38 # Arabic - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
39 'ar': (6, '(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n>=3 && n<=10 ? 3 : n>=11 && n<=99 ? 4 : 5)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
40 # Assamese
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
41 # 'as': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
42 # Avaric
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
43 # 'av': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
44 # Aymara
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
45 # 'ay': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
46 # Azerbaijani
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
47 # 'az': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
48 # Bashkir
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
49 # 'ba': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
50 # Belarusian
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
51 # 'be': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
52 # Bulgarian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
53 'bg': (2, '(n != 1)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
54 # Bihari
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
55 # 'bh': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
56 # Bislama
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
57 # 'bi': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
58 # Bambara
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
59 # 'bm': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
60 # Bengali - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
61 'bn': (2, '(n != 1)'),
297
4b840d9f232b Add plural forms definition for Tibetan.
jruigrok
parents: 296
diff changeset
62 # Tibetan - as discussed in private with Andrew West
4b840d9f232b Add plural forms definition for Tibetan.
jruigrok
parents: 296
diff changeset
63 'bo': (1, '0'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
64 # Breton
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
65 # 'br': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
66 # Bosnian
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
67 # 'bs': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
68 # Catalan - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
69 'ca': (2, '(n != 1)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
70 # Chechen
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
71 # 'ce': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
72 # Chamorro
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
73 # 'ch': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
74 # Corsican
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
75 # 'co': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
76 # Cree
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
77 # 'cr': (),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
78 # Czech
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
79 'cs': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
80 # Church Slavic
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
81 # 'cu': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
82 # Chuvash
304
3a79256294ff Assume that, since Chuvash is a Turkic language, Chuvash follows the same
jruigrok
parents: 303
diff changeset
83 'cv': (1, '0'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
84 # Welsh
335
9c41fe73e2e6 More preparation for msgctxt support (#54).
cmlenz
parents: 311
diff changeset
85 '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
86 # Danish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
87 'da': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
88 # German
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
89 'de': (2, '(n != 1)'),
302
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
90 # Divehi
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
91 # 'dv': (),
66db65e52b1c Add commented ISO 639-1 codes up to 'e'.
jruigrok
parents: 301
diff changeset
92 # Dzongkha
303
4a120facb7d5 Given Dzongkha's relation to Tibetan for now assume the same plurality rules
jruigrok
parents: 302
diff changeset
93 'dz': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
94 # Greek
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
95 'el': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
96 # English
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
97 'en': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
98 # Esperanto
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
99 'eo': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
100 # Spanish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
101 'es': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
102 # Estonian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
103 'et': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
104 # Basque - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
105 'eu': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
106 # Persian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
107 'fa': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
108 # Finnish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
109 'fi': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
110 # French
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
111 'fr': (2, '(n > 1)'),
299
a43a83aa29ff Use consistent English names for all language names.
jruigrok
parents: 297
diff changeset
112 # 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
113 'fur': (2, '(n > 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
114 # Irish
335
9c41fe73e2e6 More preparation for msgctxt support (#54).
cmlenz
parents: 311
diff changeset
115 'ga': (3, '(n==1 ? 0 : n==2 ? 1 : 2)'),
299
a43a83aa29ff Use consistent English names for all language names.
jruigrok
parents: 297
diff changeset
116 # 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
117 'gl': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
118 # Hausa - From Pootle's PO's
335
9c41fe73e2e6 More preparation for msgctxt support (#54).
cmlenz
parents: 311
diff changeset
119 'ha': (2, '(n != 1)'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
120 # Hebrew
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
121 'he': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
122 # Hindi - From Pootle's PO's
335
9c41fe73e2e6 More preparation for msgctxt support (#54).
cmlenz
parents: 311
diff changeset
123 'hi': (2, '(n != 1)'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
124 # Croatian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
125 '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
126 # Hungarian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
127 'hu': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
128 # Armenian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
129 'hy': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
130 # Icelandic - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
131 'is': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
132 # Italian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
133 'it': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
134 # Japanese
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
135 'ja': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
136 # Georgian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
137 'ka': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
138 # Kongo - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
139 'kg': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
140 # Khmer - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
141 'km': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
142 # Korean
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
143 'ko': (1, '0'),
299
a43a83aa29ff Use consistent English names for all language names.
jruigrok
parents: 297
diff changeset
144 # 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
145 'ku': (2, '(n != 1)'),
301
e6a90e0a82d8 Add a definition for Lao.
jruigrok
parents: 299
diff changeset
146 # Lao - Another member of the Tai language family, like Thai.
e6a90e0a82d8 Add a definition for Lao.
jruigrok
parents: 299
diff changeset
147 'lo': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
148 # Lithuanian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
149 '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
150 # Latvian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
151 '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
152 # Maltese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
153 'mt': (4, '(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'),
299
a43a83aa29ff Use consistent English names for all language names.
jruigrok
parents: 297
diff changeset
154 # Norwegian Bokmål
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
155 'nb': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
156 # Dutch
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
157 'nl': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
158 # Norwegian Nynorsk
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
159 'nn': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
160 # Norwegian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
161 'no': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
162 # Punjabi - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
163 'pa': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
164 # Polish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
165 '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
166 # Portuguese
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
167 'pt': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
168 # Brazilian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
169 'pt_BR': (2, '(n > 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
170 # Romanian - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
171 '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
172 # Russian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
173 '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
174 # Slovak
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
175 '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
176 # Slovenian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
177 '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
178 # Serbian - From Pootle's PO's
489
eb42dbd6b9d6 Fix Serbian plural forms (ticket #213).
jruigrok
parents: 414
diff changeset
179 'sr': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
299
a43a83aa29ff Use consistent English names for all language names.
jruigrok
parents: 297
diff changeset
180 # 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
181 'st': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
182 # Swedish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
183 'sv': (2, '(n != 1)'),
296
c2ec642f0db1 Add a plurals definition for Thai.
jruigrok
parents: 56
diff changeset
184 # Thai
c2ec642f0db1 Add a plurals definition for Thai.
jruigrok
parents: 56
diff changeset
185 'th': (1, '0'),
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
186 # Turkish
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
187 'tr': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
188 # Ukrainian
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
189 '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
190 # Venda - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
191 've': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
192 # Vietnamese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
193 'vi': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
194 # Xhosa - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
195 'xh': (2, '(n != 1)'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
196 # Chinese - From Pootle's PO's
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
197 'zh_CN': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
198 'zh_HK': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
199 'zh_TW': (1, '0'),
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
diff changeset
200 }
373
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
201
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
202
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
203 DEFAULT_PLURAL = (2, '(n != 1)')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
204
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
205
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
206 class _PluralTuple(tuple):
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
207 """A tuple with plural information."""
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
208
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
209 __slots__ = ()
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
210 num_plurals = property(itemgetter(0), doc="""
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
211 The number of plurals used by the locale.""")
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
212 plural_expr = property(itemgetter(1), doc="""
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
213 The plural expression used by the locale.""")
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
214 plural_forms = property(lambda x: 'npurals=%s; plural=%s' % x, doc="""
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
215 The plural expression used by the catalog or locale.""")
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
216
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
217 def __str__(self):
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
218 return self.plural_forms
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
219
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
220
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
221 def get_plural(locale=LC_CTYPE):
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
222 """A tuple with the information catalogs need to perform proper
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
223 pluralization. The first item of the tuple is the number of plural
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
224 forms, the second the plural expression.
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
225
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
226 >>> get_plural(locale='en')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
227 (2, '(n != 1)')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
228 >>> get_plural(locale='ga')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
229 (3, '(n==1 ? 0 : n==2 ? 1 : 2)')
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
230
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
231 The object returned is a special tuple with additional members:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
232
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
233 >>> tup = get_plural("ja")
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
234 >>> tup.num_plurals
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
235 1
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
236 >>> tup.plural_expr
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
237 '0'
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
238 >>> tup.plural_forms
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
239 'npurals=1; plural=0'
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
240
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
241 Converting the tuple into a string prints the plural forms for a
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
242 gettext catalog:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
243
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
244 >>> str(tup)
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
245 'npurals=1; plural=0'
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
246 """
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
247 locale = Locale.parse(locale)
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
248 try:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
249 tup = PLURALS[str(locale)]
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
250 except KeyError:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
251 try:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
252 tup = PLURALS[locale.language]
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
253 except KeyError:
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
254 tup = DEFAULT_PLURAL
2316a7fd75d9 Added babel.messages.plurals.get_plural which returns a special tuple with the plural information.
aronacher
parents: 335
diff changeset
255 return _PluralTuple(tup)
Copyright (C) 2012-2017 Edgewall Software