WL-603 load locale paths for themes directories
This commit is contained in:
@@ -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"))
|
||||
Reference in New Issue
Block a user