From 700e24e4fd4f2cb839e0836c454ab218118c7b1f Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Fri, 22 May 2015 17:55:00 +0200 Subject: [PATCH] Internationalizasion --- cas_server/forms.py | 7 +- cas_server/locale/en/LC_MESSAGES/django.mo | Bin 0 -> 2252 bytes cas_server/locale/en/LC_MESSAGES/django.po | 112 ++++++++++++++++ cas_server/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 2534 bytes cas_server/locale/fr/LC_MESSAGES/django.po | 123 ++++++++++++++++++ cas_server/models.py | 5 +- cas_server/templates/cas_server/logged.html | 5 +- cas_server/templates/cas_server/login.html | 5 +- .../templates/cas_server/serviceValidate.xml | 3 + cas_server/templates/cas_server/warn.html | 4 +- cas_server/views.py | 22 ++-- 11 files changed, 265 insertions(+), 21 deletions(-) create mode 100644 cas_server/locale/en/LC_MESSAGES/django.mo create mode 100644 cas_server/locale/en/LC_MESSAGES/django.po create mode 100644 cas_server/locale/fr/LC_MESSAGES/django.mo create mode 100644 cas_server/locale/fr/LC_MESSAGES/django.po diff --git a/cas_server/forms.py b/cas_server/forms.py index 192b26b..7b92c9e 100644 --- a/cas_server/forms.py +++ b/cas_server/forms.py @@ -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) diff --git a/cas_server/locale/en/LC_MESSAGES/django.mo b/cas_server/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..76cc5d4d0b4ca8fcbd14dd1a143646726149cb71 GIT binary patch literal 2252 zcmeH|&2Jk;7{(V`pqQ_IAWnQtg(AgjcVoLvDaN&0f?GvONYuEcl_FKMyRX+%ZD!2O zY#blBasweGxFP-n{({~(acjA7CsrE&c4p_}nRn)W{PW49 zUj=wxMR^_N9?Bai+fU&K&wa29KB##7=^(g(`UdzK_$k-|zX9I_?}N{Rzk<(zzgP7? zz?V=za%8&B36RG};3=>No(FG(Z-JkKtm!+D=lLEy2L1pZ1%Ctw(DW0?`nu@E`~+lu z_duTiH<0z!Ad2-}0)GLwL3|3XJU7*Q4P<>Ef*gl!kjGEJFTpQB*7r6)Qia z*Jl;K2G64YEyy9{HTc2sa-S#4+H}nGct==f&kM7+>C1}%?-g4twH*gvL3tU4*RG+Q zMB#YPo-2hPlJ+W*UKuTh(utTz3rimt%2F!giEw0hRYGE6QOg~wJF&R1SlGPo>cOGm zmNboJ{)D5WzYc$rMWbNFXibS1-Uz7Q*BA7xHCCjBRXW>m6uHSv;i0|SMcuV)3yZ{E z>+YY2xM0m>8Kn%R`4=+k5GJTEtH&0U6-E-JI0x*tz_NZQ{r=v98`zUbhSEw;RymyF!G-ucAK8J` zAso6#(z&s*X)u;n2b) ziAize+TvoYeC<|v4M~6#Vf~wiQsqT6x)3!RwZqr_|73%y;5wH1>4MJiTo*YeR&m_3 z4CySP^|mSCOuNYRS^G3|keov4$_7?&d=}<&$djrJjXJSi>RyFGI7(mG2;l%WApf!aep%?>_lTZ--9M2#L5qUb+#GWcO>Z*wyfAHmH83@@gE!4ctd U!R#__DX)pa-vus!^5ml6PYhd*AOHXW literal 0 HcmV?d00001 diff --git a/cas_server/locale/en/LC_MESSAGES/django.po b/cas_server/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000..451b06b --- /dev/null +++ b/cas_server/locale/en/LC_MESSAGES/django.po @@ -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 , 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 \n" +"Language-Team: django \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 "" +"

Log In Successful

You have successfully logged into the Central " +"Authentication Service.
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 "" +"

Logout successful

You have successfully logged out of the Central " +"Authentication Service.
For security reasons, exit your web browser." diff --git a/cas_server/locale/fr/LC_MESSAGES/django.mo b/cas_server/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..0f54e8029360ec52d9ca347488ae2a0bef2ffe17 GIT binary patch literal 2534 zcmcJQ%WoS+9LJ}$6fm!}ye>S3LzGxy9oub6aGa<#Nm0~pY5sEGw#f+ zlk^YZh`1neK>~>b1__BP;^q^#!i8JKnF}`#2qeCE{pFP_<=K|>0=fJ1HRq!(SHuw_w0qAY|8ua^g!H2=`!E@k`;D@m3C-5f54NSTQ zehV&ue}d0}ufdp2@FrLWKLgKT-F@&8jDLQJu_wV_z-PeU!6|S8hrJBWgI|H~fGgm6 zESdptfE?Td9|b=K9|J!Jy&vCzI3~3nVAwYG^MW7X^1fgSgDk_#?{oO_`*~mCVyfK) z=xu!hx7Q|v`yy_*GP+(*T!WO8p>R?w-Vm1W5-D!zP9hCOeD{D`GHn?WpPW{rNm)s zXIn`alC`xYjt~0wu`2u!&KbFz8e5YTM^IW~B~gSpz}E!Fx`uEA-`F;M;$cG=;mAmf zD2^ZG|MwvqI~|6@?v}82Pn(GC38PrW=-Uu9Sc`%kG8UOo;-RqbdCkaVZc$4c7i`$N zjDl-P-3C=%;+e{3HCQ&3W=^mI8%n&GFU$q`xu96&g;z_Li!=FRK97mPEow`@?}_u~ zF3sc%n71yh3#vva8w;mRiSLNmC#T|DqA3k8xBKIq_2a9dpPJLAzJ#T!o`^aHRT9k- zk8WeEd3k;PYAnZRlz7c#Hr6&)N3Irf`3!Q(;jEx~(1IV1_T6kN7E&#w0$Xy6+tusA z{Aiv(yGABhRiTcMaV0*#D_y1%Cq~4E8-C~g^Iu_(J#{4piBktc3iiEXHz06S~@X29u~q0g_>h4 zgWZUmZs*vJr`cjq>_aosCgIN)|9bou@vv95NLi7LQW%b+7zqxLMP?^RIF-O@sHhx| z1&_L&bmhM9PtkDYSVfNt+6(s|_p_|rxU`h^mh>#hlvpdNJd4*mIE?(Oj8!)mg#s97pOk@vE(!L4Aw1tfK&Z8fathK)}>i(Z=$cRMIC=7b15WusqQ7{JG}=@%p zmBXPPlRtA*|B)O${r?Z$|3+eXGj&3%_FgMEfX*)Pr2qf` literal 0 HcmV?d00001 diff --git a/cas_server/locale/fr/LC_MESSAGES/django.po b/cas_server/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 0000000..ded5e12 --- /dev/null +++ b/cas_server/locale/fr/LC_MESSAGES/django.po @@ -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 , 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 \n" +"Language-Team: django \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 "" +"

Connexion réussie

Vous vous êtes authentifié(e) auprès du Service " +"Central d'Authentification.
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 "" +"

Déconnexion réussie

\n" +"Vous vous êtes déconnecté(e) du Service Central d'Authentification.
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)" diff --git a/cas_server/models.py b/cas_server/models.py index 694bf79..8b44b17 100644 --- a/cas_server/models.py +++ b/cas_server/models.py @@ -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) diff --git a/cas_server/templates/cas_server/logged.html b/cas_server/templates/cas_server/logged.html index 6d26c7f..bb82c0d 100644 --- a/cas_server/templates/cas_server/logged.html +++ b/cas_server/templates/cas_server/logged.html @@ -1,6 +1,7 @@ {% extends "cas_server/base.html" %} {% load bootstrap3 %} {% load staticfiles %} +{% load i18n %} {% block bootstrap3_extra_head %} {% endblock %} @@ -10,8 +11,8 @@
{% bootstrap_messages %} - -{% bootstrap_button 'Deconnexion' size='lg' button_class="btn-danger btn-block" href="logout" %} + +{% bootstrap_button _('Logout') size='lg' button_class="btn-danger btn-block" href="logout" %}
diff --git a/cas_server/templates/cas_server/login.html b/cas_server/templates/cas_server/login.html index 3d88e34..161a5c1 100644 --- a/cas_server/templates/cas_server/login.html +++ b/cas_server/templates/cas_server/login.html @@ -1,6 +1,7 @@ {% extends "cas_server/base.html" %} {% load bootstrap3 %} {% load staticfiles %} +{% load i18n %} {% block bootstrap3_extra_head %} {% endblock %} @@ -11,10 +12,10 @@
{% bootstrap_messages %}
diff --git a/cas_server/templates/cas_server/serviceValidate.xml b/cas_server/templates/cas_server/serviceValidate.xml index 59cb01d..7e686d6 100644 --- a/cas_server/templates/cas_server/serviceValidate.xml +++ b/cas_server/templates/cas_server/serviceValidate.xml @@ -5,6 +5,9 @@ {% for key, value in attributes %} {{value}} {% endfor %} +{% for key, value in attributes %} + +{% endfor %} {% if proxyGrantingTicket %} {{proxyGrantingTicket}} {% endif %} diff --git a/cas_server/templates/cas_server/warn.html b/cas_server/templates/cas_server/warn.html index 20a6f32..768d8cf 100644 --- a/cas_server/templates/cas_server/warn.html +++ b/cas_server/templates/cas_server/warn.html @@ -1,6 +1,7 @@ {% extends "cas_server/base.html" %} {% load bootstrap3 %} {% load staticfiles %} +{% load i18n %} {% block bootstrap3_extra_head %} {% endblock %} @@ -10,8 +11,7 @@
{% bootstrap_messages %} - -{% 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 %}
diff --git a/cas_server/views.py b/cas_server/views.py index 883e58a..fc0e3f2 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -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):