File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 187187from pywikibot .tools .threading import BoundedPoolExecutor
188188
189189
190+ ARCHIVE_HEADER = 'Q6068612' , 'Q6723402'
191+
192+
190193class ArchiveBotSiteConfigError (Error ):
191194
192195 """There is an error originated by archivebot's on-site configuration."""
@@ -391,6 +394,21 @@ def max(
391394 return ts1
392395 return max (ts1 , ts2 )
393396
397+ def get_header_template (self ) -> str :
398+ """Get localized archive header template.
399+
400+ .. versionadded:: 10.2
401+
402+ :raises NotImplementedError: Archive header is not localized
403+ """
404+ for item in ARCHIVE_HEADER :
405+ tpl = self .site .page_from_repository (item )
406+ if tpl :
407+ return f'{{{{{ tpl .title (with_ns = False )} }}}}'
408+
409+ raise NotImplementedError (
410+ 'Archive header is not localized on your site' )
411+
394412 def load_page (self ) -> None :
395413 """Load the page to be archived and break it up into threads.
396414
@@ -403,13 +421,11 @@ def load_page(self) -> None:
403421 self .header = ''
404422 self .threads = []
405423 self .archives = {}
406-
407424 try :
408425 text = self .get ()
409426 except NoPageError :
410- self .header = self .archiver .get_attr (
411- 'archiveheader' ,
412- i18n .twtranslate (self .site .code , 'archivebot-archiveheader' ))
427+ self .header = self .archiver .get_attr ('archiveheader' ,
428+ self .get_header_template ())
413429 if self .params :
414430 self .header = self .header % self .params
415431 return
You can’t perform that action at this time.
0 commit comments