summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorCraig Blaszczyk <masterjakul@gmail.com>2012-06-07 11:23:25 +0200
committerRamiro Morales <cramm0@gmail.com>2013-01-17 00:53:17 -0300
commit6158c79dbef832bc8530107ab2d34f04a04471da (patch)
treec2821007f137fd51e55f955a0f0af7a368876f96 /tests/regressiontests
parent295650bd01bc4d68e918b483a2366a092dae6636 (diff)
Made (make|compile)messages commands accept multiple locales at once.
Thanks Craig Blaszczyk for the initial patch. Refs #17181.
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/i18n/commands/compilation.py31
-rw-r--r--tests/regressiontests/i18n/commands/extraction.py27
-rw-r--r--tests/regressiontests/i18n/commands/locale/hr/LC_MESSAGES/django.po71
-rw-r--r--tests/regressiontests/i18n/tests.py5
4 files changed, 132 insertions, 2 deletions
diff --git a/tests/regressiontests/i18n/commands/compilation.py b/tests/regressiontests/i18n/commands/compilation.py
index 492b0d22a3..c15b95eb0e 100644
--- a/tests/regressiontests/i18n/commands/compilation.py
+++ b/tests/regressiontests/i18n/commands/compilation.py
@@ -68,3 +68,34 @@ class PercentRenderingTests(MessageCompilationTests):
t = Template('{% load i18n %}{% trans "Completed 50%% of all the tasks" %}')
rendered = t.render(Context({}))
self.assertEqual(rendered, 'IT translation of Completed 50%% of all the tasks')
+
+
+@override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),))
+class MultipleLocaleCompilationTests(MessageCompilationTests):
+ MO_FILE_HR = None
+ MO_FILE_FR = None
+
+ def setUp(self):
+ super(MultipleLocaleCompilationTests, self).setUp()
+ self.localedir = os.path.join(test_dir, 'locale')
+ self.MO_FILE_HR = os.path.join(self.localedir, 'hr/LC_MESSAGES/django.mo')
+ self.MO_FILE_FR = os.path.join(self.localedir, 'fr/LC_MESSAGES/django.mo')
+ self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_HR))
+ self.addCleanup(self._rmfile, os.path.join(self.localedir, self.MO_FILE_FR))
+
+ def _rmfile(self, filepath):
+ if os.path.exists(filepath):
+ os.remove(filepath)
+
+ def test_one_locale(self):
+ os.chdir(test_dir)
+ call_command('compilemessages', locale='hr', stderr=StringIO())
+
+ self.assertTrue(os.path.exists(self.MO_FILE_HR))
+
+ def test_multiple_locales(self):
+ os.chdir(test_dir)
+ call_command('compilemessages', locale=['hr', 'fr'], stderr=StringIO())
+
+ self.assertTrue(os.path.exists(self.MO_FILE_HR))
+ self.assertTrue(os.path.exists(self.MO_FILE_FR))
diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py
index 575f23cfee..1d6a72d725 100644
--- a/tests/regressiontests/i18n/commands/extraction.py
+++ b/tests/regressiontests/i18n/commands/extraction.py
@@ -327,3 +327,30 @@ class KeepPotFileExtractorTests(ExtractorTests):
management.call_command('makemessages', locale=LOCALE, verbosity=0,
keep_pot=True)
self.assertTrue(os.path.exists(self.POT_FILE))
+
+
+class MultipleLocaleExtractionTests(ExtractorTests):
+ PO_FILE_PT = 'locale/pt/LC_MESSAGES/django.po'
+ PO_FILE_DE = 'locale/de/LC_MESSAGES/django.po'
+ LOCALES = ['pt', 'de', 'ch']
+
+ def tearDown(self):
+ os.chdir(self.test_dir)
+ for locale in self.LOCALES:
+ try:
+ self._rmrf('locale/%s' % locale)
+ except OSError:
+ pass
+ os.chdir(self._cwd)
+
+ def test_multiple_locales(self):
+ os.chdir(self.test_dir)
+ management.call_command('makemessages', locale=['pt','de'], verbosity=0)
+ self.assertTrue(os.path.exists(self.PO_FILE_PT))
+ self.assertTrue(os.path.exists(self.PO_FILE_DE))
+
+ def test_comma_separated_locales(self):
+ os.chdir(self.test_dir)
+ management.call_command('makemessages', locale='pt,de,ch', verbosity=0)
+ self.assertTrue(os.path.exists(self.PO_FILE_PT))
+ self.assertTrue(os.path.exists(self.PO_FILE_DE))
diff --git a/tests/regressiontests/i18n/commands/locale/hr/LC_MESSAGES/django.po b/tests/regressiontests/i18n/commands/locale/hr/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..663ca0000f
--- /dev/null
+++ b/tests/regressiontests/i18n/commands/locale/hr/LC_MESSAGES/django.po
@@ -0,0 +1,71 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-12-04 04:59-0600\n"
+"PO-Revision-Date: 2013-01-16 22:53-0300\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+
+#. Translators: Django template comment for translators
+#: templates/test.html:9
+#, python-format
+msgid "I think that 100%% is more that 50%% of anything."
+msgstr ""
+
+#: templates/test.html:10
+#, python-format
+msgid "I think that 100%% is more that 50%% of %(obj)s."
+msgstr ""
+
+#: templates/test.html:70
+#, python-format
+msgid "Literal with a percent symbol at the end %%"
+msgstr ""
+
+#: templates/test.html:71
+#, python-format
+msgid "Literal with a percent %% symbol in the middle"
+msgstr ""
+
+#: templates/test.html:72
+#, python-format
+msgid "Completed 50%% of all the tasks"
+msgstr ""
+
+#: templates/test.html:73
+#, python-format
+msgctxt "ctx0"
+msgid "Completed 99%% of all the tasks"
+msgstr ""
+
+#: templates/test.html:74
+#, python-format
+msgid "Shouldn't double escape this sequence: %% (two percent signs)"
+msgstr ""
+
+#: templates/test.html:75
+#, python-format
+msgctxt "ctx1"
+msgid "Shouldn't double escape this sequence %% either"
+msgstr ""
+
+#: templates/test.html:76
+#, python-format
+msgid "Looks like a str fmt spec %%s but shouldn't be interpreted as such"
+msgstr "Translation of the above string"
+
+#: templates/test.html:77
+#, python-format
+msgid "Looks like a str fmt spec %% o but shouldn't be interpreted as such"
+msgstr "Translation contains %% for the above string"
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 5d789b4acb..d9843c228a 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -32,10 +32,11 @@ if can_run_extraction_tests:
from .commands.extraction import (ExtractorTests, BasicExtractorTests,
JavascriptExtractorTests, IgnoredExtractorTests, SymlinkExtractorTests,
CopyPluralFormsExtractorTests, NoWrapExtractorTests,
- NoLocationExtractorTests, KeepPotFileExtractorTests)
+ NoLocationExtractorTests, KeepPotFileExtractorTests,
+ MultipleLocaleExtractionTests)
if can_run_compilation_tests:
from .commands.compilation import (PoFileTests, PoFileContentsTests,
- PercentRenderingTests)
+ PercentRenderingTests, MultipleLocaleCompilationTests)
from .contenttypes.tests import ContentTypeTests
from .forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm
from .models import Company, TestModel