summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-09-27 20:34:45 -0700
committerJulien Phalip <jphalip@gmail.com>2012-10-13 10:51:53 -0700
commitcc0478606a1d3dd804bc005a78e616550d3d0d41 (patch)
tree3d64b632127f14d7ff6beafa10df89b40d1feb06 /tests
parent4cdc416d039c7cfc04aa7bc156dd5a1c737375ed (diff)
[1.4.x] Fixed #18881 -- Made the context option in {% trans %} and {% blocktrans %} accept literals wrapped in single quotes. Thanks to lanyjie for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/i18n/commands/extraction.py15
-rw-r--r--tests/regressiontests/i18n/commands/templates/test.html5
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py
index 4eb7abc7f0..85a57e77d1 100644
--- a/tests/regressiontests/i18n/commands/extraction.py
+++ b/tests/regressiontests/i18n/commands/extraction.py
@@ -149,6 +149,21 @@ class BasicExtractorTests(ExtractorTests):
self.assertTrue('msgctxt "Special blocktrans context #4"' in po_contents)
self.assertTrue("Translatable literal #8d" in po_contents)
+ def test_context_in_single_quotes(self):
+ os.chdir(self.test_dir)
+ management.call_command('makemessages', locale=LOCALE, verbosity=0)
+ self.assertTrue(os.path.exists(self.PO_FILE))
+ with open(self.PO_FILE, 'r') as fp:
+ po_contents = fp.read()
+ # {% trans %}
+ self.assertTrue('msgctxt "Context wrapped in double quotes"' in po_contents)
+ self.assertTrue('msgctxt "Context wrapped in single quotes"' in po_contents)
+
+ # {% blocktrans %}
+ self.assertTrue('msgctxt "Special blocktrans context wrapped in double quotes"' in po_contents)
+ self.assertTrue('msgctxt "Special blocktrans context wrapped in single quotes"' in po_contents)
+
+
class JavascriptExtractorTests(ExtractorTests):
PO_FILE='locale/%s/LC_MESSAGES/djangojs.po' % LOCALE
diff --git a/tests/regressiontests/i18n/commands/templates/test.html b/tests/regressiontests/i18n/commands/templates/test.html
index 5789346984..e7d7f3ca53 100644
--- a/tests/regressiontests/i18n/commands/templates/test.html
+++ b/tests/regressiontests/i18n/commands/templates/test.html
@@ -77,3 +77,8 @@ continued here.{% endcomment %}
{% trans "Shouldn't double escape this sequence %% either" context "ctx1" %}
{% trans "Looks like a str fmt spec %s but shouldn't be interpreted as such" %}
{% trans "Looks like a str fmt spec % o but shouldn't be interpreted as such" %}
+
+{% trans "Translatable literal with context wrapped in single quotes" context 'Context wrapped in single quotes' as var %}
+{% trans "Translatable literal with context wrapped in double quotes" context "Context wrapped in double quotes" as var %}
+{% blocktrans context 'Special blocktrans context wrapped in single quotes' %}Translatable literal with context wrapped in single quotes{% endblocktrans %}
+{% blocktrans context "Special blocktrans context wrapped in double quotes" %}Translatable literal with context wrapped in double quotes{% endblocktrans %} \ No newline at end of file