Merge pull request #13492 from edx/asadiqbal08/WL-603-edx
WL-603 load locale paths for themes directories
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
26
openedx/core/djangoapps/theming/tests/test_theme_locales.py
Normal file
26
openedx/core/djangoapps/theming/tests/test_theme_locales.py
Normal file
@@ -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"))
|
||||
13
themes/conf/locale/en/LC_MESSAGES/django.po
Normal file
13
themes/conf/locale/en/LC_MESSAGES/django.po
Normal file
@@ -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"
|
||||
Reference in New Issue
Block a user