Support javascript translation for plugin
It's not possible for plugins to contribute translations to the javascript message catalog. Right now our files are hardcoded to allow only contributions from horizon and openstack_dashboard. This patch fixes the issue. Change-Id: Idde2fc6ac0bf7f762a595cf139ed5184dad64540 Closes-Bug: #1523930
This commit is contained in:
parent
2b6f9525a8
commit
b56d278582
@ -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
|
||||
|
@ -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.
|
||||
|
@ -1,2 +1,2 @@
|
||||
{% comment %} Django's JavaScript i18n Implementation {% endcomment %}
|
||||
<script type="text/javascript" src="{% url 'horizon:jsi18n' 'horizon+openstack_dashboard' %}"></script>
|
||||
<script type="text/javascript" src="{% url 'horizon:jsi18n' JS_CATALOG %}"></script>
|
||||
|
@ -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
|
||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user