Ticket #11966: 11966.patch

File 11966.patch, 2.3 KB (added by Claude Paroz, 13 years ago)

Fix + tests

  • django/utils/translation/trans_real.py

     
    443461                else:
    444462                    singular.append('%%(%s)s' % t.contents)
    445463            elif t.token_type == TOKEN_TEXT:
     464                contents = t.contents.replace('%', '%%')
    446465                if inplural:
    447                     plural.append(t.contents)
     466                    plural.append(contents)
    448467                else:
    449                     singular.append(t.contents)
     468                    singular.append(contents)
    450469        else:
    451470            if t.token_type == TOKEN_BLOCK:
    452471                imatch = inline_re.match(t.contents)
  • tests/regressiontests/i18n/commands/extraction.py

     
    3434        return self.assert_(not re.search('^msgid "%s"' % msgid, s, re.MULTILINE))
    3535
    3636
     37class TemplateExtractorTests(ExtractorTests):
     38
     39    def test_templatize(self):
     40        os.chdir(self.test_dir)
     41        management.call_command('makemessages', locale=LOCALE, verbosity=0)
     42        self.assert_(os.path.exists(self.PO_FILE))
     43        po_contents = open(self.PO_FILE, 'r').read()
     44        self.assertMsgId('I think that 100%% is more that 50%% of anything.', po_contents)
     45        self.assertMsgId('I think that 100%% is more that 50%% of %\(obj\)s.', po_contents)
     46
     47
    3748class JavascriptExtractorTests(ExtractorTests):
    3849
    3950    PO_FILE='locale/%s/LC_MESSAGES/djangojs.po' % LOCALE
  • tests/regressiontests/i18n/commands/templates/test.html

     
    11{% load i18n %}
    2 {% trans "This literal should be included." %}
    3  No newline at end of file
     2{% trans "This literal should be included." %}
     3{% blocktrans %}I think that 100% is more that 50% of anything.{% endblocktrans %}
     4{% blocktrans with 'txt' as obj %}I think that 100% is more that 50% of {{ obj }}.{% endblocktrans %}
Back to Top