jenkins-bot has submitted this change and it was merged.
Change subject: [i18n] localize comma and semicolon separator ......................................................................
[i18n] localize comma and semicolon separator
- use mediawiki_message() for to localize comma and semicolon separators - use Page.title(asLink=True) for formatting - join generators if possible - remove old /dev/null setting - dont re-use variable 'cat' in category.py loop
Change-Id: I96d9f784e0a7880ce4931b9450b2a0d397a1332d --- M scripts/archivebot.py M scripts/category.py M scripts/interwiki.py M scripts/replace.py 4 files changed, 36 insertions(+), 37 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Xqt: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py index 6563a83..021ac22 100644 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -428,8 +428,8 @@ def attr2text(self): return '{{%s\n%s\n}}' \ % (self.tpl.title(withNamespace=(self.tpl.namespace() != 10)), - '\n'.join(['|%s = %s' % (a, self.get_attr(a)) - for a in self.saveables()])) + '\n'.join('|%s = %s' % (a, self.get_attr(a)) + for a in self.saveables()))
def key_ok(self): s = md5() @@ -455,7 +455,7 @@
If it doesn't exist yet, create it. If archive name is an empty string (or None), - discard the thread (/dev/null). + discard the thread. Also checks for security violations.
""" @@ -544,12 +544,11 @@ return self.page.header = rx.sub(self.attr2text(), self.page.header) self.comment_params['count'] = self.archived_threads + comma = self.site.mediawiki_message('comma-separator') self.comment_params['archives'] \ - = ', '.join(['[[' + a.title() + ']]' - for a in self.archives.values()]) - if not self.comment_params['archives']: - self.comment_params['archives'] = '/dev/null' - self.comment_params['why'] = ', '.join(whys) + = comma.join(a.title(asLink=True) + for a in self.archives.values()) + self.comment_params['why'] = comma.join(whys) comment = i18n.twntranslate(self.site.code, 'archivebot-page-summary', self.comment_params) diff --git a/scripts/category.py b/scripts/category.py index 1db584f..b1f51a5 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -630,10 +630,10 @@ # Some preparing pywikibot.output('Moving text from %s to %s.' % ( self.oldcat.title(), self.newcat.title())) - authors = ', '.join(self.oldcat.contributingUsers()) + comma = self.site.mediawiki_message('comma-separator') + authors = comma.join(self.oldcat.contributingUsers()) template_vars = (self.oldcat.title(), authors) - comment = i18n.twtranslate(self.site, - 'category-renamed') % template_vars + comment = i18n.twtranslate(self.site, 'category-renamed', template_vars) self.newcat.text = self.oldcat.text # Replace stuff REGEX = r"<!--BEGIN CFD TEMPLATE-->.*?<!--END CFD TEMPLATE-->" @@ -995,19 +995,19 @@ if currentDepth < self.maxDepth // 2: # noisy dots pywikibot.output('.', newline=False) - # Find out which other cats are supercats of the current cat - supercat_names = [] - for cat in self.catDB.getSupercats(cat): - # create a list of wiki links to the supercategories - if cat != parent: - supercat_names.append(cat.title(asLink=True, - textlink=True, - withNamespace=False)) + # Create a list of other cats which are supercats of the current cat + supercat_names = [super_cat.title(asLink=True, + textlink=True, + withNamespace=False) + for super_cat in self.catDB.getSupercats(cat) + if super_cat != parent] + if supercat_names: # print this list, separated with commas, using translations - # given in also_in_cats + # given in 'category-also-in' + comma = self.site.mediawiki_message('comma-separator') result += ' ' + i18n.twtranslate(self.site, 'category-also-in', - {'alsocat': ', '.join( + {'alsocat': comma.join( supercat_names)}) del supercat_names result += '\n' diff --git a/scripts/interwiki.py b/scripts/interwiki.py index becd5de..41b4a67 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -2397,21 +2397,20 @@ useFrom = False
if adding or removing or modifying: - # Version info marks bots without unicode error - # This also prevents abuse filter blocking on de-wiki - - # if not pywikibot.unicode_error: - # mcomment += u'r%s) (' % sys.version.split()[0] - mcomment += globalvar.summary + comma = insite.mediawiki_message('comma-separator')
- changes = {'adding': ', '.join([fmt(new, x) for x in adding]), - 'removing': ', '.join([fmt(old, x) for x in removing]), - 'modifying': ', '.join([fmt(new, x) for x in modifying]), + changes = {'adding': comma.join(fmt(new, x) for x in adding), + 'removing': comma.join(fmt(old, x) for x in removing), + 'modifying': comma.join(fmt(new, x) for x in modifying), 'from': u'' if not useFrom else old[modifying[0]]} + en_changes = {'adding': ', '.join(fmt(new, x) for x in adding), + 'removing': ', '.join(fmt(old, x) for x in removing), + 'modifying': ', '.join(fmt(new, x) for x in modifying), + 'from': u'' if not useFrom else old[modifying[0]]}
- mcomment += i18n.twtranslate(insite.lang, commentname) % changes - mods = i18n.twtranslate('en', commentname) % changes + mcomment += i18n.twtranslate(insite.lang, commentname, changes) + mods = i18n.twtranslate('en', commentname, en_changes)
return mods, mcomment, adding, removing, modifying
diff --git a/scripts/replace.py b/scripts/replace.py index cbc9a43..efbb9c6 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -517,15 +517,16 @@ if self.summary: summary_messages.insert(0, self.summary) else: - default_summary = ', '.join( + comma = self.site.mediawiki_message('comma-separator') + default_summary = comma.join( u'-{0} +{1}'.format(*default_summary) for default_summary in default_summaries) summary_messages.insert(0, i18n.twtranslate( - pywikibot.Site(), 'replace-replacing', - {'description': - u' ({0})'.format(default_summary)} + self.site, 'replace-replacing', + {'description': u' ({0})'.format(default_summary)} )) - return u'; '.join(summary_messages) + semicolon = self.site.mediawiki_message('semicolon-separator') + return semicolon.join(summary_messages)
def run(self): """Start the bot."""
pywikibot-commits@lists.wikimedia.org