Internationalizasion

This commit is contained in:
Valentin Samir 2015-05-22 17:55:00 +02:00
parent 6964821da4
commit 700e24e4fd
11 changed files with 265 additions and 21 deletions

View File

@ -2,15 +2,16 @@ import default_settings
from django import forms
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
import models
class UserCredential(forms.Form):
username = forms.CharField(label='login')
username = forms.CharField(label=_('login'))
service = forms.CharField(widget=forms.HiddenInput(), required=False)
password = forms.CharField(label='password', widget=forms.PasswordInput)
password = forms.CharField(label=_('password'), widget=forms.PasswordInput)
method = forms.CharField(widget=forms.HiddenInput(), required=False)
warn = forms.BooleanField(label='warn', required=False)
warn = forms.BooleanField(label=_('warn'), required=False)
def __init__(self, *args, **kwargs):
super(UserCredential, self).__init__(*args, **kwargs)

Binary file not shown.

View File

@ -0,0 +1,112 @@
# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: cas_server\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-22 17:49+0200\n"
"PO-Revision-Date: 2015-05-22 17:52+0100\n"
"Last-Translator: Valentin Samir <valentin.samir@crans.org>\n"
"Language-Team: django <LL@li.org>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.10\n"
#: forms.py:10
msgid "login"
msgstr "username"
#: forms.py:12
msgid "password"
msgstr "password"
#: forms.py:14
msgid "warn"
msgstr " Warn me before logging me into other sites."
#: models.py:57
#, python-format
msgid "Error during service logout %s"
msgstr "Error during service logout %s"
#: models.py:189
#, python-format
msgid ""
"Error during service logout %(service)s:\n"
"%(error)s"
msgstr ""
"Error during service logout %(service)s:\n"
"%(error)s"
#: templates/cas_server/logged.html:14
msgid "Logged"
msgstr ""
"<h3>Log In Successful</h3>You have successfully logged into the Central "
"Authentication Service.<br/>For security reasons, please Log Out and Exit "
"your web browser when you are done accessing services that require "
"authentication!"
#: templates/cas_server/logged.html:15
msgid "Logout"
msgstr "Logout"
#: templates/cas_server/login.html:15
msgid "Please loggin"
msgstr "Please loggin"
#: templates/cas_server/login.html:18
msgid "Login"
msgstr "Login"
#: templates/cas_server/warn.html:14
msgid "Connect to the service"
msgstr "Connect to the service"
#: views.py:74
#, python-format
msgid "Authentication has been required by service %(name)s (%(url)s)"
msgstr "Authentication has been required by service %(name)s (%(url)s)"
#: views.py:79
#, python-format
msgid "Service %(url)s non allowed."
msgstr "Service %(url)s non allowed."
#: views.py:81
msgid "Username non allowed"
msgstr "Username non allowed"
#: views.py:83
msgid "User charateristics non allowed"
msgstr "User charateristics non allowed"
#: views.py:85
#, python-format
msgid "The attribut %(field)s is needed to use that service"
msgstr "The attribut %(field)s is needed to use that service"
#: views.py:101
#, python-format
msgid "Authentication renewal required by service %(name)s (%(url)s)."
msgstr "Authentication renewal required by service %(name)s (%(url)s)."
#: views.py:103
#, python-format
msgid "Authentication required by service %(name)s (%(url)s)."
msgstr "Authentication required by service %(name)s (%(url)s)."
#: views.py:105
#, python-format
msgid "Service %s non allowed"
msgstr "Service %s non allowed"
#: views.py:121
msgid "Successfully logout"
msgstr ""
"<h3>Logout successful</h3>You have successfully logged out of the Central "
"Authentication Service.</br>For security reasons, exit your web browser."

Binary file not shown.

View File

