translation (not working actually)

This commit is contained in:
Benni Bärmann 2022-01-25 11:21:57 +01:00
parent b1b68ae68d
commit aec2fdac16
4 changed files with 42 additions and 5 deletions

View File

@ -58,6 +58,7 @@ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -119,7 +120,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/ # https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us' # LANGUAGE_CODE = 'de'
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'

View File

@ -14,6 +14,9 @@
{% load socialaccount %} {% load socialaccount %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
{% block content %} {% block content %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<center> <center>
<style> <style>
ul > li { ul > li {
@ -34,7 +37,7 @@
{% endif %} {% endif %}
<h1> <h1>
E (V A) - Eintritt, (Veränderung, Austritt)<p> E (V A) - Eintritt, (Veränderung, Austritt)<p>
</h1>Du bist eingeloggt als {{ user.email }} </h1>{% translate "Du bist eingeloggt als" %} {{ user.email }}
<h2> <h2>
<p>Schritt {{ wizard.steps.step1 }} von {{ wizard.steps.count }}</p> <p>Schritt {{ wizard.steps.step1 }} von {{ wizard.steps.count }}</p>
<p>{% if wizard.steps.step1 == 1 %} <p>{% if wizard.steps.step1 == 1 %}

View File

@ -14,12 +14,17 @@ class LoginTestCase(TestCase):
self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe') self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe')
self.client.login(username='vladimir', password='reiherzehe') self.client.login(username='vladimir', password='reiherzehe')
self.response = self.client.get('/') self.response = self.client.get('/')
with translation.override('en'):
self.response_en = self.client.get('/')
def testLogin(self): def testLogin(self):
self.assertContains(self.response, 'Du bist eingeloggt als vladimir@reiherzehe.com', status_code=200) self.assertContains(self.response, 'Du bist eingeloggt als vladimir@reiherzehe.com', status_code=200)
self.assertContains(self.response_en, 'You are logged in as vladimir@reiherzehe.com', status_code=200) # self.client.cookies.load({settings.LANGUAGE_COOKIE_NAME: 'en'})
#with translation.override('en'):
response_en = self.client.get('/', HTTP_ACCEPT_LANGUAGE='en-us')
#self.response_en = self.client.get('/')
print('START')
print (response_en.content)
print('END')
self.assertContains(response_en, 'You are logged in as vladimir@reiherzehe.com', status_code=200)
def testDebugWarning(self): def testDebugWarning(self):
with self.settings(DEBUG=True): with self.settings(DEBUG=True):

View File

@ -0,0 +1,28 @@
# 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: 2022-01-20 12:24+0100\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"
#: evapp/templates/evapp/employee_form.html:40
msgid "Du bist eingeloggt als"
msgstr "You are logged in as"
#: evapp/templates/evapp/employee_form.html:97
#: evapp/templates/evapp/employee_form.html:99
msgid "Weiter"
msgstr "Next"