Ticket #4695: 4695-javascript-makemessages-fix.diff
File 4695-javascript-makemessages-fix.diff, 3.1 KB (added by , 15 years ago) |
---|
-
django/core/management/commands/makemessages.py
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
a b 9 9 10 10 from django.core.management.base import CommandError, BaseCommand 11 11 12 pythonize_re = re.compile(r' \n\s*//')12 pythonize_re = re.compile(r'(?:^|\n)\s*//') 13 13 14 14 def handle_extensions(extensions=('html',)): 15 15 """ -
new file tests/regressiontests/makemessages/__init__.py
diff --git a/tests/regressiontests/makemessages/__init__.py b/tests/regressiontests/makemessages/__init__.py new file mode 100644
- + 1 # -
new file tests/regressiontests/makemessages/javascript.js
diff --git a/tests/regressiontests/makemessages/javascript.js b/tests/regressiontests/makemessages/javascript.js new file mode 100644
- + 1 // ' 2 gettext('This literal should be included.') 3 // ' 4 gettext('This one as well.') -
new file tests/regressiontests/makemessages/locale/dummy
diff --git a/tests/regressiontests/makemessages/locale/dummy b/tests/regressiontests/makemessages/locale/dummy new file mode 100644
- + 1 This file is her so version control systems don't delete/ignore the directory containing it. -
new file tests/regressiontests/makemessages/models.py
diff --git a/tests/regressiontests/makemessages/models.py b/tests/regressiontests/makemessages/models.py new file mode 100644
- + 1 # -
new file tests/regressiontests/makemessages/tests.py
diff --git a/tests/regressiontests/makemessages/tests.py b/tests/regressiontests/makemessages/tests.py new file mode 100644
- + 1 import os 2 import re 3 from django.test import TestCase 4 from django.core import management 5 6 LOCALE='de' 7 8 class ExtractorTests(TestCase): 9 10 def setUp(self): 11 self._cwd = os.getcwd() 12 self.test_dir = os.path.abspath(os.path.dirname(__file__)) 13 14 def _rmrf(self, dname): 15 if os.path.commonprefix([self.test_dir, os.path.abspath(dname)]) != self.test_dir: 16 return 17 for root, dirs, files in os.walk(dname, topdown=False): 18 for name in files: 19 os.remove(os.path.join(root, name)) 20 for name in dirs: 21 os.rmdir(os.path.join(root, name)) 22 23 def tearDown(self): 24 os.chdir(self.test_dir) 25 try: 26 self._rmrf('locale/%s' % LOCALE) 27 except OSError: 28 pass 29 os.chdir(self._cwd) 30 31 def assertMsgId(self, msgid, s): 32 return self.assert_(re.search('^msgid "%s"' % msgid, s, re.MULTILINE)) 33 34 35 class JavascriptExtractorTests(ExtractorTests): 36 37 PO_FILE='locale/%s/LC_MESSAGES/djangojs.po' % LOCALE 38 39 def test_javascript_literals(self): 40 os.chdir(self.test_dir) 41 management.call_command('makemessages', domain='djangojs', 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('This literal should be included.', po_contents) 45 self.assertMsgId('This one as well.', po_contents)