summaryrefslogtreecommitdiff
path: root/babel
diff options
context:
space:
mode:
authorAlex Morega <alex@grep.ro>2013-07-07 12:59:47 +0200
committerAlex Morega <alex@grep.ro>2013-07-07 13:02:27 +0200
commit4233823e22aa86bf466d58f6f37f60f59e9d42d2 (patch)
treecfbe84b7a11e61065c7b11359b7bf7b29e4b3dbb /babel
parent3f135860f5daec180e0b0d6d4c9fb795209d7b12 (diff)
downloadbabel-4233823e22aa86bf466d58f6f37f60f59e9d42d2.tar.gz
make sure rules are always sorted
Diffstat (limited to 'babel')
-rw-r--r--babel/plural.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/babel/plural.py b/babel/plural.py
index c3137db..afc6d1e 100644
--- a/babel/plural.py
+++ b/babel/plural.py
@@ -57,7 +57,7 @@ class PluralRule(object):
rules = rules.items()
found = set()
self.abstract = []
- for key, expr in rules:
+ for key, expr in sorted(list(rules)):
if key not in _plural_tags:
raise ValueError('unknown tag %r' % key)
elif key in found:
@@ -180,7 +180,7 @@ def to_gettext(rule):
technically limited to integers and returns indices rather than tags.
>>> to_gettext({'one': 'n is 1', 'two': 'n is 2'})
- 'nplurals=3; plural=((n == 2) ? 1 : (n == 1) ? 0 : 2)'
+ 'nplurals=3; plural=((n == 1) ? 0 : (n == 2) ? 1 : 2)'
:param rule: the rules as list or dict, or a `PluralRule` object
:return: an equivalent gettext-style plural expression