Testing translation

This commit is contained in:
Götz 2019-05-16 16:01:01 +02:00
parent c1d7c2b914
commit 6aac94436e
9 changed files with 78 additions and 19 deletions

View File

@ -1,7 +1,7 @@
FROM alpine:3.9
ADD ["requirements.txt", "/requirements.txt"]
RUN apk upgrade --update && \
apk add --update python3 build-base openldap-dev python3-dev py3-psycopg2 && \
apk add --update python3 build-base openldap-dev python3-dev py3-psycopg2 gettext && \
pip3 install -r /requirements.txt && rm /requirements.txt
WORKDIR /lama
EXPOSE 80

View File

@ -1,7 +1,7 @@
FROM alpine:3.9
ADD ["requirements.txt", "/requirements.txt"]
RUN apk upgrade --update && \
apk add --update python3 build-base openldap-dev python3-dev py3-psycopg2 && \
apk add --update python3 build-base openldap-dev python3-dev py3-psycopg2 gettext && \
pip3 install -r /requirements.txt && rm /requirements.txt
WORKDIR /lama
EXPOSE 80

View File

@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
from django.utils.translation import ugettext_lazy as _
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DOMAIN = os.environ['DOMAIN']
@ -37,6 +38,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -113,19 +115,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
@ -190,6 +179,29 @@ LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'realm-home'
PASSWORD_RESET_TIMEOUT_DAYS = 3
########################################################################################################################
# Languages Config #
########################################################################################################################
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
LANGUAGES = (
('en', _('English')),
('de', _('Deutsch'))
)
USE_L10N = True
LANGUAGE_CODE = 'de'
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
########################################################################################################################
# Logging Config #
########################################################################################################################

View File

@ -1,13 +1,15 @@
from django.templatetags.static import static
from django.urls import reverse
from django.utils import translation
from jinja2 import Environment
def environment(**options):
env = Environment(**options)
env = Environment(extensions=['jinja2.ext.i18n'], **options)
# env.install_gettext_translations(translation)
env.globals.update({
'static': static,
'url': reverse,
})
return env
return env

View File

@ -0,0 +1,41 @@
# 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-05-16 13:48+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"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: account_manager/views/user_views.py:37
msgid ""
"Der angefragte Nutzer gehört einem anderen Bereich an. Nutzer können nur von "
"dem Bereich bearbeitet werden, in dem sie erstellt wurden."
msgstr ""
#: core/docker_settings.py:196
msgid "English"
msgstr ""
#: core/docker_settings.py:197
msgid "Deutsch"
msgstr ""
#: templates/base.jinja2:34
msgid "LAMa"
msgstr ""
#: templates/user/realm_user_detail.jinja2:23
msgid "Anzeigename:"
msgstr ""

View File

@ -1,4 +1,5 @@
{#{% load static %}#}
{#{% load i18n %}#}
{# ===== HTML ===== #}
<!DOCTYPE html>
<html lang="en" dir="ltr">
@ -30,7 +31,7 @@
<a class="navbar-brand" href="{{ url('realm-home') }}">
<img src="{{ static('images/lama.svg') }}" width="30" height="30" class="d-inline-block align-top"
alt="">
LAMa
{% trans "LAMa" %}
</a>
{% if request.user.is_authenticated %}

View File

@ -1,4 +1,5 @@
{% extends 'base.jinja2' %}
{#{% load i18n %}#}
{% block body %}
<div class="d-flex wrapper">

View File

@ -1,4 +1,5 @@
{% extends 'base_admin.jinja2' %}
{% load i18n %}
{% block admin_content %}
<div class="row ">
<div class="col-12 p-3">

View File

@ -1,4 +1,5 @@
{% extends 'realm/realm_detailed.jinja2' %}
{#{% load i18n %}#}
{% import 'macros/form_macros.jinja2' as mform %}
{% block detail_content %}
@ -19,7 +20,7 @@
{% if not form %}
<ul class="list-group list-group-flush w-100">
<li class="list-group-item">Ldap Domain: {{ user.user.dn }}</li>
<li class="list-group-item"> Anzeigename:
<li class="list-group-item"> {% trans "Anzeigename:" %}
{% if user.user.display_name %}
{{ user.user.display_name }}
{% else %}