diff --git a/AKPlanning/locale/de_DE/LC_MESSAGES/django.po b/AKPlanning/locale/de_DE/LC_MESSAGES/django.po new file mode 100644 index 0000000000000000000000000000000000000000..97d38e3a7aa7be726d93dee70bfb6e84686fd7fb --- /dev/null +++ b/AKPlanning/locale/de_DE/LC_MESSAGES/django.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-10-20 08:43+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" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: settings.py:124 +msgid "German" +msgstr "Deutsch" + +#: settings.py:125 +msgid "English" +msgstr "Englisch" diff --git a/AKPlanning/settings.py b/AKPlanning/settings.py index 0c97a2482c9dd77b813a31e8be7c9dba816aa3fa..7e52bedb04f440e7cd82e99368c56934665ec27c 100644 --- a/AKPlanning/settings.py +++ b/AKPlanning/settings.py @@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os +from django.utils.translation import gettext_lazy as _ + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -108,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'en-US' TIME_ZONE = 'UTC' @@ -118,6 +120,11 @@ USE_L10N = True USE_TZ = True +LANGUAGES = [ + ('de', _('German')), + ('en', _('English')), +] + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ diff --git a/AKPlanning/urls.py b/AKPlanning/urls.py index 959681e6f5d2539136861214732661eae9d55de3..44811231eedd374ffc76e36ea8f5446b5dd0df41 100644 --- a/AKPlanning/urls.py +++ b/AKPlanning/urls.py @@ -19,4 +19,5 @@ from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('AKSubmission.urls', namespace='submit')), + path('i18n/', include('django.conf.urls.i18n')), ] diff --git a/README.md b/README.md index 48eb11ec061e117c4625175c0861b06449ad5afe..79d82835a287e61d4a79c0023e051220ea58ef0f 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Python requirements are listed in ``requirements.txt``. They can be installed wi 1. activate virtualenv ``source env/bin/activate`` 1. install python requirements ``pip install -r requirements.txt`` 1. setup necessary database tables etc. ``python manage.py migrate`` +1. prepare static files (can be omitted for dev setups) ``python manage.py collectstatic`` +1. compile translations ``python manage.py compilemessages`` 1. create a priviledged user, credentials are entered interactively on CLI ``python manage.py createsuperuser`` 1. deactivate virtualenv ``deactivate`` diff --git a/Utils/setup.sh b/Utils/setup.sh index 7e9d7a2ac0efdb278f18ffa0796fb9e127888f3e..ba0a5aa032e2793652515b0abaa3ab081b7f933b 100755 --- a/Utils/setup.sh +++ b/Utils/setup.sh @@ -18,6 +18,10 @@ pip install -r requirements.txt # Setup database python manage.py migrate +# Prepare static files and translations +python manage.py collectstatic --noinput +python manage.py compilemessages + # Create superuser # Credentials are entered interactively on CLI python manage.py createsuperuser diff --git a/Utils/update.sh b/Utils/update.sh index 240767427bb0f37243481ee45e3f583ccd3bc534..e1568893eb2d44c5bbebb761cd74c266c01d9148 100755 --- a/Utils/update.sh +++ b/Utils/update.sh @@ -24,4 +24,6 @@ if [ "$1" = "--prod" ]; then fi ./manage.py migrate +./manage.py collectstatic --noinput +./manage.py compilemessages touch AKPlanning/wsgi.py diff --git a/templates/base.html b/templates/base.html index 669bd80611e7bd53483c828ae4340198111d5c29..8ff7b8a65d101a1890b3abf30af83c54d72fad02 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,5 @@ {% load static %} +{% load i18n %} {% load bootstrap4 %} {% load fontawesome %} @@ -15,8 +16,39 @@ </head> <body> + {% block language-switcher %} + <!-- language switcher --> + <div class="container" style="margin-top:20px"> + <form action="{% url 'set_language' %}" + method="post" + class="form-inline" + name="language-form" + style="flex-direction: column;"> + {% csrf_token %} - <div class="container" style="margin-top:20px;margin-bottom: 30px;"> + <input name="next" type="hidden" value="{{ request.path }}" /> + + {% get_current_language as LANGUAGE_CODE %} + {% get_available_languages as LANGUAGES %} + {% get_language_info_list for LANGUAGES as languages %} + + <div style="align-self: end;"> + {% for language in languages %} + + <button type="submit" + class="btn {% if language.code == LANGUAGE_CODE %}btn-info{% else %}btn-outline-info{% endif %}" + name="language" + value="{{ language.code }}" + style="align-self: end;"> + {{ language.code | upper }} + </button> + {% endfor %} + </div> + </form> + </div> + {% endblock %} + + <div class="container" style="margin-top:15px;margin-bottom: 30px;"> <ol class="breadcrumb"> {% block breadcrumbs %} {% endblock %}