Page MenuHomePhabricator

Add support for translated dates/times
Closed, ResolvedPublic

Description

The Revertbot-revert message currently uses an ISO timestamp, and using a translated string would be nicer.

The easiest way to do this is to hook into PyICU (https://pypi.python.org/pypi/PyICU), but that depends on ICU which is nontrivial to install.

Event Timeline

valhallasw raised the priority of this task from to Needs Triage.
valhallasw updated the task description. (Show Details)
valhallasw added subscribers: valhallasw, Purodha.

We have a humongous date.py library which can do this.

>>> s = pywikibot.Site('fa', 'wikipedia')
>>> fd = pywikibot.date.FormatDate(s)
>>> fd(10, 3)
u'3 \u0627\u06a9\u062a\u0628\u0631'
>>> pywikibot.date.formatYear('fa', 2013)
u'\u06f2\u06f0\u06f1\u06f3 (\u0645\u06cc\u0644\u0627\u062f\u06cc)'

I am not sure how to stitch the year and month+day together correctly for a locale, but I am sure the voodoo is in that library somewhere .. ;-)

We could also use the site messages for month names, which is the approach that textlib.TimeStripper uses, and ensures good localisation. I wonder if there are other site messages which describe the format of a date used on the wiki.

Change 738510 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Add support for translated dates/times

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

Xqt triaged this task as Low priority.Nov 13 2021, 1:11 PM
Xqt claimed this task.

Change 738510 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Add support for translated dates/times

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