Xqt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/222878

Change subject: Print a message to run i18n_from_json when python i18n are 
missing
......................................................................

Print a message to run i18n_from_json when python i18n are missing

python i18n translation files are no longer supported but needed for compat.
But it is easy to create the needed files with a maintenance script. This
patch gives a warning to create these files if they are missing.

Change-Id: Ifd7b65f4d247c59fcea12677c4ead4d1f6567a45
---
M pywikibot/i18n.py
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat 
refs/changes/78/222878/1

diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index e62d04d..75590c4 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -335,7 +335,15 @@
         import table.
     """
     package = twtitle.split("-")[0]
-    transdict = getattr(__import__("i18n", {}, {}, [package]), package).msg
+    try:
+        transdict = getattr(__import__("i18n", {}, {}, [package]), package).msg
+    except AttributeError:
+        raise TranslationError("No translation file '%s' has been defined\n"
+                               "for TranslateWiki key %r.\n"
+                               "Please run the  maintenance script "
+                               "'i18n_from_json.py'\ninside  maintenance "
+                               "folder to generate the files."
+                               % (package, twtitle))
 
     code_needed = False
     # If a site is given instead of a code, use its language

-- 
To view, visit https://gerrit.wikimedia.org/r/222878
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd7b65f4d247c59fcea12677c4ead4d1f6567a45
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to