Ricordisamoa has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/80698


Change subject: use "while" to allow multiple "{{PLURAL}}" paths to be used 
within "translate"
......................................................................

use "while" to allow multiple "{{PLURAL}}" paths to be used within "translate"

Change-Id: I3c6e28316f7ca667ba9a3e95332301520b86dd97
---
M pywikibot/i18n.py
1 file changed, 20 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/98/80698/1

diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 4a96bbe..5a14e86 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -289,26 +289,27 @@
         return trans
 
     # else we check for PLURAL variants
-    try:
-        selector, variants = re.search(PLURAL_PATTERN, trans).groups()
-    except AttributeError:
-        pass
-    else:  # we found PLURAL patterns, process it
-        if type(parameters) == dict:
-            num = param[selector]
-        elif isinstance(parameters, basestring):
-            num = int(parameters)
-        else:
-            num = parameters
-        # TODO: check against plural_rules[lang]['nplurals']
+    while re.search(PLURAL_PATTERN, trans):
         try:
-            index = plural_rules[code]['plural'](num)
-        except KeyError:
-            index = plural_rules['_default']['plural'](num)
-        except TypeError:
-            # we got an int, not a function
-            index = plural_rules[code]['plural']
-        trans = re.sub(PLURAL_PATTERN, variants.split('|')[index], trans)
+            selector, variants = re.search(PLURAL_PATTERN, trans).groups()
+        except AttributeError:
+            pass
+        else:  # we found PLURAL patterns, process it
+            if type(parameters) == dict:
+                num = param[selector]
+            elif isinstance(parameters, basestring):
+                num = int(parameters)
+            else:
+                num = parameters
+            # TODO: check against plural_rules[lang]['nplurals']
+            try:
+                index = plural_rules[code]['plural'](num)
+            except KeyError:
+                index = plural_rules['_default']['plural'](num)
+            except TypeError:
+                # we got an int, not a function
+                index = plural_rules[code]['plural']
+            trans = re.sub(PLURAL_PATTERN, variants.split('|')[index], trans, 
count = 1)
     if param:
         try:
             return trans % param

-- 
To view, visit https://gerrit.wikimedia.org/r/80698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c6e28316f7ca667ba9a3e95332301520b86dd97
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisa...@live.it>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to