コード例 #1
0
def _get_translation(domain):
    """
    Used in templates to load a different translation domain.
    """
    t = i18n.get_translation(domain)
    t.ugettext = _make_new_gettext(t.ugettext)
    t.ungettext = _make_new_ngettext(t.ungettext)
    return t
コード例 #2
0
def _get_translation(domain):
    """
    Used in templates to load a different translation domain.
    """
    t = i18n.get_translation(domain)
    t.ugettext = _make_new_gettext(t.ugettext)
    t.ungettext = _make_new_ngettext(t.ungettext)
    return t
コード例 #3
0
ファイル: __init__.py プロジェクト: ndt6896/gatco_jinja2
    def update_request_context(self, request, context):
        if 'babel' in request.app.extensions:
            babel = request.app.babel_instance
            g = _make_new_gettext(babel._get_translations(request).ugettext)
            ng = _make_new_ngettext(babel._get_translations(request).ungettext)
            context.setdefault('gettext', g)
            context.setdefault('ngettext', ng)
            context.setdefault('_', context['gettext'])

        if 'session' in request:
            context.setdefault('session', request['session'])

        context.setdefault('_', self.fake_trans)
        context.setdefault('request', request)
コード例 #4
0
ファイル: __init__.py プロジェクト: xen/sanic-jinja2
def update_request_context(request, context):
    if not request:
        return

    if "babel" in request.app.extensions:
        babel = request.app.babel_instance
        g = _make_new_gettext(babel._get_translations(request).ugettext)
        ng = _make_new_ngettext(babel._get_translations(request).ungettext)
        context.setdefault("gettext", g)
        context.setdefault("ngettext", ng)
        context.setdefault("_", context["gettext"])

    if "session" in request:
        context.setdefault("session", request["session"])

    context.setdefault("_", fake_trans)
    context.setdefault("request", request)
    context.setdefault("get_flashed_messages",
                       partial(_get_flashed_messages, request))
コード例 #5
0
def update_request_context(request, context):
    if not request:
        return

    if 'babel' in request.app.extensions:
        babel = request.app.babel_instance
        g = _make_new_gettext(babel._get_translations(request).ugettext)
        ng = _make_new_ngettext(babel._get_translations(request).ungettext)
        context.setdefault('gettext', g)
        context.setdefault('ngettext', ng)
        context.setdefault('_', context['gettext'])

    if 'session' in request:
        context.setdefault('session', request['session'])

    context.setdefault('_', fake_trans)
    context.setdefault('request', request)
    context.setdefault('get_flashed_messages',
                       partial(_get_flashed_messages, request))