Ticket #18114: 18114.trans-context.diff

File 18114.trans-context.diff, 2.0 KB (added by julien, 3 years ago)

Same patch but with .diff extension

  • tests/regressiontests/i18n/commands/extraction.py

    diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py
    index fb9ca4e..87e2332 100644
    a b class BasicExtractorTests(ExtractorTests): 
    148148            self.assertTrue('msgctxt "Special blocktrans context #4"' in po_contents)
    149149            self.assertTrue("Translatable literal #8d" in po_contents)
    150150
     151    def test_template_message_context_extractor_same_string(self):
     152        """
     153        Refs #18114.
     154        """
     155        os.chdir(self.test_dir)
     156        management.call_command('makemessages', locale=LOCALE, verbosity=0)
     157        self.assertTrue(os.path.exists(self.PO_FILE))
     158        with open(self.PO_FILE, 'r') as fp:
     159            po_contents = fp.read()
     160            print po_contents
     161            # {% trans %}
     162            self.assertTrue("Translatable literal #9" in po_contents)
     163            self.assertTrue('msgctxt "Special trans context #9a"' in po_contents)
     164            self.assertTrue('msgctxt "Special trans context #9b"' in po_contents)
     165
    151166class JavascriptExtractorTests(ExtractorTests):
    152167
    153168    PO_FILE='locale/%s/LC_MESSAGES/djangojs.po' % LOCALE
  • tests/regressiontests/i18n/commands/templates/test.html

    diff --git a/tests/regressiontests/i18n/commands/templates/test.html b/tests/regressiontests/i18n/commands/templates/test.html
    index 5789346..2828282 100644
    a b continued here.{% endcomment %} 
    7777{% trans "Shouldn't double escape this sequence %% either" context "ctx1" %}
    7878{% trans "Looks like a str fmt spec %s but shouldn't be interpreted as such" %}
    7979{% trans "Looks like a str fmt spec % o but shouldn't be interpreted as such" %}
     80
     81{% trans "Translatable literal #9" %}
     82{% trans "Translatable literal #9" context "Special trans context #9a" %}
     83{% trans "Translatable literal #9" as var context "Special trans context #9b" %}
Back to Top