Page MenuHomePhabricator

support multiple occurrences of {{PLURAL}} within a single message
Closed, ResolvedPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/patches/617/
Reported by: Anonymous user
Created on: 2013-05-28 23:05:42
Subject: important fix for i18n.py
Original description:
the "i18n.py" file in the "/pywikibot" directory has a useful "translate" function; but it doesn't work well with multiple "\{\{PLURAL\}\}" directives in the same string: for example, the following code:
pywikibot.i18n.translate\('en',\{'en':'%\(links\)d \{\{PLURAL:%\(links\)d|link|links\}\} and %\(apples\)d \{\{PLURAL:%\(apples\)d|apple|apples\}\}'\},\{'links':1,'apples':4\}\)
returns "1 link and 4 link" instead of "1 link and 4 apples".
I've fixed that doing a "while" loop for each \{\{PLURAL\}\} and replacing/translating only one of them at a time; probably other functions need such fixes as well.
My version is attached, feel free to improve it and include it in the pywikipediabot rewrite branch.


Version: compat-(1.0)
Severity: minor
See Also:
https://sourceforge.net/p/pywikipediabot/patches/617

Details

Reference
bz54544

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:10 AM
bzimport added a project: Pywikibot-i18n.
bzimport set Reference to bz54544.
bzimport added a subscriber: Unknown Object (????).

Change 91414 had a related patch set uploaded by Ladsgroup:
Bugfix for python 2.5: "plural_rules" is the valid function

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

This bug is not related to gerrit 91414 but to Gerrit 80698

(In reply to comment #0)

Reported by: Anonymous user

That was me.

@Xqt: any updates?

Ah yes. I am just testing a new function for both translation methods to prevent code duplication. Hm, it should become ready to commit ;)

Ok, so please take care of the backport when you're finished ;-)

jayvdb lowered the priority of this task from High to Low.Dec 26 2014, 5:59 AM

So far, the pywikibot/i18n repo does not have any messages which use multiple PLURALs, and the messages which use one PLURAL dont appear to need another one.

$ git grep PLURAL */en.json
archivebot/en.json:     "archivebot-page-summary": "Bot: Archiving %(count)d {{PLURAL:%(count)d|thread|threads}} (%(why)s) to %(archives)s.",
archivebot/en.json:     "archivebot-archive-summary": "Bot: Archiving %(count)d {{PLURAL:%(count)d|thread|threads}} from [[%(from)s]]."
category/en.json:       "category-listifying": "Bot: Listifying from %(fromcat)s ({{PLURAL:%(num)d|1 entry|%(num)d entries}})"
table2wiki/en.json:     "table2wiki-warnings": "User-controlled bot: Table syntax updated - {{PLURAL:count|1 warning|%(count)d warnings}}!",
template/en.json:       "template-removing": "Bot: Removing {{PLURAL:%(num)d|template|templates}}: %(list)s",
template/en.json:       "template-changing": "Bot: Changing {{PLURAL:%(num)d|template|templates}}: %(list)s",
template/en.json:       "template-substituting": "Bot: Substituting {{PLURAL:%(num)d|template|templates}}: %(list)s"

If there is a pending change which needs multiple PLURALs, it should add this task as a dependency.

Xqt claimed this task.

already done in 4b1dc6a2bf52069e641a90b6dfd114063bbf6699
https://gerrit.wikimedia.org/r/#/c/119338/