~dorian-kemps/unifield-web/UW-4697

« back to all changes in this revision

Viewing changes to openobject/i18n/_gettext.py

  • Committer: Jeff Allen
  • Date: 2017-01-24 15:27:50 UTC
  • mto: This revision was merged to the branch mainline in revision 4835.
  • Revision ID: jeff.allen@geneva.msf.org-20170124152750-sko25j8nuamcwyue
Fix spaces before other commits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
            with open(popath, 'rb') as pofile:
63
63
                with open(mopath, 'wb') as mofile:
64
64
                    babel.messages.mofile.write_mo(
65
 
                            mofile,
66
 
                            babel.messages.pofile.read_po(
67
 
                                    pofile, locale, domain))
 
65
                        mofile,
 
66
                        babel.messages.pofile.read_po(
 
67
                            pofile, locale, domain))
68
68
        except Exception:
69
69
            # If the parsing of the PO file broke, don't leave an empty MO
70
70
            # file hanging around
75
75
            raise
76
76
 
77
77
    return babel.support.Translations.load(
78
 
            locale_path, [locale], domain)
 
78
        locale_path, [locale], domain)
79
79
 
80
80
def _load_translations(path, locales, domain):
81
81
    if not locales:
94
94
        except SyntaxError:
95
95
            # http://babel.edgewall.org/ticket/213
96
96
            cherrypy.log.error(
97
 
                    'Could not load translation domain "%s" for'
98
 
                    ' locale "%s" in addon %s' % (
99
 
                        domain, locale, basename(path)),
100
 
                    context="i18n",
101
 
                    severity=logging.WARNING)
 
97
                'Could not load translation domain "%s" for'
 
98
                ' locale "%s" in addon %s' % (
 
99
                    domain, locale, basename(path)),
 
100
                context="i18n",
 
101
                severity=logging.WARNING)
102
102
            cherrypy.log.error(context='i18n', severity=logging.DEBUG,
103
103
                               traceback=True)
104
104
        if isinstance(translation, babel.support.Translations):
184
184
_lazy_gettext = lazify(_gettext)
185
185
 
186
186
def gettext(key, locale=None, domain=None):
187
 
    if cherrypy.request.loading_addons:
 
187
    if hasattr(cherrypy.request, "loading_addons") and cherrypy.request.loading_addons:
188
188
        return _lazy_gettext(key, locale, domain)
189
189
    return _gettext(key, locale, domain)
190
190