Ticket #10004: comment-extraction-2.patch

File comment-extraction-2.patch, 2.9 KB (added by Claude Paroz, 13 years ago)

Comment extraction without tests refactoring

  • django/core/management/commands/makemessages.py

     
    196196                    'xgettext -d %s -L Perl %s --keyword=gettext_noop '
    197197                    '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 '
    198198                    '--keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 '
    199                     '--from-code UTF-8 -o - "%s"' % (
     199                    '--from-code UTF-8 --add-comments=L10n -o - "%s"' % (
    200200                        domain, wrap, os.path.join(dirpath, thefile)
    201201                    )
    202202                )
     
    240240                    '--keyword=ugettext_noop --keyword=ugettext_lazy '
    241241                    '--keyword=ungettext_lazy:1,2 --keyword=pgettext:1c,2 '
    242242                    '--keyword=npgettext:1c,2,3 --keyword=pgettext_lazy:1c,2 '
    243                     '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 -o - '
    244                     '"%s"' % (domain, wrap, os.path.join(dirpath, thefile))
     243                    '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 '
     244                    '--add-comments=L10n -o - "%s"' % (
     245                        domain, wrap, os.path.join(dirpath, thefile))
    245246                )
    246247                msgs, errors = _popen(cmd)
    247248                if errors:
  • tests/regressiontests/i18n/commands/__init__.py

     
     1from django.utils.translation import ugettext as _
     2
     3# L10n: This comment should be extracted
     4dummy1 = _("This is a translatable string.")
     5
     6# This comment should not be extracted
     7dummy2 = _("This is another translatable string.")
     8
  • tests/regressiontests/i18n/commands/extraction.py

     
    3838        return self.assert_(not re.search('^msgid %s' % msgid, s, re.MULTILINE))
    3939
    4040
    41 class TemplateExtractorTests(ExtractorTests):
     41class BasicExtractorTests(ExtractorTests):
    4242
     43    def test_comments_extractor(self):
     44        os.chdir(self.test_dir)
     45        management.call_command('makemessages', locale=LOCALE, verbosity=0)
     46        self.assert_(os.path.exists(self.PO_FILE))
     47        po_contents = open(self.PO_FILE, 'r').read()
     48        self.assert_('#. L10n: This comment should be extracted' in po_contents)
     49        self.assert_('This comment should not be extracted' not in po_contents)
     50
    4351    def test_templatize(self):
    4452        os.chdir(self.test_dir)
    4553        management.call_command('makemessages', locale=LOCALE, verbosity=0)
Back to Top