comparison 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
comparison
equal deleted inserted replaced
3073:78c516164e01 3074:18cba7defa5a
24 @license: GNU GPL, see COPYING for details. 24 @license: GNU GPL, see COPYING for details.
25 """ 25 """
26 debug = 0 26 debug = 0
27 27
28 import os, gettext, glob 28 import os, gettext, glob
29 import logging
29 30
30 from MoinMoin import caching 31 from MoinMoin import caching
31 32
32 # This is a global for a reason: in persistent environments all languages in 33 # This is a global for a reason: in persistent environments all languages in
33 # use will be cached; Note: you have to restart if you update language data. 34 # use will be cached; Note: you have to restart if you update language data.
137 def load_mo(self, f): 138 def load_mo(self, f):
138 """ load the mo file, setup some attributes from metadata """ 139 """ load the mo file, setup some attributes from metadata """
139 # binary files have to be opened in the binary file mode! 140 # binary files have to be opened in the binary file mode!
140 self.translation = gettext.GNUTranslations(f) 141 self.translation = gettext.GNUTranslations(f)
141 self.info = info = self.translation.info() 142 self.info = info = self.translation.info()
142 self.name = info['x-language'] 143 try:
143 self.ename = info['x-language-in-english'] 144 self.name = info['x-language']
144 self.direction = info['x-direction'] 145 self.ename = info['x-language-in-english']
145 assert self.direction in ('ltr', 'rtl', ) 146 self.direction = info['x-direction']
146 self.maintainer = info['last-translator'] 147 self.maintainer = info['last-translator']
148 except KeyError, err:
149 logging.debug("%r %s" % (self.language, str(err)))
150 try:
151 assert self.direction in ('ltr', 'rtl', )
152 except (AttributeError, AssertionError), err:
153 logging.debug("%r %s" % (self.language, str(err)))
147 154
148 def formatMarkup(self, request, text, currentStack=[]): 155 def formatMarkup(self, request, text, currentStack=[]):
149 """ 156 """
150 Formats the text passed according to wiki markup. 157 Formats the text passed according to wiki markup.
151 This raises an exception if a text needs itself to be translated, 158 This raises an exception if a text needs itself to be translated,