Skip to content

Instantly share code, notes, and snippets.

@prudnitskiy
Last active August 29, 2015 14:00
Show Gist options
  • Save prudnitskiy/f4bbd42890b29b6ee928 to your computer and use it in GitHub Desktop.
Save prudnitskiy/f4bbd42890b29b6ee928 to your computer and use it in GitHub Desktop.
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}">
<!-- shows an current lang. Also you need it for HTML strict test -->
<!-- non-ajax but simple language selector -->
<ul class="list-unstyled pull-right footer-inline">
{% for lang in LANGUAGES %}
<li>
<a href="#" onclick="document.setLang{{ lang.1 }}.submit();return false;"><img src="{{MEDIA_ROOT}}img/{{ lang.0 }}.png"/>{{ lang.1 }}</a>
<form style="margin:0; padding: 0" name="setLang{{ lang.1}}" action="/i18n/setlang/" method="POST">{% csrf_token %}
<input name="next" type="hidden" value="{{ request.url }}" />
<input type="hidden" name="language" value="{{ lang.0 }}" />
</form>
</li>
{% endfor %}
</ul>
@prudnitskiy
Copy link
Author

you need to place {{LANG_CODE}}.png files to {{MEDIA_ROOT}}img/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment