Skip to content
Snippets Groups Projects
Unverified Commit 53813eeb authored by adeel khan's avatar adeel khan Committed by GitHub
Browse files

Merge pull request #22968 from edx/adeel/prod_960_automate_js_18n_compilation

Adds compilejs task to paver.
parents 5a2d98b1 9d6fd1d3
No related branches found
Tags release-2021-06-22-17.43
No related merge requests found
......@@ -51,6 +51,7 @@ pull_translations: ## pull translations from Transifex
git clean -fdX conf/locale/rtl
git clean -fdX conf/locale/eo
i18n_tool validate
paver i18n_compilejs
detect_changed_source_translations: ## check if translation files are up-to-date
i18n_tool changed
......
......@@ -92,6 +92,22 @@ def i18n_dummy(options):
# Need to then compile the new dummy strings
sh("i18n_tool generate")
@task
@needs(
"pavelib.prereqs.install_prereqs",
"pavelib.i18n.i18n_validate_gettext",
)
@cmdopts([
("settings=", "s", "The settings to use (defaults to devstack)"),
])
@timed
def i18n_compilejs(options):
"""
Generating djangojs.mo file using django-statici18n
"""
settings = options.get('settings', DEFAULT_SETTINGS)
# Generate static i18n JS files.
for system in ['lms', 'cms']:
sh(django_cmd(system, settings, 'compilejsi18n'))
......
......@@ -163,6 +163,34 @@ class TestI18nDummy(PaverTestCase):
u'i18n_tool extract',
u'i18n_tool dummy',
u'i18n_tool generate',
]
)
class TestI18nCompileJS(PaverTestCase):
"""
Test the Paver i18n_compilejs task.
"""
def setUp(self):
super(TestI18nCompileJS, self).setUp()
# Mock the paver @needs decorator for i18n_extract
self._mock_paver_needs = patch.object(pavelib.i18n.i18n_extract, 'needs').start()
self._mock_paver_needs.return_value = 0
# Cleanup mocks
self.addCleanup(self._mock_paver_needs.stop)
def test_i18n_compilejs(self):
"""
Test the "i18n_compilejs" task.
"""
self.reset_task_messages()
os.environ['NO_PREREQ_INSTALL'] = "true"
call_task('pavelib.i18n.i18n_compilejs', options={"settings": Env.TEST_SETTINGS})
self.assertEqual(
self.task_messages,
[
u'python manage.py lms --settings={} compilejsi18n'.format(Env.TEST_SETTINGS),
u'python manage.py cms --settings={} compilejsi18n'.format(Env.TEST_SETTINGS),
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment