Justincheng12345 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78943
Change subject: Allow variant choosing of i18n.
......................................................................
Allow variant choosing of i18n.
Change-Id: I06cfaf5557c07ac0914e080cee2645872f5b8068
---
M pywikibot/config2.py
M pywikibot/i18n.py
2 files changed, 10 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/43/78943/1
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index d6ad0bd..a3edc63 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -588,6 +588,12 @@
# This should be more accurate than our current regex, but is currently opt-in.
use_mwparserfromhell = False
+# To enable users to choose to commit their changes with a comment that use
+# variant when that language has variants. For example when site.lang = 'zh'
+# which the use may would like to use 'zh-hk'
+# In user-config, this should be like usevariant['zh'] = 'zh-hk'
+usevariant = {}
+
# End of configuration section
# ============================
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index bc9f480..1652204 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -336,6 +336,10 @@
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
lang = code.lang
+ if config.usevariant:
+ for var in config.usevariant:
+ if var == lang:
+ lang = config.usevariant[var]
# check whether we need the language code back
elif type(code) == list:
lang = code.pop()
--
To view, visit https://gerrit.wikimedia.org/r/78943
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06cfaf5557c07ac0914e080cee2645872f5b8068
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Justincheng12345 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits