diff --git a/cms/envs/aws.py b/cms/envs/aws.py index 65f0903a99..17c96c490b 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -215,6 +215,13 @@ if ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR', None): COMPREHENSIVE_THEME_DIR = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR') COMPREHENSIVE_THEME_DIRS = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIRS', COMPREHENSIVE_THEME_DIRS) or [] + +# COMPREHENSIVE_THEME_LOCALE_PATHS contain the paths to themes locale directories e.g. +# "COMPREHENSIVE_THEME_LOCALE_PATHS" : [ +# "/edx/src/edx-themes/conf/locale" +# ], +COMPREHENSIVE_THEME_LOCALE_PATHS = ENV_TOKENS.get('COMPREHENSIVE_THEME_LOCALE_PATHS', []) + DEFAULT_SITE_THEME = ENV_TOKENS.get('DEFAULT_SITE_THEME', DEFAULT_SITE_THEME) ENABLE_COMPREHENSIVE_THEMING = ENV_TOKENS.get('ENABLE_COMPREHENSIVE_THEMING', ENABLE_COMPREHENSIVE_THEMING) diff --git a/cms/envs/common.py b/cms/envs/common.py index ce5c1ca62c..f8572177bd 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1190,3 +1190,6 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id' ############## Settings for Studio Context Sensitive Help ############## DOC_LINK_BASE_URL = None + +# Theme directory locale paths +COMPREHENSIVE_THEME_LOCALE_PATHS = [] diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 9f71896d22..bc52bb4ed6 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -274,6 +274,13 @@ if ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR', None): COMPREHENSIVE_THEME_DIR = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIR') COMPREHENSIVE_THEME_DIRS = ENV_TOKENS.get('COMPREHENSIVE_THEME_DIRS', COMPREHENSIVE_THEME_DIRS) or [] + +# COMPREHENSIVE_THEME_LOCALE_PATHS contain the paths to themes locale directories e.g. +# "COMPREHENSIVE_THEME_LOCALE_PATHS" : [ +# "/edx/src/edx-themes/conf/locale" +# ], +COMPREHENSIVE_THEME_LOCALE_PATHS = ENV_TOKENS.get('COMPREHENSIVE_THEME_LOCALE_PATHS', []) + DEFAULT_SITE_THEME = ENV_TOKENS.get('DEFAULT_SITE_THEME', DEFAULT_SITE_THEME) ENABLE_COMPREHENSIVE_THEMING = ENV_TOKENS.get('ENABLE_COMPREHENSIVE_THEMING', ENABLE_COMPREHENSIVE_THEMING) diff --git a/lms/envs/common.py b/lms/envs/common.py index 1acd1da91a..0dc4b47b0a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2950,6 +2950,9 @@ SITE_ID = 1 # dir containing all themes COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes"] +# Theme directory locale paths +COMPREHENSIVE_THEME_LOCALE_PATHS = [] + # Theme to use when no site or site theme is defined, # set to None if you want to use openedx theme DEFAULT_SITE_THEME = None diff --git a/lms/envs/test.py b/lms/envs/test.py index 0afd3d6780..def7a840bc 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -588,6 +588,7 @@ OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' COURSE_CATALOG_API_URL = 'https://catalog.example.com/api/v1' COMPREHENSIVE_THEME_DIRS = [REPO_ROOT / "themes", REPO_ROOT / "common/test"] +COMPREHENSIVE_THEME_LOCALE_PATHS = [REPO_ROOT / "themes/conf/locale", ] LMS_ROOT_URL = "http://localhost:8000" diff --git a/openedx/core/djangoapps/theming/core.py b/openedx/core/djangoapps/theming/core.py index 27865f2efc..5004686d50 100644 --- a/openedx/core/djangoapps/theming/core.py +++ b/openedx/core/djangoapps/theming/core.py @@ -2,6 +2,7 @@ Core logic for Comprehensive Theming. """ from django.conf import settings +from path import Path as path from .helpers import get_themes @@ -21,9 +22,16 @@ def enable_theming(): ) for theme in get_themes(): - locale_dir = theme.path / "conf" / "locale" - if locale_dir.isdir(): - settings.LOCALE_PATHS = (locale_dir, ) + settings.LOCALE_PATHS - if theme.themes_base_dir not in settings.MAKO_TEMPLATES['main']: settings.MAKO_TEMPLATES['main'].insert(0, theme.themes_base_dir) + + _add_theming_locales() + + +def _add_theming_locales(): + """ + Add locale paths to settings for comprehensive theming. + """ + theme_locale_paths = settings.COMPREHENSIVE_THEME_LOCALE_PATHS + for locale_path in theme_locale_paths: + settings.LOCALE_PATHS += (path(locale_path), ) # pylint: disable=no-member diff --git a/openedx/core/djangoapps/theming/tests/test_theme_locales.py b/openedx/core/djangoapps/theming/tests/test_theme_locales.py new file mode 100644 index 0000000000..f577ef23bd --- /dev/null +++ b/openedx/core/djangoapps/theming/tests/test_theme_locales.py @@ -0,0 +1,26 @@ +""" +Tests for Themeing locales +""" + +import unittest +from django.conf import settings +from django.test import TestCase +import os + + +class TestComprehensiveThemeLocale(TestCase): + """ + Test Comprehensive Theme Locales + """ + @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') + def test_theme_locale_path_in_settings(self): + """ + test comprehensive theming paths in settings. + """ + self.assertIn(settings.REPO_ROOT / 'themes/conf/locale', settings.LOCALE_PATHS) # pylint: disable=no-member + + def test_theme_locale_path_exist(self): + """ + test comprehensive theming directory path exist. + """ + self.assertTrue(os.path.exists(settings.REPO_ROOT / "themes/conf/locale")) diff --git a/themes/conf/locale/en/LC_MESSAGES/django.po b/themes/conf/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000000..e5062169fe --- /dev/null +++ b/themes/conf/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,13 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2016-09-01 10:46+0500\n" +"PO-Revision-Date: 2016-09-01 10:48+0500\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: en\n"