jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] Pluralize some messages ......................................................................
[FEAT] Pluralize some messages
- unlink becomes the counter for removing links and redirect - the number of changed links is the lenght of new_targets - simplify targets string by join statement, use localized comma separator. targets will be an empty string if the new_targets list is empty.
Bug: T89678 Change-Id: Iff8f577e430deffea19b6763de1f53cfa58fd39e --- M scripts/solve_disambiguation.py 1 file changed, 23 insertions(+), 19 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index fad491e..c740a58 100644 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -559,7 +559,7 @@ # TODO: break this function up into subroutines!
include = False - unlink = False + unlink_counter = 0 new_targets = [] try: text = refPage.get() @@ -769,7 +769,7 @@ elif choice in ['u', 'U']: # unlink - we remove the section if there's any text = text[:m.start()] + link_text + text[m.end():] - unlink = True + unlink_counter += 1 continue else: if len(choice) > 0 and choice[0] == 'r': @@ -843,7 +843,8 @@ pywikibot.showDiff(original_text, text) pywikibot.output(u'') # save the page - self.setSummaryMessage(disambPage, new_targets, unlink, dn) + self.setSummaryMessage(disambPage, new_targets, unlink_counter, + dn) try: refPage.put_async(text, comment=self.comment) except pywikibot.LockedPage: @@ -927,17 +928,16 @@ self.alternatives += links return True
- def setSummaryMessage(self, disambPage, new_targets=[], unlink=False, + def setSummaryMessage(self, disambPage, new_targets=[], unlink_counter=0, dn=False): # make list of new targets - targets = '' - for page_title in new_targets: - targets += u'[[%s]], ' % page_title - # remove last comma - targets = targets[:-2] + comma = self.mysite.mediawiki_message(u"comma-separator") + targets = comma.join(u'[[%s]]' % page_title + for page_title in new_targets)
if not targets: - targets = i18n.twtranslate(self.mysite, 'solve_disambiguation-unknown-page') + targets = i18n.twtranslate(self.mysite, + 'solve_disambiguation-unknown-page')
# first check whether user has customized the edit comment if (self.mysite.family.name in config.disambiguation_comment and @@ -957,27 +957,29 @@ fallback=True) % disambPage.title() elif disambPage.isRedirectPage(): # when working on redirects, there's another summary message - if unlink and not new_targets: + if unlink_counter and not new_targets: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-redirect-removed', - {'from': disambPage.title()} - ) + {'from': disambPage.title(), + 'count': unlink_counter}) elif dn and not new_targets: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-redirect-adding-dn-template', - {'from': disambPage.title()} - ) + {'from': disambPage.title()}) else: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-redirect-resolved', - {'from': disambPage.title(), 'to': targets}) + {'from': disambPage.title(), + 'to': targets, + 'count': len(new_targets)}) else: - if unlink and not new_targets: + if unlink_counter and not new_targets: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-links-removed', - {'from': disambPage.title()}) + {'from': disambPage.title(), + 'count': unlink_counter}) elif dn and not new_targets: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-adding-dn-template', @@ -985,7 +987,9 @@ else: self.comment = i18n.twtranslate( self.mysite, 'solve_disambiguation-links-resolved', - {'from': disambPage.title(), 'to': targets}) + {'from': disambPage.title(), + 'to': targets, + 'count': len(new_targets)})
def run(self): if self.main_only: