diff --git a/admin/forms.py b/admin/forms.py index b2fb7dc5c..238662d2e 100644 --- a/admin/forms.py +++ b/admin/forms.py @@ -1,15 +1,16 @@ from django import forms from mailng.admin.models import Domain, Mailbox, Alias +from django.utils.translation import ugettext as _ class DomainForm(forms.ModelForm): class Meta: model = Domain class MailboxForm(forms.ModelForm): - quota = forms.IntegerField(label="Quota", required=False) - password1 = forms.CharField(label="Password", widget=forms.PasswordInput) - password2 = forms.CharField(label="Confirmation", widget=forms.PasswordInput) - enabled = forms.BooleanField(label="Enabled", required=False) + quota = forms.IntegerField(label=_("Quota"), required=False) + password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput) + password2 = forms.CharField(label=_("Confirmation"), widget=forms.PasswordInput) + enabled = forms.BooleanField(label=_("Enabled"), required=False) class Meta: model = Mailbox @@ -17,7 +18,7 @@ class MailboxForm(forms.ModelForm): def clean_password2(self): if self.cleaned_data["password1"] != self.cleaned_data["password2"]: - raise forms.ValidationError("Passwords mismatch") + raise forms.ValidationError(_("Passwords mismatch")) return self.cleaned_data["password2"] class AliasForm(forms.ModelForm): diff --git a/admin/models.py b/admin/models.py index e02ea1d8f..7d03fc77f 100644 --- a/admin/models.py +++ b/admin/models.py @@ -1,13 +1,14 @@ from django.db import models from django.contrib.auth.models import User from django.conf import settings +from django.utils.translation import ugettext_lazy as _ from mailng.lib import exec_pipe import os class Domain(models.Model): - name = models.CharField(max_length=100) + name = models.CharField(_('name'), max_length=100) quota = models.IntegerField() - enabled = models.BooleanField() + enabled = models.BooleanField(_('enabled')) def create_dir(self): code, output = exec_pipe("sudo -u %s mkdir %s/%s" \ @@ -39,10 +40,10 @@ class Domain(models.Model): return True class Mailbox(models.Model): - name = models.CharField(max_length=100) - address = models.CharField(max_length=100) + name = models.CharField(_('name'), max_length=100) + address = models.CharField(_('address'), max_length=100) full_address = models.CharField(max_length=150) - password = models.CharField(max_length=100) + password = models.CharField(_('password'), max_length=100) quota = models.IntegerField() uid = models.IntegerField() gid = models.IntegerField() @@ -84,7 +85,7 @@ class Mailbox(models.Model): return True class Alias(models.Model): - address = models.CharField(max_length=100) + address = models.CharField(_('address'), max_length=100) full_address = models.CharField(max_length=150) - mbox = models.ForeignKey(Mailbox) - enabled = models.BooleanField() + mbox = models.ForeignKey(Mailbox, verbose_name=_('mailbox')) + enabled = models.BooleanField(_('enabled')) diff --git a/admin/views.py b/admin/views.py index f7564c131..9fad0d22c 100644 --- a/admin/views.py +++ b/admin/views.py @@ -3,6 +3,7 @@ from django.template.loader import render_to_string from django.template import RequestContext from django.http import HttpResponse, HttpResponseRedirect from django.utils import simplejson +from django.utils.translation import ugettext as _ from django.core import serializers from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required @@ -39,7 +40,7 @@ def newdomain(request): error = None if form.is_valid(): if Domain.objects.filter(name=request.POST["name"]): - error = "Domain with this name already defined" + error = _("Domain with this name already defined") else: domain = form.save(commit=False) if domain.create_dir(): @@ -47,7 +48,7 @@ def newdomain(request): ctx = _ctx_ok(reverse(admin.views.domains)) return HttpResponse(simplejson.dumps(ctx), mimetype="application/json") - error = "Failed to initialise domain, check permissions" + error = _("Failed to initialise domain, check permissions") ctx = _ctx_ko("admin/newdomain.html", { "form" : form, "error" : error }) @@ -67,10 +68,10 @@ def editdomain(request, dom_id): if form.is_valid(): if domain.name != request.POST["name"]: if Domain.objects.filter(name=request.POST["name"]): - error = "Domain with this name already defined" + error = _("Domain with this name already defined") else: if not domain.rename_dir(request.POST["name"]): - error = "Failed to rename domain, check permissions" + error = _("Failed to rename domain, check permissions") if not error: form.save() ctx = _ctx_ok(reverse(admin.views.domains)) @@ -109,7 +110,7 @@ def newmailbox(request, dom_id=None): if form.is_valid(): if Mailbox.objects.filter(address=request.POST["address"], domain=dom_id): - error = "Mailbox with this address already exists" + error = _("Mailbox with this address already exists") else: mb = form.save(commit=False) if mb.create_dir(domain): @@ -136,7 +137,7 @@ def newmailbox(request, dom_id=None): ctx = _ctx_ok(reverse(admin.views.mailboxes, args=[domain.id])) return HttpResponse(simplejson.dumps(ctx), mimetype="application/json") - error = "Failed to initialise mailbox, check permissions" + error = _("Failed to initialise mailbox, check permissions") ctx = _ctx_ko("admin/newmailbox.html", { "form" : form, "domain" : domain, "error" : error }) @@ -157,10 +158,10 @@ def editmailbox(request, dom_id, mbox_id=None): if mb.address != request.POST["address"]: if Mailbox.objects.filter(address=request.POST["address"], domain=dom_id): - error = "Mailbox with this address already exists" + error = _("Mailbox with this address already exists") else: if not mb.rename_dir(mb.domain.name, request.POST["address"]): - error = "Failed to rename mailbox, check permissions" + error = _("Failed to rename mailbox, check permissions") if not error: mb = form.save(commit=False) enabled = request.POST.has_key("enabled") \ @@ -224,7 +225,7 @@ def newalias(request, dom_id, mbox_id): if form.is_valid(): if Alias.objects.filter(address=request.POST["address"], mbox=mbox_id): - error = "Alias with this address already exists" + error = _("Alias with this address already exists") else: alias = form.save(commit=False) alias.full_address = "%s@%s" % (alias.address, mbox.domain.name) @@ -252,7 +253,7 @@ def editalias(request, dom_id, alias_id): if alias.address != request.POST["address"] \ and Alias.objects.filter(address=request.POST["address"], mbox=alias.mbox.id): - error = "Alias with this address already exists" + error = _("Alias with this address already exists") else: alias = form.save(commit=False) alias.full_address = "%s@%s" % (alias.address, diff --git a/lib/__init__.py b/lib/__init__.py index d512117ee..d16f36492 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -32,3 +32,12 @@ def exec_pipe(cmd): else: code = -1 return code, output + +def crypt_password(raw_password): + import md5 + import random + + salt = md5.new(str(random.random) + str(random.random)).hexdigest() + salt = salt[:5] + hash = md5.new(salt + raw_password).hexdigest() + return "%s$%s$%s" % ("md5", salt, hash) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 000000000..b0c0ea15a --- /dev/null +++ b/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,216 @@ +# 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. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-03-29 23:04+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Antoine Nguyen \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin/forms.py:10 templates/admin/domains.html:20 +#: templates/admin/mailboxes.html:17 +msgid "Quota" +msgstr "" + +#: admin/forms.py:11 +msgid "Password" +msgstr "Mot de passe" + +#: admin/forms.py:12 +msgid "Confirmation" +msgstr "" + +#: admin/forms.py:13 templates/admin/domains.html:21 +#: templates/admin/mailboxes.html:18 +msgid "Enabled" +msgstr "Activé" + +#: admin/forms.py:21 +msgid "Passwords mismatch" +msgstr "Les mots de passe diffèrent" + +#: admin/models.py:9 admin/models.py:43 +msgid "name" +msgstr "Nom" + +#: admin/models.py:11 admin/models.py:91 +msgid "enabled" +msgstr "Activé" + +#: admin/models.py:44 admin/models.py:88 +msgid "address" +msgstr "Adresse" + +#: admin/models.py:46 +msgid "password" +msgstr "Mot de passe" + +#: admin/models.py:90 +msgid "mailbox" +msgstr "Boite aux lettres" + +#: admin/views.py:43 admin/views.py:71 +msgid "Domain with this name already defined" +msgstr "Un domaine avec ce nom existe déjà" + +#: admin/views.py:51 +msgid "Failed to initialise domain, check permissions" +msgstr "Impossible d'initialiser le domaine, vérifier les permissions" + +#: admin/views.py:74 +msgid "Failed to rename domain, check permissions" +msgstr "Impossible de renommer le domaine, vérifier les permissions" + +#: admin/views.py:113 admin/views.py:161 +msgid "Mailbox with this address already exists" +msgstr "Une boite aux lettres pour cette adresse existe déjà" + +#: admin/views.py:140 +msgid "Failed to initialise mailbox, check permissions" +msgstr "" +"Impossible d'initialiser la boite aux lettres, vérifier les permissions" + +#: admin/views.py:164 +msgid "Failed to rename mailbox, check permissions" +msgstr "Impossible de renommer la boite aux lettres, vérifier les permissions." + +#: admin/views.py:228 admin/views.py:256 +msgid "Alias with this address already exists" +msgstr "Un alias avec cette adresse existe déjà" + +#: templates/admin/aliases.html:10 +msgid "No alias defined." +msgstr "Aucun alias défini." + +#: templates/admin/aliases.html:25 +msgid "Edit alias" +msgstr "Editer cet alias" + +#: templates/admin/aliases.html:29 +msgid "Delete alias" +msgstr "Supprimer cet alias" + +#: templates/admin/domain_header.html:8 templates/admin/editdomain.html:7 +msgid "Domain" +msgstr "Domaine" + +#: templates/admin/domain_menu.html:12 templates/admin/newmailbox.html:7 +msgid "New mailbox" +msgstr "Nouvelle boite aux lettres" + +#: templates/admin/domain_menu.html:18 templates/admin/domains.html:19 +msgid "Mailboxes" +msgstr "Boites aux lettres" + +#: templates/admin/domain_menu.html:22 +msgid "Aliases" +msgstr "Alias" + +#: templates/admin/domain_menu.html:27 +msgid "Properties" +msgstr "Propriétés" + +#: templates/admin/domains.html:8 +msgid "Available domains" +msgstr "Domaines disponibles" + +#: templates/admin/domains.html:13 +msgid "No domain defined." +msgstr "Aucun alias défini." + +#: templates/admin/domains.html:17 templates/admin/mailboxes.html:14 +msgid "Actions" +msgstr "" + +#: templates/admin/domains.html:18 templates/admin/mailboxes.html:15 +msgid "Name" +msgstr "Nom" + +#: templates/admin/domains.html:29 +msgid "Edit domain" +msgstr "Editer le domaine" + +#: templates/admin/domains.html:33 +msgid "Delete domain" +msgstr "Supprimer le domaine" + +#: templates/admin/domains.html:39 templates/admin/mailboxes.html:45 +msgid "MB" +msgstr "Mo" + +#: templates/admin/domains.html:40 templates/admin/mailboxes.html:46 +msgid "yes,no" +msgstr "oui,non" + +#: templates/admin/editalias.html:13 templates/admin/editdomain.html:15 +#: templates/admin/editmailbox.html:16 +msgid "Update" +msgstr "Mettre à jour" + +#: templates/admin/layout.html:17 +msgid "Logout" +msgstr "Déconnexion" + +#: templates/admin/layout.html:29 templates/admin/newdomain.html:7 +msgid "New domain" +msgstr "Nouveau domaine" + +#: templates/admin/layout.html:35 +msgid "Domains" +msgstr "Domaines" + +#: templates/admin/layout.html:41 +msgid "Settings" +msgstr "Paramètres" + +#: templates/admin/mailboxes.html:10 +msgid "No mailbox defined." +msgstr "Aucun alias défini." + +#: templates/admin/mailboxes.html:16 +msgid "Address" +msgstr "Adresse" + +#: templates/admin/mailboxes.html:26 +msgid "Edit mailbox" +msgstr "Editer la boite aux lettres" + +#: templates/admin/mailboxes.html:31 +msgid "Delete mailbox" +msgstr "Supprimer la boite aux lettres" + +#: templates/admin/mailboxes.html:36 +msgid "Add new alias" +msgstr "Ajouter un alias" + +#: templates/admin/mailboxes.html:40 +msgid "Mailbox aliases" +msgstr "Alias de cette boite aux lettres" + +#: templates/admin/newalias.html:7 +msgid "New alias" +msgstr "Nouvel alias" + +#: templates/admin/newalias.html:14 templates/admin/newdomain.html:15 +#: templates/admin/newmailbox.html:16 +msgid "Create" +msgstr "Créer" + +#: templates/registration/login.html:8 +msgid "Welcome" +msgstr "Bienvenue" + +#: templates/registration/login.html:11 +msgid "Your username and password didn't match. Please try again." +msgstr "" +"Votre nom d'utilisateur et mot de passe ne correspondent pas. Veuillez " +"réessayer." diff --git a/static/js/domains.js b/static/js/domains.js index b0f603c53..28dd9b3ed 100644 --- a/static/js/domains.js +++ b/static/js/domains.js @@ -13,26 +13,23 @@ window.addEvent('domready', function() { // }; if ($$("a[name=deleteDom]")) - $$("a[name=deleteDom]").addEvent('click', function(event) { - if (!confirm("Delete this domain?")) - event.stop(); - }); - + $$("a[name=deleteDom]").addEvent('click', function(event) { + if (!confirm(gettext("Delete this domain?"))) + event.stop(); + }); + if ($$("a[name=deleteMb]")) $$("a[name=deleteMb]").addEvent('click', function(event) { - if (!confirm("Delete this mailbox?")) + if (!confirm(gettext("Delete this mailbox?"))) event.stop(); }); if ($$("a[name=deleteAlias]")) $$("a[name=deleteAlias]").addEvent('click', function(event) { - if (!confirm("Delete this alias?")) + if (!confirm(gettext("Delete this alias?"))) event.stop(); }); - handlers['deleteDom'] = function(obj, target) { - return confirm("Supprimer ce domaine?"); - } $('body').addEvent('click', function(event) { target = event.target; @@ -89,4 +86,4 @@ loadPage = function(url, destination, callback) { new Request({url: url, method: "get", onSuccess: function(data) { $(destination).set('html', data); }}).send(); -}; \ No newline at end of file +}; diff --git a/templates/admin/aliases.html b/templates/admin/aliases.html index 8dd9130fd..ae17cbb7b 100644 --- a/templates/admin/aliases.html +++ b/templates/admin/aliases.html @@ -5,8 +5,9 @@ {% endblock %} {% block domcontent %} +{% load i18n %} {% if not aliases %} -

No alias defined.

+

{% trans "No alias defined." %}

{% else %} @@ -21,11 +22,11 @@ {% url admin.views.editalias domain.id alias.id as edit_url %} - + {% url admin.views.delalias domain.id alias.id as del_url %} - + diff --git a/templates/admin/domain_header.html b/templates/admin/domain_header.html index 48d191861..4e048c03f 100644 --- a/templates/admin/domain_header.html +++ b/templates/admin/domain_header.html @@ -3,8 +3,9 @@ {% endblock %} {% block mainframe %} +{% load i18n %}
-

Domain {{ domain.name }}

+

{% trans "Domain" %} {{ domain.name }}

{{ alias.address }}@{{ alias.mbox.domain.name }}
- - - - - + + + + + {% for dom in domains %} @@ -25,18 +26,18 @@ {% url admin.views.editdomain dom.id as edit_url %} - + {% url admin.views.deldomain dom.id as del_url %} - + {% url admin.views.mailboxes dom.id as domurl %} - - + + {% endfor %}
ActionsNameMailboxesQuotaEnabled{% trans "Actions" %}{% trans "Name" %}{% trans "Mailboxes" %}{% trans "Quota" %}{% trans "Enabled" %}
{{ dom.name }} {{ dom.mboxcounter }}{{ dom.quota }} MB{{ dom.enabled|yesno }}{{ dom.quota }} {% trans "MB" %}{{ dom.enabled|yesno:_("yes,no") }}
diff --git a/templates/admin/editalias.html b/templates/admin/editalias.html index 3725ae74e..e67c724a8 100644 --- a/templates/admin/editalias.html +++ b/templates/admin/editalias.html @@ -10,7 +10,7 @@ {% include "admin/genericform.html" %}
- +
{% endblock %} diff --git a/templates/admin/editdomain.html b/templates/admin/editdomain.html index fe5d2adb4..cc887f38e 100644 --- a/templates/admin/editdomain.html +++ b/templates/admin/editdomain.html @@ -3,7 +3,8 @@ {% endblock %} {% block content %} -

Domain {{ domain.name }}

+{% load i18n %} +

{% trans "Domain" %} {{ domain.name }}

{% if error %}
{{ error }}
{% endif %} {% url admin.views.editdomain domain.id as dom_url %} @@ -11,7 +12,7 @@ {% include "admin/genericform.html" %}
- +
{% endblock %} diff --git a/templates/admin/editmailbox.html b/templates/admin/editmailbox.html index dc775d226..96cd75237 100644 --- a/templates/admin/editmailbox.html +++ b/templates/admin/editmailbox.html @@ -1,4 +1,5 @@ {% extends "admin/layout_simple.html" %} +{% load i18n %} {% block html_head %} {% endblock %} @@ -12,7 +13,7 @@
- +
{% endblock %} diff --git a/templates/admin/layout.html b/templates/admin/layout.html index 522ea9094..7685f86dc 100644 --- a/templates/admin/layout.html +++ b/templates/admin/layout.html @@ -1,5 +1,6 @@ {% extends "layout.html" %} {% block content %} +{% load i18n %} {% url admin.views.domains as dom_url %}
@@ -13,7 +14,7 @@
  • {% url django.contrib.auth.views.logout_then_login as logout_url %} - Logout + {% trans "Logout" %}
  • @@ -25,18 +26,20 @@ - New domain + {% trans "New domain" %}
  • - Domains + {% trans "Domains" %} +
  • - Settings + {% trans "Settings" %} +
  • diff --git a/templates/admin/mailboxes.html b/templates/admin/mailboxes.html index 412de23c9..296495b25 100644 --- a/templates/admin/mailboxes.html +++ b/templates/admin/mailboxes.html @@ -5,16 +5,17 @@ {% endblock %} {% block domcontent %} +{% load i18n %} {% if not mailboxes %} -

    No mailbox defined.

    +

    {% trans "No mailbox defined." %}

    {% else %} - - - - - + + + + + {% for mb in mailboxes %} @@ -22,27 +23,27 @@ {% url admin.views.editmailbox domain.id mb.id as edit_url %} - + {% url admin.views.delmailbox domain.id mb.id as del_url %} + title="{% trans 'Delete mailbox' %}" /> {% url admin.views.newalias domain.id mb.id as alias_url %} - + {% url mbox-aliases domain.id mb.id as aliases_url %} - + - - + + {% endfor %}
    ActionsNameAddressQuotaEnabled{% trans "Actions" %}{% trans "Name" %}{% trans "Address" %}{% trans "Quota" %}{% trans "Enabled" %}
    {{ mb.name }} {{ mb.address }}@{{ mb.domain.name }}{{ mb.quota }} MB{{ mb.user.is_active|yesno }}{{ mb.quota }} {% trans "MB" %}{{ mb.user.is_active|yesno:_("yes,no") }}
    diff --git a/templates/admin/newalias.html b/templates/admin/newalias.html index 645b9e87a..5cd4b8460 100644 --- a/templates/admin/newalias.html +++ b/templates/admin/newalias.html @@ -1,16 +1,17 @@ {% extends "admin/layout_simple.html" %} +{% load i18n %} {% block html_head %} {% endblock %} {% block content %} -

    New alias

    +

    {% trans "New alias" %}

    {% if error %}
    {{ error }}
    {% endif %} {% url admin.views.newalias mbox.domain_id mbox.id as box_url %}
    {% include "admin/genericform.html" %}
    - +
    {% endblock %} diff --git a/templates/admin/newdomain.html b/templates/admin/newdomain.html index 8a55e0622..00b618811 100644 --- a/templates/admin/newdomain.html +++ b/templates/admin/newdomain.html @@ -3,7 +3,8 @@ {% endblock %} {% block content %} -

    New domain

    +{% load i18n %} +

    {% trans "New domain" %}

    {% if error %}
    {{ error }}
    {% endif %} {% url admin.views.newdomain as dom_url %} @@ -11,8 +12,8 @@ {% include "admin/genericform.html" %}
    - +
    {% endblock %} -² + diff --git a/templates/admin/newmailbox.html b/templates/admin/newmailbox.html index f65867340..e0af22d60 100644 --- a/templates/admin/newmailbox.html +++ b/templates/admin/newmailbox.html @@ -1,9 +1,10 @@ {% extends "admin/layout_simple.html" %} +{% load i18n %} {% block html_head %} {% endblock %} {% block content %} -

    New mailbox

    +

    {% trans "New mailbox" %}

    {% if error %}
    {{ error }}
    {% endif %} {% url admin.views.newmailbox domain.id as box_url %} @@ -12,7 +13,7 @@
    - +
    {% endblock %} diff --git a/templates/layout.html b/templates/layout.html index 29fd6ce54..119d38717 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -1,3 +1,4 @@ +{% load i18n %} @@ -8,6 +9,8 @@ + {% url django.views.i18n.javascript_catalog as catalog_url %} + {%block html_head %}{% endblock %} diff --git a/templates/registration/login.html b/templates/registration/login.html index 041eb2094..53c8a1e2f 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -1,13 +1,14 @@ {% extends "layout.html" %} +{% load i18n %} {% block html_head %} {% endblock %} {% block content %}
    -

    Welcome

    +

    {% trans "Welcome" %}

    {% if form.errors %}
    -

    Your username and password didn't match. Please try again.

    +

    {% trans "Your username and password didn't match. Please try again." %}

    {% endif %}
    diff --git a/urls.py b/urls.py index 28ebd211b..31b00f480 100644 --- a/urls.py +++ b/urls.py @@ -18,7 +18,9 @@ urlpatterns = patterns('', (r'^mailng/admin/', include('mailng.admin.urls')), (r'^accounts/login/$', 'django.contrib.auth.views.login'), - (r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login') + (r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'), + (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', + {'packages': ('mailng',),}) ) if settings.DEBUG: