Merge "Support javascript translation for plugin"
This commit is contained in:
commit
eb2554ad9b
@ -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