Skip to content

Commit

Permalink
fix broken url on language toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
fanjinfei committed Jun 7, 2017
1 parent 20b5cc4 commit 9ee7b9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -357,6 +357,9 @@ def full_current_url():
for sharing etc '''
return (url_for(request.environ['CKAN_CURRENT_URL'], qualified=True))

def current_url():
''' Returns current url unquoted'''
return urllib.unquote(request.environ['CKAN_CURRENT_URL'])

def lang():
''' Return the language code for the current locale eg `en` '''
Expand Down Expand Up @@ -2224,6 +2227,7 @@ def get_translated(data_dict, field):
'debug_inspect',
'dict_list_reduce',
'full_current_url',
'current_url',
'popular',
'debug_full_info_as_list',
'get_facet_title',
Expand Down
3 changes: 1 addition & 2 deletions ckan/templates/snippets/language_selector.html
@@ -1,10 +1,9 @@
{% set current_url = request.environ.CKAN_CURRENT_URL %}
{% set current_lang = request.environ.CKAN_LANG %}
<form class="form-inline form-select lang-select" action="{% url_for controller='util', action='redirect' %}" data-module="select-switch" method="POST">
<label for="field-lang-select">{{ _('Language') }}</label>
<select id="field-lang-select" name="url" data-module="autocomplete" data-module-dropdown-class="lang-dropdown" data-module-container-class="lang-container">
{% for locale in h.get_available_locales() %}
<option value="{% url_for current_url, locale=locale %}" {% if locale == current_lang %}selected="selected"{% endif %}>
<option value="{% url_for h.current_url(), locale=locale %}" {% if locale == current_lang %}selected="selected"{% endif %}>
{{ locale.display_name or locale.english_name }}
</option>
{% endfor %}
Expand Down

0 comments on commit 9ee7b9c

Please sign in to comment.