Skip to content

Commit

Permalink
translate when link contains #{langcode}
Browse files Browse the repository at this point in the history
  • Loading branch information
silviolleite committed Apr 10, 2019
1 parent 58253ee commit ee81285
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions django_translation_flags/templates/languages.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
<form action="{% url 'set_language' %}" method="post" id="setlang">
{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}">
<input type="hidden" name="language">
<input type="hidden" name="language" id="language">
</form>

<script type="text/javascript">
function set_language(language) {
$('input[name="language"]').val(language);
$('form#setlang').submit();
}
if (window.location.hash){
var hash = window.location.hash;
document.getElementById('language').value = hash.replace('#', '');
document.getElementById('setlang').submit()
}
function set_language(language) {
$('input[name="language"]').val(language);
$('form#setlang').submit();
}
</script>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='django-translation-flags',
version='1.0.4',
version='1.0.5',
packages=find_packages(),
include_package_data=True,
license='MIT License',
Expand Down

0 comments on commit ee81285

Please sign in to comment.