def process_request(self, request):
     initialize(self.is_turned_on(request))
     if is_enabled():
         active_language = get_language()
         trans_real._active.clear()
         trans_real._translations.clear()
         gettext._translations.clear()
         activate(active_language)
    def process_response(self, request, response):
        if (is_enabled() and
            response['Content-Type'].split(';')[0] in _HTML_TYPES):

            jquery_found = find_jquery_link(response.content)
            response.content = insert_jquery_link(response.content,
                                                  not jquery_found)
            response.content = render_translations(
                response.content.decode('UTF-8')).encode('UTF-8')
            if response.get('Content-Length', None):
                response['Content-Length'] = len(response.content)

        return response
def ugettext(message):
    translation = django_ugettext(message)
    if not is_enabled():
        return translation
    return mark_translation(message, u'', translation)
 def new_render(self, context):
     if not is_enabled():
         return old_render(context)
     singular, plural = get_msgid(context)
     return mark_translation(singular, plural, old_render(context))
def ungettext(singular, plural, number):
    translation = django_ungettext(singular, plural, number)
    if not is_enabled():
        return translation
    return mark_translation(singular, plural, translation)