diff --git a/openstack_dashboard/context_processors.py b/openstack_dashboard/context_processors.py index cb0dc04e82..804595c801 100644 --- a/openstack_dashboard/context_processors.py +++ b/openstack_dashboard/context_processors.py @@ -19,8 +19,12 @@ Context processors used by Horizon. """ +import re + from django.conf import settings +from horizon import conf + def openstack(request): """Context processor necessary for OpenStack Dashboard functionality. @@ -56,4 +60,13 @@ def openstack(request): # Adding webroot access context['WEBROOT'] = getattr(settings, "WEBROOT", "/") + # Search for external plugins and append to javascript message catalog + # internal plugins are under the openstack_dashboard domain + # so we exclude them from the js_catalog + js_catalog = ['horizon', 'openstack_dashboard'] + regex = re.compile(r'^openstack_dashboard') + all_plugins = conf.HORIZON_CONFIG['plugins'] + js_catalog.extend(p for p in all_plugins if not regex.search(p)) + context['JS_CATALOG'] = '+'.join(js_catalog) + return context diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index bc325ff93c..9c82c3cfc5 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -70,6 +70,7 @@ HORIZON_CONFIG = { 'js_files': [], 'js_spec_files': [], 'external_templates': [], + 'plugins': [] } # Set to True to allow users to upload images to glance via Horizon server. diff --git a/openstack_dashboard/templates/horizon/_script_i18n.html b/openstack_dashboard/templates/horizon/_script_i18n.html index e9aa8f49f2..8336ab281e 100644 --- a/openstack_dashboard/templates/horizon/_script_i18n.html +++ b/openstack_dashboard/templates/horizon/_script_i18n.html @@ -1,2 +1,2 @@ {% comment %} Django's JavaScript i18n Implementation {% endcomment %} - + diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py index 227334d334..6a6d16dc79 100644 --- a/openstack_dashboard/utils/settings.py +++ b/openstack_dashboard/utils/settings.py @@ -160,4 +160,12 @@ def update_dashboards(modules, horizon_config, installed_apps): horizon_config.setdefault('js_files', []).extend(js_files) horizon_config.setdefault('js_spec_files', []).extend(js_spec_files) horizon_config.setdefault('scss_files', []).extend(scss_files) + + # apps contains reference to applications declared in the enabled folder + # basically a list of applications that are internal and external plugins + # installed_apps contains reference to applications declared in settings + # such as django.contribe.*, django_pyscss, compressor, horizon, etc... + # for translation, we are only interested in the list of external plugins + # so we save the reference to it before we append to installed_apps + horizon_config.setdefault('plugins', []).extend(apps) installed_apps[0:0] = apps diff --git a/releasenotes/notes/enable-js-catalog-plugin-1885df911148247a.yaml b/releasenotes/notes/enable-js-catalog-plugin-1885df911148247a.yaml new file mode 100644 index 0000000000..4c94cc7d87 --- /dev/null +++ b/releasenotes/notes/enable-js-catalog-plugin-1885df911148247a.yaml @@ -0,0 +1,9 @@ +--- +features: + - Allow external plugins to contribute translations to the Javascript + message catalog. + +fixes: + - Provided the ability for plugins to contribute translations to the + JavaScript message catalog. Previously the horizon and openstack_dahboard + applications were hardcoded.