summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-10-29 16:48:58 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-10-29 16:48:58 +0000
commitccc49029b8d84cf3eaaa3593df6370329f7b14e1 (patch)
tree3e88f1a774a557cae46a7095073ccf6e05e7fff8 /django/template
parent269e921756371bee6d35a967bc2ffe84d1ae39eb (diff)
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
Diffstat (limited to 'django/template')
-rw-r--r--django/template/__init__.py2
-rw-r--r--django/template/context.py7
-rw-r--r--django/template/debug.py3
3 files changed, 7 insertions, 5 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index c3167861fd..74403584be 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -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)
diff --git a/django/template/context.py b/django/template/context.py
index 323c1446b2..a5b417cdd3 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -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:
diff --git a/django/template/debug.py b/django/template/debug.py
index c21fb50b3e..aa42b2b5ca 100644
--- a/django/template/debug.py
+++ b/django/template/debug.py
@@ -1,3 +1,4 @@
+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'):