jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1187943?usp=email )

Change subject: IMPR: use (cached) siteinfo with ChangeLangBot
......................................................................

IMPR: use (cached) siteinfo with ChangeLangBot

Change-Id: I490d8f1632c9aa6c3fc21c8cc12bf8e47ede8af7
---
M scripts/change_pagelang.py
1 file changed, 9 insertions(+), 7 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/change_pagelang.py b/scripts/change_pagelang.py
index 587fce7..f6f327b 100755
--- a/scripts/change_pagelang.py
+++ b/scripts/change_pagelang.py
@@ -23,7 +23,7 @@
 .. versionadded:: 5.1
 """
 #
-# (C) Pywikibot team, 2018-2024
+# (C) Pywikibot team, 2018-2025
 #
 # Distributed under the terms of the MIT license.
 #
@@ -80,17 +80,19 @@
         :type page: pywikibot.page.BasePage
         """
         # Current content language of the page and site language
-        parameters = {'action': 'query',
-                      'prop': 'info',
-                      'titles': page.title(),
-                      'meta': 'siteinfo'}
+        parameters = {
+            'action': 'query',
+            'prop': 'info',
+            'titles': page.title(),
+        }
         r = self.site.simple_request(**parameters)
         langcheck = r.submit()['query']
 
         currentlang = ''
         for k in langcheck['pages']:
             currentlang = langcheck['pages'][k]['pagelanguage']
-        sitelang = langcheck['general']['lang']
+
+        sitelang = self.site.siteinfo['lang']

         if self.opt.setlang == currentlang:
             pywikibot.info(
@@ -109,7 +111,7 @@
             choice = pywikibot.input_choice(
                 f'The content language for this page is already set to '
                 f'<<yellow>>{currentlang}<<default>>, which is different from '
-                f'the default ({sitelang}). Change it to'
+                f'the default ({sitelang}). Change it to '
                 f'<<green>>{self.opt.setlang}<<default>> anyway?',
                 [('Always', 'a'), ('Yes', 'y'), ('No', 'n'), ('Never', 'v')],
                 default='Y')

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1187943?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I490d8f1632c9aa6c3fc21c8cc12bf8e47ede8af7
Gerrit-Change-Number: 1187943
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to