Xqt has uploaded a new change for review.

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

Change subject: [IMPR] Localize digits only
......................................................................

[IMPR] Localize digits only

- to_local_digits() method localizes digits inside a string.
  The digit is extracted in duration string. To increase performance
  (and may be not to localize wanted latin digits inside mediawiki messages)
  we only localize that part and replace the replacement specifier afterwards
  instead of running through the whole string.
- add a comment regarding the plural replacement inside translate method

Change-Id: If06a7d2a0f1cbe6ca3a64cabfb1108cc24b0226d
---
M scripts/archivebot.py
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/52/313352/1

diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index ecd8701..b093d1d 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -164,8 +164,11 @@
     elif string[-1] == 'y':
         template = site.mediawiki_message('Years')
     if template:
-        exp = i18n.translate(site.code, template, {'$1': int(string[:-1])})
-        return to_local_digits(exp.replace('$1', string[:-1]), site.code)
+        duration = string[:-1]
+        # replace plural variants
+        exp = i18n.translate(site.code, template, {'$1': int(duration)})
+
+        return exp.replace('$1', to_local_digits(duration, site.code))
     else:
         return to_local_digits(string, site.code)
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If06a7d2a0f1cbe6ca3a64cabfb1108cc24b0226d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

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

Reply via email to