Page MenuHomePhabricator

i18n Messages should use a dict for replacements
Closed, ResolvedPublic

Description

'category-renamed': u'Bot: Moved from %s. Authors: %s',

should be changes to

'category-renamed': u'Bot: Moved from %(from)s. Authors: %(authors)s',

or similar for use with a dict like all the other messages:

  • category-renamed: “Bot: Moved from %s. Authors: %s”
  • deledpimage-edit-summary: “Robot: Fix EDP image use: [[%s]]”
  • followlive-blanking: “Blanked, content was '%s'.”
  • piper-edit-summary: “Robot: Piping the article text through %s”
  • unlink-unlinking: “Bot: Unlinking \"%s\"”

Event Timeline

Xqt raised the priority of this task from to Low.
Xqt updated the task description. (Show Details)
Xqt added a project: Pywikibot-i18n.
Xqt added a subscriber: Xqt.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptMay 4 2015, 1:49 PM

Same for

'followlive-blanking': u'Blanked, content was \'%s\'.'

additional one:

'unlink-unlinking': u'Bot: Unlinking "%s"',

A complete list as of 31646360:

$ git grep '%s' | grep 'en.json'
category/en.json:	"category-renamed": "Bot: Moved from %s. Authors: %s",
deledpimage/en.json:	"deledpimage-edit-summary": "Robot: Fix EDP image use: [[%s]]"
followlive/en.json:	"followlive-blanking": "Blanked, content was '%s'."
piper/en.json:	"piper-edit-summary": "Robot: Piping the article text through %s"
unlink/en.json:	"unlink-unlinking": "Bot: Unlinking \"%s\""
XZise set Security to None.
Xqt renamed this task from Change category-renamed messages to dict entries to i18n Messages should use a dict for replacements.Jun 10 2015, 7:43 AM

Change 221395 had a related patch set uploaded (by XZise):
[FIX] category: Use dict in i18n

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

This changeset is only fixing category as the others only use one parameter so there no ambiguity yet. And to avoid that https://gerrit.wikimedia.org/r/#/c/221381 needs to change it to the “numbered” mode.

Change 221395 merged by jenkins-bot:
[FIX] category: Use dict in i18n

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

Note that the deledpimage-edit-summary and followlive-blanking both are unused in Pywikibot. (There are afaik patches for both)

Change 221414 had a related patch set uploaded (by XZise):
[FIX] Use named i18n parameters

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

Change 221413 had a related patch set uploaded (by XZise):
[FIX] Use named i18n parameters

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

Change 221417 had a related patch set uploaded (by XZise):
[FIX] category: Use dict in i18n

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

Change 221413 merged by jenkins-bot:
[FIX] Use named i18n parameters

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

Change 221414 merged by jenkins-bot:
[FIX] Use named i18n parameters

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

Change 221420 had a related patch set uploaded (by XZise):
[FIX] Use named i18n parameters

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

All scripts in Pywikibot now don't use %s. There is one patch remaining in the Pywikibot-i18n repository to fix the remaining two which aren't in Pywikibot and aren't used in Pywikibot-compat. I've added a note to the patches Gerrit 190710 and Gerrit 203539 that there is a patch changing it into a named parameter. So from the standpoint of the Pywikibot and Pywikibot-i18n repository all cases have been handled. I/We need to check Pywikibot-compat though as that might use unnamed parameters still and will be broken as soon as the Python files are updated (they haven't been yet). Alternatively the converter from JSON to Python file could be modified to check for the keys and do something like re.sub(r'%\([^)]*?\)s', '%s'). I've also checked the i18n repository using git grep -E "%[^.(s]" | grep en.json and that does only show one translation where it's used for strptime.

Okay a quick look through Pywikibot-compat and it only uses unlink-unlinking from those five keys and I've proposed a patch Gerrit 221421 which prevents it from breaking.

Change 221421 had a related patch set uploaded (by XZise):
[FIX] Use named i18n parameter in unlink

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

Change 221424 had a related patch set uploaded (by XZise):
[FIX] Use named i18n parameters

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

Change 221420 merged by jenkins-bot:
[FIX] Use named i18n parameters

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

Message checkers and inesrtables in translatewiki.net should be updated to understand the new formats.

Change 221424 merged by jenkins-bot:
[FIX] Use named i18n parameters

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

Change 221417 merged by jenkins-bot:
[FIX] category: Use dict in i18n

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

Message checkers and inesrtables in translatewiki.net should be updated to understand the new formats.

Could you expand on that? I don't understand what needs to be done.

@Nikerabbit I've no idea how to change the messagechecker at twn. I am wondering why changing the en translations is not enough.

Sorry for my terseness. I only left a quick note as I came across this task by accident.

In the image below, checkers produce the warning for missing and unknown parameters (yellow) [1] and insertables provide one click insertion for chunks of text (%s next to Discard changes) to reduce spelling mistakes and to help tablet users. The format of parameters vary a lot, so the formats need to be specified manually per project. I am happy to apply them if you provide a list of examples of different types of parameters and optionally regular expressions to match them.

[1] If at translation save time a check fails, the translation is marked as outdated.

pasted_file (800×1 px, 110 KB)

With the merged changes it should be afaik only %\([a-z0-9A-Z]+?\)[ds]. I need to check if there are any weird variables which use characters other than a-zA-Z0-9 (afaik all variables should use English names) and I'll verify that we got all instances of %s (which shouldn't occur but may). @Xqt has also a patch which checks the repository (unfortunately it only checks in Pywikibot and not Pywikibot-i18n so not on merge but only later but it's a start).

EDIT: Couldn't find any odd parameters (there is an occurrence of %d in thirdparty-drtrigonbot-sum_disc-parse-start but that is for strptime as explained above).

Change 221421 abandoned by XZise:
[FIX] Use named i18n parameter in unlink

Reason:
As Xqt said, the Python files will continue to use the unnamed parameters which is fine in this case as there is just one anyway.

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