diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py index d89a0a65839..7516132cb1f 100644 --- a/ckan/lib/app_globals.py +++ b/ckan/lib/app_globals.py @@ -83,12 +83,6 @@ def set_main_css(css_file): # FIXME we should check the css file exists app_globals.main_css = str(new_css) -def set_rtl_globals(rtl_css_file, rtl_languages): - assert rtl_css_file.endswith('.css') - new_css = rtl_css_file - # FIXME we should check the css file exists - app_globals.rtl_css = str(new_css) - app_globals.rtl_languages = rtl_languages def set_app_global(key, value): ''' @@ -181,10 +175,6 @@ def get_config_value(key, default=''): main_css = get_config_value('ckan.main_css', '/base/css/main.css') set_main_css(main_css) - rtl_css_file = get_config_value('ckan.i18n.rtl_css', '/base/css/rtl.css') - rtl_languages = get_config_value('ckan.i18n.rtl_languages', 'he ar') - set_rtl_globals(rtl_css_file, rtl_languages) - if app_globals.site_logo: app_globals.header_class = 'header-image' elif not app_globals.site_description: diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 6152fde36a0..e6afa459814 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -578,7 +578,7 @@ def ckan_version(): @core_helper def lang_native_name(lang=None): - ''' Return the langage name currently used in it's localised form + ''' Return the language name currently used in it's localised form either from parameter or current environ setting''' lang = lang or lang() locale = i18n.get_locales_dict().get(lang) @@ -587,6 +587,16 @@ def lang_native_name(lang=None): return lang +@core_helper +def is_rtl_language(): + return lang() in config.get('ckan.i18n.rtl_languages', ['he', 'ar']) + + +@core_helper +def get_rtl_css(): + return config.get('ckan.i18n.rtl_css', '/base/css/rtl.css') + + class Message(object): '''A message returned by ``Flash.pop_messages()``. diff --git a/ckan/templates/base.html b/ckan/templates/base.html index 84dfc256fe9..0992ff6b1fa 100644 --- a/ckan/templates/base.html +++ b/ckan/templates/base.html @@ -67,8 +67,8 @@ #} {%- block styles %} {% resource g.main_css[6:] %} - {% if h.lang() in g.rtl_languages %} - {% resource g.rtl_css[6:] %} + {% if h.is_rtl_language() %} + {% resource h.get_rtl_css()[6:] %} {% endif %} {% endblock %}