Commit ccc49029 authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

Fixed #14181 -- Added a template tag and filters to allow localization to be...

Fixed #14181 -- Added a template tag and filters to allow localization to be disabled in a template. Thanks to Benjamin Wohlwend for the work on the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14395 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 269e9217
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -501,6 +501,7 @@ answer newbie questions, and generally made Django that much better:
    Joel Watts <joel@joelwatts.com>
    Lakin Wecker <lakin@structuredabstraction.com>
    Chris Wesseling <Chris.Wesseling@cwi.nl>
    Benjamin Wohlwend <piquadrat@gmail.com>
    James Wheare <django@sparemint.com>
    Mike Wiacek <mjwiacek@google.com>
    Frank Wierzbicki
+5 −3
Original line number Diff line number Diff line
{% load l10n %}
{% autoescape off %}
{% localize off %}
{% block vars %}var geodjango = {};{% for icon in icons %}
var {{ icon.varname }} = new GIcon(G_DEFAULT_ICON);
{% if icon.image %}{{ icon.varname }}.image = "{{ icon.image }}";{% endif %}
@@ -32,4 +34,4 @@ var {{ icon.varname }} = new GIcon(G_DEFAULT_ICON);
    alert("Sorry, the Google Maps API is not compatible with this browser.");
  }
}
{% endblock load %}{% endblock functions %}{% endautoescape %}
{% endblock load %}{% endblock functions %}{% endlocalize %}{% endautoescape %}
+1 −1
Original line number Diff line number Diff line
@@ -825,7 +825,7 @@ def _render_value_in_context(value, context):
    means escaping, if required, and conversion to a unicode object. If value
    is a string, it is expected to have already been translated.
    """
    value = localize(value)
    value = localize(value, use_l10n=context.use_l10n)
    value = force_unicode(value)
    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
        return escape(value)
+4 −3
Original line number Diff line number Diff line
@@ -66,8 +66,9 @@ class BaseContext(object):

class Context(BaseContext):
    "A stack container for variable context"
    def __init__(self, dict_=None, autoescape=True, current_app=None):
    def __init__(self, dict_=None, autoescape=True, current_app=None, use_l10n=None):
        self.autoescape = autoescape
        self.use_l10n = use_l10n
        self.current_app = current_app
        self.render_context = RenderContext()
        super(Context, self).__init__(dict_)
@@ -139,8 +140,8 @@ class RequestContext(Context):
    Additional processors can be specified as a list of callables
    using the "processors" keyword argument.
    """
    def __init__(self, request, dict=None, processors=None, current_app=None):
        Context.__init__(self, dict, current_app=current_app)
    def __init__(self, request, dict=None, processors=None, current_app=None, use_l10n=None):
        Context.__init__(self, dict, current_app=current_app, use_l10n=use_l10n)
        if processors is None:
            processors = ()
        else:
+2 −1
Original line number Diff line number Diff line
from django.conf import settings
from django.template import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
from django.utils.encoding import force_unicode
from django.utils.html import escape
@@ -87,7 +88,7 @@ class DebugVariableNode(VariableNode):
    def render(self, context):
        try:
            output = self.filter_expression.resolve(context)
            output = localize(output)
            output = localize(value, use_l10n=use_l10n)
            output = force_unicode(output)
        except TemplateSyntaxError, e:
            if not hasattr(e, 'source'):
Loading