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
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)
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))
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))