jenkins-bot has submitted this change and it was merged.
Change subject: Convert protect.py to i18n ......................................................................
Convert protect.py to i18n
Change-Id: I6599e89b91678ce94e05fe5e66cb3004ff5e2f9b --- M scripts/protect.py 1 file changed, 8 insertions(+), 64 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/protect.py b/scripts/protect.py index 681fe6f..0fa1ca1 100644 --- a/scripts/protect.py +++ b/scripts/protect.py @@ -48,59 +48,8 @@ #
import pywikibot -from pywikibot import catlib +from pywikibot import 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: @@ -131,7 +80,6 @@ #Loop through everything in the page generator and (un)protect it. for page in self.generator: pywikibot.output(u'Processing page %s' % page.title()) - #print self.edit, self.move#, self.create page.protect(unprotect=self.unprotect, reason=self.summary, prompt=self.prompt, edit=self.edit, move=self.move) @@ -240,32 +188,28 @@ 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) + 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 - gen = pagegenerators.ImagesPageGenerator(pywikibot.Page(mysite, - pageName)) + summary = i18n.twtranslate(mysite, 'protect-images', {'page': pageName}) + gen = pagegenerators.ImagesPageGenerator(pywikibot.Page(mysite, pageName))
if gen: pywikibot.setAction(summary)
pywikibot-commits@lists.wikimedia.org