http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10432
Revision: 10432
Author: xqt
Date: 2012-06-30 15:47:55 +0000 (Sat, 30 Jun 2012)
Log Message:
-----------
fix for non plural languages when plural_rules returns just 0;
update from rewrite r10431
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2012-06-30 15:47:10 UTC (rev 10431)
+++ trunk/pywikipedia/pywikibot/i18n.py 2012-06-30 15:47:55 UTC (rev 10432)
@@ -396,10 +396,13 @@
# maybe we should implement this to i18n.translate()
# TODO: check against plural_rules[lang]['nplurals']
try:
- plural_func = plural_rules[lang]['plural']
+ index = plural_rules[lang]['plural'](num)
except KeyError:
- plural_func = plural_rules['_default']['plural']
- repl = variants.split('|')[plural_func(num)]
+ index = plural_rules['_default']['plural'](num)
+ except TypeError:
+ # we got an int
+ index = plural_rules[lang]['plural']
+ repl = variants.split('|')[index]
trans = re.sub(PATTERN, repl, trans)
if param:
try: