Whym has uploaded a new change for review.

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

Change subject: archivebot: conformance to translate() and additional shorthands
......................................................................

archivebot: conformance to translate() and additional shorthands

Use dict as the argument for translate().
Additional shorthand notations for "years" and "weeks".

Change-Id: I1ef93cf16f0345ab858532e7a9c2063c76c554c4
---
M scripts/archivebot.py
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/22/265222/1

diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index d87e72c..e2459a2 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -155,12 +155,16 @@
     Translates a duration written in the shorthand notation (ex. "24h", "7d")
     into an expression in the local language of the wiki ("24 hours", "7 
days").
     """
-    if string[-1] == 'd':
-        template = site.mediawiki_message('Days')
-    elif string[-1] == 'h':
+    if string[-1] == 'h':
         template = site.mediawiki_message('Hours')
+    elif string[-1] == 'd':
+        template = site.mediawiki_message('Days')
+    elif string[-1] == 'w':
+        template = site.mediawiki_message('Weeks')
+    elif string[-1] == 'y':
+        template = site.mediawiki_message('Years')
     if template:
-        exp = i18n.translate(site.code, template, int(string[:-1]))
+        exp = i18n.translate(site.code, template, {'$1': int(string[:-1])})
         return to_local_digits(exp.replace('$1', string[:-1]), site.code)
     else:
         return to_local_digits(string, site.code)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ef93cf16f0345ab858532e7a9c2063c76c554c4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Whym <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to