Sn1per has uploaded a new change for review.

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


Change subject: Convert protect.py to i18n
......................................................................

Convert protect.py to i18n

Change-Id: I6599e89b91678ce94e05fe5e66cb3004ff5e2f9b
---
M scripts/protect.py
1 file changed, 8 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/46/104046/1

diff --git a/scripts/protect.py b/scripts/protect.py
index 681fe6f..59a8f9e 100644
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -48,59 +48,8 @@
 #
 
 import pywikibot
-from pywikibot import catlib
+from pywikibot import catlib, i18n
 from pywikibot import pagegenerators
-
-# Summary messages for protecting from a category.
-msg_simple_protect = {
-    'ar': u'بوت: حماية قائمة من الملفات.',
-    'en': u'Robot: Protecting a list of files.',
-    'it': u'Bot: Protezione di una lista di pagine.',
-    'fa': u'ربات:حفاظت فهرستی از صفحه‌ها',
-    'nl': u'Bot: lijst met bestanden beveiligd',
-    'pt': u'Bot: Protegendo uma lista de artigos.',
-    'zh': u'機器人:保護清單中的所有檔案',
-}
-
-msg_protect_category = {
-    'ar': u'روبوت - حماية كل الصفحات من التصنيف %s',
-    'en': u'Robot: Protecting all pages from category %s',
-    'it': u'Bot: Protezione di tutte le pagine nella categoria %s.',
-    'fa': u'ربات:حفاظت تمام صفحه‌های رده %s',
-    'nl': u'Bot: alle pagina\'s uit categorie %s beveiligd',
-    'pt': u'Bot: Protegendo todos os artigos da categoria %s',
-    'zh': u'機器人: 保護目錄 %s 的所有頁面',
-}
-
-msg_protect_links = {
-    'ar': u'روبوت - حماية كل الصفحات الموصولة من %s',
-    'en': u'Robot: Protecting all pages linked from %s',
-    'it': u'Bot: Protezione di tutte le pagine linkate da %s.',
-    'fa': u'ربات:حفاظت تمام صفحه‌هایی که در %s پیوند شده‌اند.',
-    'nl': u'Bot: alle pagina\'s met verwijzingen vanaf %s beveiligd',
-    'pt': u'Bot: Protegendo todos os artigos ligados a %s',
-    'zh': u'機器人: 保護所有從 %s 連結的頁面',
-}
-
-msg_protect_ref = {
-    'ar': u'روبوت - حماية كل الصفحات الراجعة من %s',
-    'en': u'Robot: Protecting all pages referring from %s',
-    'it': u'Bot: Protezione di tutte le pagine con link verso %s.',
-    'fa': u'ربات:حفاظت تمام صفحه‌هایی که به %s پیوند داده‌اند',
-    'nl': u'Bot: alle pagina\'s met een verwijzing op beveiligd',
-    'pt': u'Bot: Protegendo todos os artigos afluentes a %s',
-    'zh': u'機器人: 保護所有連至 %s 的頁面',
-}
-
-msg_protect_images = {
-    'ar': u'روبوت - حماية كل الصور في الصفحة %s',
-    'en': u'Robot: Protecting all images on page %s',
-    'it': u'Bot: Protezione di tutte le immagini presenti in %s.',
-    'fa': u'ربات:حفاظت تمام تصاویر به کار رفته در %s',
-    'nl': u'Bot: alle bestanden gebruikt op %s beveiligd',
-    'pt': u'Bot: Protegendo todas as imagens do artigo %s',
-    'zh': u'機器人: 保護頁面 %s 中的所有圖條',
-}
 
 
 class ProtectionRobot:
@@ -240,30 +189,30 @@
         gen = iter([page])
     elif doCategory:
         if not summary:
-            summary = pywikibot.translate(mysite,
-                                          msg_protect_category) % pageName
+            summary = i18n.twtranslate(mysite,
+                                          'protect-category') % {'cat': 
pageName}
         ns = mysite.category_namespace()
         categoryPage = catlib.Category(mysite, ns + ':' + pageName)
         gen = pagegenerators.CategorizedPageGenerator(categoryPage,
                                                       
recurse=protectSubcategories)
     elif doLinks:
         if not summary:
-            summary = pywikibot.translate(mysite,
-                                          msg_protect_links) % pageName
+            summary = i18n.twtranslate(mysite,
+                                          'protect-links') % {'page': pageName}
         linksPage = pywikibot.Page(mysite, pageName)
         gen = pagegenerators.LinkedPageGenerator(linksPage)
     elif doRef:
         if not summary:
-            summary = pywikibot.translate(mysite, msg_protect_ref) % pageName
+            summary = i18n.twtranslate(mysite, 'protect-ref') % {'page': 
pageName}
         refPage = pywikibot.Page(mysite, pageName)
         gen = pagegenerators.ReferringPageGenerator(refPage)
     elif fileName:
         if not summary:
-            summary = pywikibot.translate(mysite, msg_simple_protect)
+            summary = i18n.twtranslate(mysite, 'protect-simple')
         gen = pagegenerators.TextfilePageGenerator(fileName)
     elif doImages:
         if not summary:
-            summary = pywikibot.translate(mysite, msg_protect_images) % 
pageName
+            summary = i18n.twtranslate(mysite, 'protect-images') % {'page': 
pageName}
         gen = pagegenerators.ImagesPageGenerator(pywikibot.Page(mysite,
                                                                 pageName))
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6599e89b91678ce94e05fe5e66cb3004ff5e2f9b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Sn1per <geof...@gmail.com>

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

Reply via email to