From 77ab470d3803deea5c14544f7f15c4024ba46caf Mon Sep 17 00:00:00 2001 From: Keith Grootboom Date: Wed, 2 Feb 2022 09:09:31 +0200 Subject: [PATCH] feat: add PREPEND_LOCALE_PATHS configuration setting edx-platform supports COMPREHENSIVE_THEME_LOCALE_PATHS setting, which appends paths to the end of LOCALE_PATHS, but there's currently no way to add additional paths to the start of the list. We want to be able to prepend locale paths so that we can override existing translations in edx-platform. --- cms/envs/common.py | 6 ++++++ cms/envs/devstack-experimental.yml | 1 + cms/envs/production.py | 6 ++++++ lms/envs/common.py | 11 ++++++++++- lms/envs/devstack-experimental.yml | 1 + lms/envs/production.py | 7 +++++++ lms/envs/test.py | 2 ++ 7 files changed, 33 insertions(+), 1 deletion(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 4cf5cc8567d2..3ce77834383c 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2026,6 +2026,12 @@ # "COMPREHENSIVE_THEME_LOCALE_PATHS" : ["/edx/src/edx-themes/conf/locale"]. COMPREHENSIVE_THEME_LOCALE_PATHS = [] +# .. setting_name: PREPEND_LOCALE_PATHS +# .. setting_default: [] +# .. setting_description: A list of the paths to locale directories to load first e.g. +# "PREPEND_LOCALE_PATHS" : ["/edx/my-locales/"]. +PREPEND_LOCALE_PATHS = [] + # .. setting_name: DEFAULT_SITE_THEME # .. setting_default: None # .. setting_description: See LMS annotation. diff --git a/cms/envs/devstack-experimental.yml b/cms/envs/devstack-experimental.yml index 81619af2dc75..0ed383b825fc 100644 --- a/cms/envs/devstack-experimental.yml +++ b/cms/envs/devstack-experimental.yml @@ -415,6 +415,7 @@ PLATFORM_FACEBOOK_ACCOUNT: http://www.facebook.com/YourPlatformFacebookAccount PLATFORM_NAME: Your Platform Name Here PLATFORM_TWITTER_ACCOUNT: '@YourPlatformTwitterAccount' POLICY_CHANGE_GRADES_ROUTING_KEY: edx.lms.core.default +PREPEND_LOCALE_PATHS: [] PRESS_EMAIL: press@example.com PROCTORING_BACKENDS: DEFAULT: 'null' diff --git a/cms/envs/production.py b/cms/envs/production.py index 7be4ab002370..b100bbf3bd04 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -247,6 +247,12 @@ def get_env_setting(setting): # ], COMPREHENSIVE_THEME_LOCALE_PATHS = ENV_TOKENS.get('COMPREHENSIVE_THEME_LOCALE_PATHS', []) +# PREPEND_LOCALE_PATHS contain the paths to locale directories to load first e.g. +# "PREPEND_LOCALE_PATHS" : [ +# "/edx/my-locale/" +# ], +PREPEND_LOCALE_PATHS = ENV_TOKENS.get('PREPEND_LOCALE_PATHS', []) + #Timezone overrides TIME_ZONE = ENV_TOKENS.get('CELERY_TIMEZONE', CELERY_TIMEZONE) diff --git a/lms/envs/common.py b/lms/envs/common.py index 5969d7abb06d..1750bb6c2d51 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1848,7 +1848,9 @@ def _make_mako_template_dirs(settings): # Localization strings (e.g. django.po) are under these directories def _make_locale_paths(settings): # pylint: disable=missing-function-docstring - locale_paths = [settings.REPO_ROOT + '/conf/locale'] # edx-platform/conf/locale/ + locale_paths = list(settings.PREPEND_LOCALE_PATHS) + locale_paths += [settings.REPO_ROOT + '/conf/locale'] # edx-platform/conf/locale/ + if settings.ENABLE_COMPREHENSIVE_THEMING: # Add locale paths to settings for comprehensive theming. for locale_path in settings.COMPREHENSIVE_THEME_LOCALE_PATHS: @@ -4347,6 +4349,13 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring # "COMPREHENSIVE_THEME_LOCALE_PATHS" : ["/edx/src/edx-themes/conf/locale"]. COMPREHENSIVE_THEME_LOCALE_PATHS = [] + +# .. setting_name: PREPEND_LOCALE_PATHS +# .. setting_default: [] +# .. setting_description: A list of the paths to locale directories to load first e.g. +# "PREPEND_LOCALE_PATHS" : ["/edx/my-locales/"]. +PREPEND_LOCALE_PATHS = [] + # .. setting_name: DEFAULT_SITE_THEME # .. setting_default: None # .. setting_description: Theme to use when no site or site theme is defined, for example diff --git a/lms/envs/devstack-experimental.yml b/lms/envs/devstack-experimental.yml index cf8020e1fe7a..16aa92440f29 100644 --- a/lms/envs/devstack-experimental.yml +++ b/lms/envs/devstack-experimental.yml @@ -484,6 +484,7 @@ PLATFORM_FACEBOOK_ACCOUNT: http://www.facebook.com/YourPlatformFacebookAccount PLATFORM_NAME: Your Platform Name Here PLATFORM_TWITTER_ACCOUNT: '@YourPlatformTwitterAccount' POLICY_CHANGE_GRADES_ROUTING_KEY: edx.lms.core.default +PREPEND_LOCALE_PATHS: [] PRESS_EMAIL: press@example.com PROCTORING_BACKENDS: DEFAULT: 'null' diff --git a/lms/envs/production.py b/lms/envs/production.py index e40a69121159..4342da374d67 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -279,6 +279,13 @@ def get_env_setting(setting): COMPREHENSIVE_THEME_LOCALE_PATHS = ENV_TOKENS.get('COMPREHENSIVE_THEME_LOCALE_PATHS', []) +# PREPEND_LOCALE_PATHS contain the paths to locale directories to load first e.g. +# "PREPEND_LOCALE_PATHS" : [ +# "/edx/my-locale" +# ], +PREPEND_LOCALE_PATHS = ENV_TOKENS.get('PREPEND_LOCALE_PATHS', []) + + MKTG_URL_LINK_MAP.update(ENV_TOKENS.get('MKTG_URL_LINK_MAP', {})) ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS = ENV_TOKENS.get( 'ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS', diff --git a/lms/envs/test.py b/lms/envs/test.py index 0e352c6bf52a..1de33d8b8f96 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -477,6 +477,8 @@ COMPREHENSIVE_THEME_LOCALE_PATHS = [REPO_ROOT / "themes/conf/locale", ] ENABLE_COMPREHENSIVE_THEMING = True +PREPEND_LOCALE_PATHS = [] + LMS_ROOT_URL = "http://localhost:8000" # Needed for derived settings used by cms only.