From 009694db63b8c3d30dc4f07110169c4bf48a3de6 Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Sat, 1 Oct 2005 16:35:20 +0000 Subject: [PATCH] i18n: i18n string resolution now does string interpolation against the context, too git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@761 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/template.py | 2 +- tests/othertests/templates.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/django/core/template.py b/django/core/template.py index df0e1083c4..d23e3f6a71 100644 --- a/django/core/template.py +++ b/django/core/template.py @@ -418,7 +418,7 @@ def resolve_variable(path, context): if path[0] in ('"', "'") and path[0] == path[-1]: current = path[1:-1] elif path.startswith('_(') and path.endswith(')') and path[2] in ("'", '"') and path[-2] == path[2]: - current = _(path[3:-2]) + current = _(path[3:-2]) % context else: current = context bits = path.split(VARIABLE_ATTRIBUTE_SEPARATOR) diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index 509aa29a3e..9b70230537 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -244,6 +244,9 @@ TEMPLATE_TESTS = { # translation of string without i18n tag 'i18n11': ('{{ _("blah") }}', {}, "blah"), + + # translation of string without i18n tag but with interpolation + 'i18n12': ('{{ _("blah%(anton)s") }}', {'anton': 'blubb'}, "blahblubb"), } # This replaces the standard template_loader.