@ -0,0 +1,123 @@
# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: cas_server\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-22 17:42+0200\n"
"PO-Revision-Date: 2015-05-22 17:53+0100\n"
"Last-Translator: Valentin Samir <valentin.samir@crans.org>\n"
"Language-Team: django <LL@li.org>\n"
"Language: fr\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"
"X-Generator: Poedit 1.6.10\n"
#: forms.py:10
msgid "login"
msgstr "Identifiant"
#: forms.py:12
msgid "password"
msgstr "mot de passe"
#: forms.py:14
msgid "warn"
msgstr "Prévenez-moi avant d'accéder à d'autres services."
#: models.py:57
#, python-format
msgid "Error during service logout %s"
msgstr "Une erreur est survenue durant la déconnexion du service %s"
#: models.py:189
#, python-format
msgid ""
"Error during service logout %(service)s:\n"
"%(error)s"
msgstr ""
"Une erreur est survenue durant la déconnexion du service %(service)s:"
"%(error)s"
#: templates/cas_server/logged.html:14
msgid "Logged"
msgstr ""
"<h3>Connexion réussie</h3>Vous vous êtes authentifié(e) auprès du Service "
"Central d'Authentification.<br/>Pour des raisons de sécurité, veuillez vous "
"déconnecter et fermer votre navigateur lorsque vous avez fini d'accéder aux "
"services authentifiés."
#: templates/cas_server/logged.html:15
msgid "Logout"
msgstr "Se déconnecter"
#: templates/cas_server/login.html:15
msgid "Please loggin"
msgstr "Merci de se connecter"
#: templates/cas_server/login.html:18
msgid "Login"
msgstr "Connexion"
#: templates/cas_server/warn.html:14
msgid "Connect to the service"
msgstr "Se connecter au service"
#: views.py:74
#, python-format
msgid "Authentication has been required by service %(name)s (%(url)s)"
msgstr ""
"Une demande d'authentification a été émise pour le service %(name)s "
"(%(url)s)."
#: views.py:79
#, python-format
msgid "Service %(url)s non allowed."
msgstr "le service %(url)s n'est pas autorisé."
#: views.py:81
msgid "Username non allowed"
msgstr "Nom d'utilisateur non authorisé"
#: views.py:83
msgid "User charateristics non allowed"
msgstr "Caractéristique utilisateur non autorisée"
#: views.py:85
#, python-format
msgid "The attribut %(field)s is needed to use that service"
msgstr "L'attribut %(field)s est nécessaire pour se connecter à ce service"
#: views.py:101
#, python-format
msgid "Authentication renewal required by service %(name)s (%(url)s)."
msgstr "Demande de réauthentification pour le service %(name)s (%(url)s)."
#: views.py:103
#, python-format
msgid "Authentication required by service %(name)s (%(url)s)."
msgstr "Authentification requise par le service %(name)s (%(url)s)."
#: views.py:105
#, python-format
msgid "Service %s non allowed"
msgstr "Le service %s n'est pas autorisé"
#: views.py:121
msgid "Successfully logout"
msgstr ""
"<h3>Déconnexion réussie</h3>\n"
"Vous vous êtes déconnecté(e) du Service Central d'Authentification.<br/>Pour "
"des raisons de sécurité, veuillez fermer votre navigateur."
#~ msgid ""
#~ "Une demande d'authentification a été émise pour le service %(name)s "
#~ "(%(url)s)"
#~ msgstr ""
#~ "Une demande d'authentification a été émise pour le service %(name)s "
#~ "(%(url)s)"

View File

@ -5,6 +5,7 @@ from django.conf import settings
from django.db import models
from django.contrib import messages
from picklefield.fields import PickledObjectField
from django.utils.translation import ugettext as _
import re
import os
@ -53,7 +54,7 @@ class User(models.Model):
try:
future.result()
except Exception as e:
messages.add_message(request, messages.WARNING, u'Erreur lors de la déconnexion des services %s' % e)
messages.add_message(request, messages.WARNING, _(u'Error during service logout %s') % e)
def delete(self):
super(User, self).delete()
@ -185,7 +186,7 @@ class Ticket(models.Model):
try:
return session.post(self.service.encode('utf-8'), data=xml.encode('utf-8'), headers=headers)
except Exception as e:
messages.add_message(request, messages.WARNING, u'Erreur lors de la déconnexion du service %s:\n%s' % (self.service, e))
messages.add_message(request, messages.WARNING, _(u'Error during service logout %(service)s:\n%(error)s') % {'service': self.service, 'error':e})
class ServiceTicket(Ticket):
value = models.CharField(max_length=255, default=_gen_st, unique=True)

View File

@ -1,6 +1,7 @@
{% extends "cas_server/base.html" %}
{% load bootstrap3 %}
{% load staticfiles %}
{% load i18n %}
{% block bootstrap3_extra_head %}
<link href="{% static "cas_server/login.css" %}" rel="stylesheet">
{% endblock %}
@ -10,8 +11,8 @@
<div class="col-md-3"></div>
<div class="col-md-6">
{% bootstrap_messages %}
<div class="alert alert-success" role="alert">Logged</div>
{% bootstrap_button 'Deconnexion' size='lg' button_class="btn-danger btn-block" href="logout" %}
<div class="alert alert-success" role="alert">{% trans "Logged" %}</div>
{% bootstrap_button _('Logout') size='lg' button_class="btn-danger btn-block" href="logout" %}
</div>
<div class="col-md-3"></div>
</div>

View File

@ -1,6 +1,7 @@
{% extends "cas_server/base.html" %}
{% load bootstrap3 %}
{% load staticfiles %}
{% load i18n %}
{% block bootstrap3_extra_head %}
<link href="{% static "cas_server/login.css" %}" rel="stylesheet">
{% endblock %}
@ -11,10 +12,10 @@
<div class="col-md-6">
{% bootstrap_messages %}
<form class="form-signin" method="post">
<h2 class="form-signin-heading">Merci de se connecter</h2>
<h2 class="form-signin-heading">{% trans "Please loggin" %}</h2>
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_button 'Connection' size='lg' button_type="submit" button_class="btn-block"%}
{% bootstrap_button _('Login') size='lg' button_type="submit" button_class="btn-block"%}
</form>
</div>
<div class="col-md-3"></div>

View File

