Monkey patch .gettext with .ugettext if possible (we use python 2.x)

This commit is contained in:
Daniel Neuhäuser 2010-08-15 12:22:43 +02:00
parent 817a7bb2c8
commit 532a0de601
2 changed files with 3 additions and 1 deletions

View File

@ -209,7 +209,7 @@ class Locale(Transform):
for node, msg in extract_messages(self.document): for node, msg in extract_messages(self.document):
ctx = node.parent ctx = node.parent
patch = new_document(source, settings) patch = new_document(source, settings)
msgstr = catalog.ugettext(msg) msgstr = catalog.gettext(msg)
#XXX add marker to untranslated parts #XXX add marker to untranslated parts
if not msgstr or msgstr == msg: # as-of-yet untranslated if not msgstr or msgstr == msg: # as-of-yet untranslated
continue continue

View File

@ -217,4 +217,6 @@ def init(locale_dirs, language, catalog='sphinx'):
translator = gettext.NullTranslations() translator = gettext.NullTranslations()
has_translation = False has_translation = False
translators[catalog] = translator translators[catalog] = translator
if hasattr(translator, 'ugettext'):
translator.gettext = translator.ugettext
return translator, has_translation return translator, has_translation