diff MoinMoin/i18n/__init__.py @ 3074:18cba7defa5a

i18n: avoid crashing, log errors in po files, update i18n
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 18 Sep 2007 19:48:35 +0200
parents 7fa08b9b8a90
children 8f7097ad7755
line wrap: on
line diff
--- a/MoinMoin/i18n/__init__.py	Fri Feb 22 22:11:51 2008 +0100
+++ b/MoinMoin/i18n/__init__.py	Tue Sep 18 19:48:35 2007 +0200
@@ -26,6 +26,7 @@
 debug = 0
 
 import os, gettext, glob
+import logging
 
 from MoinMoin import caching
 
@@ -139,11 +140,17 @@
         # binary files have to be opened in the binary file mode!
         self.translation = gettext.GNUTranslations(f)
         self.info = info = self.translation.info()
-        self.name = info['x-language']
-        self.ename = info['x-language-in-english']
-        self.direction = info['x-direction']
-        assert self.direction in ('ltr', 'rtl', )
-        self.maintainer = info['last-translator']
+        try:
+            self.name = info['x-language']
+            self.ename = info['x-language-in-english']
+            self.direction = info['x-direction']
+            self.maintainer = info['last-translator']
+        except KeyError, err:
+            logging.debug("%r %s" % (self.language, str(err)))
+        try:
+            assert self.direction in ('ltr', 'rtl', )
+        except (AttributeError, AssertionError), err:
+            logging.debug("%r %s" % (self.language, str(err)))
 
     def formatMarkup(self, request, text, currentStack=[]):
         """