コード例 #1
0
    def _get_translation(self):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        return translation.gettext(text)
コード例 #2
0
ファイル: exception.py プロジェクト: melmorabity/kimchi
    def _get_translation(self):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        return translation.gettext(text)
コード例 #3
0
    def _get_translation(self, args):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        for key, value in args.iteritems():
            if not isinstance(value, unicode):
                args[key] = unicode(value, 'utf-8')

        return unicode(translation.gettext(text), 'utf-8') % args
コード例 #4
0
ファイル: exception.py プロジェクト: Brainiarc7/kimchi
    def _get_translation(self, args):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        for key, value in args.iteritems():
            if not isinstance(value, unicode):
                args[key] = unicode(value, 'utf-8')

        return unicode(translation.gettext(text), 'utf-8') % args
コード例 #5
0
ファイル: exception.py プロジェクト: jayzcode/kimchi
    def __init__(self, code='', args={}):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(code, code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        for key, value in args.iteritems():
            if not isinstance(value, unicode):
                args[key] = unicode(value, 'utf-8')

        msg = unicode(translation.gettext(text), 'utf-8') % args
        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
コード例 #6
0
ファイル: exception.py プロジェクト: shaohef/kimchi
    def _get_translation(self, args):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        for key, value in args.iteritems():
            if not isinstance(value, unicode):
                try:
                    # In case the value formats itself to an ascii string.
                    args[key] = unicode(str(value), 'utf-8')
                except UnicodeEncodeError:
                    # In case the value is a KimchiException or it formats
                    # itself to a unicode string.
                    args[key] = unicode(value)

        return unicode(translation.gettext(text), 'utf-8') % args
コード例 #7
0
ファイル: exception.py プロジェクト: EmperorBeezie/kimchi
    def _get_translation(self, args):
        lang = validate_language(get_lang())
        paths = cherrypy.request.app.root.paths
        domain = cherrypy.request.app.root.domain
        messages = cherrypy.request.app.root.messages
        text = messages.get(self.code, self.code)

        try:
            translation = gettext.translation(domain, paths.mo_dir, [lang])
        except:
            translation = gettext

        for key, value in args.iteritems():
            if not isinstance(value, unicode):
                try:
                    # In case the value formats itself to an ascii string.
                    args[key] = unicode(str(value), 'utf-8')
                except UnicodeEncodeError:
                    # In case the value is a KimchiException or it formats
                    # itself to a unicode string.
                    args[key] = unicode(value)

        return unicode(translation.gettext(text), 'utf-8') % args