Fix multilanguage
This commit is contained in:
@ -4,5 +4,5 @@ from django.utils.translation import ugettext_lazy as _
|
||||
class RugTemplateConfig(AppConfig):
|
||||
name = 'apps.RUG_template'
|
||||
label = 'RUG_template'
|
||||
verbose_name = _('RUG_template')
|
||||
verbose_name_plural = _('RUG_template')
|
||||
verbose_name = _('RUG Template')
|
||||
verbose_name_plural = _('RUG Template')
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-15 08:29+0000\n"
|
||||
"POT-Creation-Date: 2020-05-15 10:51+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -19,22 +19,22 @@ msgstr ""
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: apps/RUG_template/apps.py:7 apps/RUG_template/apps.py:8
|
||||
msgid "RUG_template"
|
||||
msgid "RUG Template"
|
||||
msgstr ""
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:21
|
||||
#: apps/RUG_template/templates/admin/base_site.html:27
|
||||
msgid "Language"
|
||||
msgstr ""
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:28
|
||||
#: apps/RUG_template/templates/admin/base_site.html:35
|
||||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:32
|
||||
#: apps/RUG_template/templates/admin/base_site.html:39
|
||||
msgid "Change password"
|
||||
msgstr ""
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:34
|
||||
#: apps/RUG_template/templates/admin/base_site.html:41
|
||||
msgid "Log out"
|
||||
msgstr ""
|
||||
|
||||
@ -137,7 +137,7 @@ msgid ""
|
||||
"the email shortly!"
|
||||
msgstr ""
|
||||
|
||||
#: apps/RUG_template/templates/registration/password_reset_email.html:6
|
||||
#: apps/RUG_template/templates/registration/password_reset_email.html:2
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You're receiving this email because you requested a password reset for your "
|
||||
|
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-15 08:29+0000\n"
|
||||
"PO-Revision-Date: 2020-05-15 10:20+0200\n"
|
||||
"POT-Creation-Date: 2020-05-15 10:51+0000\n"
|
||||
"PO-Revision-Date: 2020-05-15 12:52+0200\n"
|
||||
"Last-Translator: Joshua Rubingh <j.g.rubingh@rug.nl>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: nl\n"
|
||||
@ -19,22 +19,22 @@ msgstr ""
|
||||
"X-Generator: Poedit 2.0.6\n"
|
||||
|
||||
#: apps/RUG_template/apps.py:7 apps/RUG_template/apps.py:8
|
||||
msgid "RUG_template"
|
||||
msgstr "RUG_template"
|
||||
msgid "RUG Template"
|
||||
msgstr "RUG Template"
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:21
|
||||
#: apps/RUG_template/templates/admin/base_site.html:27
|
||||
msgid "Language"
|
||||
msgstr "Taal"
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:28
|
||||
#: apps/RUG_template/templates/admin/base_site.html:35
|
||||
msgid "Documentation"
|
||||
msgstr "Documentatie"
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:32
|
||||
#: apps/RUG_template/templates/admin/base_site.html:39
|
||||
msgid "Change password"
|
||||
msgstr "Verander wachtwoord"
|
||||
|
||||
#: apps/RUG_template/templates/admin/base_site.html:34
|
||||
#: apps/RUG_template/templates/admin/base_site.html:41
|
||||
msgid "Log out"
|
||||
msgstr "Logouit"
|
||||
|
||||
@ -145,7 +145,7 @@ msgstr ""
|
||||
"We hebben u een e-mail gestuurd met instructies voor het instellen van uw "
|
||||
"wachtwoord. U ontvangt de e-mail binnenkort!"
|
||||
|
||||
#: apps/RUG_template/templates/registration/password_reset_email.html:6
|
||||
#: apps/RUG_template/templates/registration/password_reset_email.html:2
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You're receiving this email because you requested a password reset for your "
|
||||
|
@ -1,4 +1,8 @@
|
||||
img.i18n_flag {
|
||||
width: 16px;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
form#language_form {
|
||||
display: inline;
|
||||
}
|
@ -3,25 +3,28 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
<!-- custom filter module -->
|
||||
{% load i18n_switcher %}
|
||||
|
||||
{% block extrahead %}
|
||||
<link rel="shortcut icon" href="{% static 'RUG_template/images/favicon.ico' %}" />
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'RUG_template/css/custom_admin.css' %}"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block userlinks %}
|
||||
{% comment %} Language choice. Should be put somewhere else when finale designs are done. {% endcomment %}
|
||||
<form action="{% url 'set_language' %}" method="post" id="language_form" name="language_form">
|
||||
{% csrf_token %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
{% get_available_languages as LANGUAGES %}
|
||||
{% get_language_info_list for LANGUAGES as languages %}
|
||||
{% for language in languages %}
|
||||
<a href="{{ request|switch_i18n:language.code}}">
|
||||
{% with 'RUG_template/images/flag-'|add:language.code|add:'.png' as image_static %}
|
||||
<img class="i18n_flag" src="{% static image_static %}" title="{% trans 'Language' %} {{ language.name_translated }}"/>
|
||||
{% endwith %}
|
||||
<input name="next" type="hidden" value="{% if redirect_to %}{{ redirect_to }}{% endif %}">
|
||||
<input type="hidden" name="language" id="language" value="{{LANGUAGE_CODE}}">
|
||||
{% for language in languages %}
|
||||
<a onclick="document.getElementById('language').value='{{ language.code }}'; document.forms['language_form'].submit(); return false;" href="#">
|
||||
{% with 'RUG_template/images/flag-'|add:language.code|add:'.png' as image_static %}
|
||||
<img class="i18n_flag" src="{% static image_static %}" title="{% trans 'Language' %} {{ language.name_translated }}"/>
|
||||
{% endwith %}
|
||||
</a> /
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
{% if user.is_active and user.is_staff %}
|
||||
{% url 'django-admindocs-docroot' as docsroot %}
|
||||
{% if docsroot %}
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% load i18n %}
|
||||
{% url 'password_reset_confirm' uidb64=uid token=token as reset_url%}
|
||||
{% autoescape off %}
|
||||
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.
|
||||
{% load i18n %}{% url 'password_reset_confirm' uidb64=uid token=token as reset_url%}
|
||||
{% autoescape off %}{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.
|
||||
|
||||
Please go to the following page and choose a new password:
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
from django import template
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.conf import settings
|
||||
|
||||
def switch_lang_code(path, language):
|
||||
|
||||
# Get the supported language codes
|
||||
lang_codes = [c for (c, name) in settings.LANGUAGES]
|
||||
|
||||
# Validate the inputs
|
||||
if path == '':
|
||||
raise Exception('URL path for language switch is empty')
|
||||
elif path[0] != '/':
|
||||
raise Exception('URL path for language switch does not start with "/"')
|
||||
elif language not in lang_codes:
|
||||
raise Exception('%s is not a supported language code' % language)
|
||||
|
||||
# Split the parts of the path
|
||||
parts = path.split('/')
|
||||
|
||||
# Add or substitute the new language prefix
|
||||
if parts[1] in lang_codes:
|
||||
parts[1] = language
|
||||
else:
|
||||
parts[0] = "/" + language
|
||||
|
||||
# Return the full new path
|
||||
return '/'.join(parts)
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
@stringfilter
|
||||
def switch_i18n_prefix(path, language):
|
||||
"""takes in a string path"""
|
||||
return switch_lang_code(path, language)
|
||||
|
||||
@register.filter
|
||||
def switch_i18n(request, language):
|
||||
"""takes in a request object and gets the path from it"""
|
||||
return switch_lang_code(request.get_full_path(), language)
|
Reference in New Issue
Block a user