Skip to content

Commit

Permalink
Merge branch 'master' into feature-1650-language-field
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Apr 30, 2012
2 parents d0a1386 + 62ce626 commit 1655244
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ckan/config/middleware.py
Expand Up @@ -134,8 +134,9 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
if asbool(config.get('ckan.page_cache_enabled')):
app = PageCacheMiddleware(app, config)

# Tracking add config option
app = TrackingMiddleware(app, config)
# Tracking
if asbool(config.get('ckan.tracking_enabled', 'false')):
app = TrackingMiddleware(app, config)
return app

class I18nMiddleware(object):
Expand Down
9 changes: 8 additions & 1 deletion ckan/lib/helpers.py
Expand Up @@ -154,9 +154,14 @@ def _add_i18n_to_url(url_to_amend, **kw):
return url

def lang():
''' Reurn the language code for the current locale eg `en` '''
''' Return the language code for the current locale eg `en` '''
return request.environ.get('CKAN_LANG')

def lang_native_name():
''' Return the langage name currently used in it's localised form '''
locale = get_locales_dict().get(lang())
return locale.display_name or locale.english_name

class Message(object):
"""A message returned by ``Flash.pop_messages()``.
Expand Down Expand Up @@ -800,6 +805,7 @@ def process_names(items):
'snippet',
'convert_to_dict',
'activity_div',
'lang_native_name',
# imported into ckan.lib.helpers
'literal',
'link_to',
Expand All @@ -810,5 +816,6 @@ def process_names(items):
'mail_to',
'radio',
'submit',
'asbool',
]

2 changes: 2 additions & 0 deletions ckan/templates/layout_base.html
Expand Up @@ -268,6 +268,7 @@ <h3 class="widget-title">Meta</h3>
});
</script>

<py:if test="h.asbool(config.get('ckan.tracking_enabled', 'false'))">
<script type="text/javascript">
$(function (){
// Tracking
Expand All @@ -289,6 +290,7 @@ <h3 class="widget-title">Meta</h3>
});
});
</script>
</py:if>

<py:if test="defined('optional_footer')">
${optional_footer()}
Expand Down

0 comments on commit 1655244

Please sign in to comment.