@ -5,6 +5,9 @@
{% for key, value in attributes %} <cas:{{key}}>{{value}}</cas:{{key}}>
{% endfor %}
</cas:attributes>
{% for key, value in attributes %}
<cas:attribute name="{{key}}" value="{{value}}"/>
{% endfor %}
{% if proxyGrantingTicket %}
<cas:proxyGrantingTicket>{{proxyGrantingTicket}}</cas:proxyGrantingTicket>
{% endif %}

View File

@ -1,6 +1,7 @@
{% extends "cas_server/base.html" %}
{% load bootstrap3 %}
{% load staticfiles %}
{% load i18n %}
{% block bootstrap3_extra_head %}
<link href="{% static "cas_server/login.css" %}" rel="stylesheet">
{% endblock %}
@ -10,8 +11,7 @@
<div class="col-md-3"></div>
<div class="col-md-6">
{% bootstrap_messages %}
<div class="alert alert-warning" role="alert">Une demande d'authentification a été émise pour le service {% if name %}{{name}} ({% endif %}{{service}}{% if name %}){% endif %}</div>
{% bootstrap_button 'Se connecter au service' size='lg' button_class="btn-primary btn-block" href=service_ticket_url %}
{% bootstrap_button _('Connect to the service') size='lg' button_class="btn-primary btn-block" href=service_ticket_url %}
</div>
<div class="col-md-3"></div>
</div>

View File

@ -5,6 +5,7 @@ from django.shortcuts import render, redirect
from django.http import HttpResponse, StreamingHttpResponse
from django.conf import settings
from django.contrib import messages
from django.utils.translation import ugettext as _
import requests
from datetime import datetime, timedelta
@ -70,24 +71,25 @@ def login(request):
service_pattern.check_user(user)
# if the user has asked to be warned before any login to a service (no transparent SSO)
if request.session["warn"] and not warned:
return render(request, settings.CAS_WARN_TEMPLATE, {'service_ticket_url':user.get_service_url(service, service_pattern, renew=renew),'service':service, 'name': service_pattern.name})
messages.add_message(request, messages.WARNING, _(u"Authentication has been required by service %(name)s (%(url)s)") % {'name':service_pattern.name, 'url':service})
return render(request, settings.CAS_WARN_TEMPLATE, {'service_ticket_url':user.get_service_url(service, service_pattern, renew=renew)})
else:
return redirect(user.get_service_url(service, service_pattern, renew=renew)) # redirect, using method ?
except models.ServicePattern.DoesNotExist:
messages.add_message(request, messages.ERROR, u'Service %s non autorisé.' % service)
messages.add_message(request, messages.ERROR, _(u'Service %(url)s non allowed.') % {'url' : service})
except models.BadUsername:
messages.add_message(request, messages.ERROR, u"Nom d'utilisateur non autorisé")
messages.add_message(request, messages.ERROR, _(u"Username non allowed"))
except models.BadFilter:
messages.add_message(request, messages.ERROR, u"Caractéristique utilisateur non autorisé")
messages.add_message(request, messages.ERROR, _(u"User charateristics non allowed"))
except models.UserFieldNotDefined:
messages.add_message(request, messages.ERROR, u"L'attribut %s est nécessaire pour utiliser ce service" % service_pattern.user_field)
messages.add_message(request, messages.ERROR, _(u"The attribut %(field)s is needed to use that service") % {'field':service_pattern.user_field})
# if gateway is set and auth failed redirect to the service without authentication
if gateway:
list(messages.get_messages(request)) # clean messages before leaving the django app
return redirect(service)
return render(request, settings.CAS_LOGGED_TEMPLATE, {})
return render(request, settings.CAS_LOGGED_TEMPLATE, {'session':request.session})
else:
if service:
try:
@ -96,11 +98,11 @@ def login(request):
list(messages.get_messages(request)) # clean messages before leaving the django app
return redirect(service)
if request.session.get("authenticated") and renew:
messages.add_message(request, messages.WARNING, u"Demande de réautentification par le service %s (%s)." % (service_pattern.name, service))
messages.add_message(request, messages.WARNING, _(u"Authentication renewal required by service %(name)s (%(url)s).") % {'name':service_pattern.name, 'url':service})
else:
messages.add_message(request, messages.WARNING, u"Demande d'autentification par le service %s (%s)." % (service_pattern.name, service))
messages.add_message(request, messages.WARNING, _(u"Authentication required by service %(name)s (%(url)s).") % {'name':service_pattern.name, 'url':service})
except models.ServicePattern.DoesNotExist:
messages.add_message(request, messages.ERROR, u'Service %s non autorisé.' % service)
messages.add_message(request, messages.ERROR, _(u'Service %s non allowed') % service)
return render(request, settings.CAS_LOGIN_TEMPLATE, {'form':form})
def logout(request):
@ -116,7 +118,7 @@ def logout(request):
return redirect(service)
# else redirect to login page
else:
messages.add_message(request, messages.SUCCESS, u'Déconnecté avec succès')
messages.add_message(request, messages.SUCCESS, _(u'Successfully logout'))
return redirect("login")
def validate(request):