jenkins-bot has submitted this change and it was merged.
Change subject: set default userinterface_lang in config
......................................................................
set default userinterface_lang in config
Allow userinterface_lang to be used elsewhere in pywikibot
Change-Id: I3abc73ec1c463352a2eed8a71817a630db0a55c4
---
M pywikibot/config2.py
M pywikibot/i18n.py
2 files changed, 7 insertions(+), 6 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index dbb1c28..60e6740 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -29,6 +29,7 @@
import stat
import sys
+from locale import getdefaultlocale
from warnings import warn
from pywikibot.tools import default_encoding
@@ -909,6 +910,9 @@
# Fix up default console_encoding
console_encoding = default_encoding(console_encoding)
+if userinterface_lang is None:
+ userinterface_lang = getdefaultlocale()[0].split('_')[0]
+
# Fix up transliteration_target
if transliteration_target == 'not set':
if sys.platform == 'win32':
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 2fff519..4d19b4f 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -28,7 +28,6 @@
import sys
import re
-import locale
import warnings
from pywikibot import Error
@@ -617,9 +616,8 @@
"""
Ask the user a question, return the user's answer.
- The prompt message is retrieved via L{twtranslate} and either uses the
- config variable 'userinterface_lang' or the default locale as the language
- code.
+ The prompt message is retrieved via L{twtranslate} and uses the
+ config variable 'userinterface_lang'.
@param twtitle: The TranslateWiki string title, in <package>-<key>
format
@param parameters: The values which will be applied to the translated text
@@ -635,8 +633,7 @@
else:
prompt = fallback_prompt
else:
- code = config.userinterface_lang or \
- locale.getdefaultlocale()[0].split('_')[0]
+ code = config.userinterface_lang
prompt = twtranslate(code, twtitle, parameters)
return pywikibot.input(prompt, password)
--
To view, visit
https://gerrit.wikimedia.org/r/203506
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3abc73ec1c463352a2eed8a71817a630db0a55c4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>