French translation.

This commit is contained in:
tonio
2009-03-30 08:25:56 +02:00
parent 5c4c7b929c
commit 9f28169de7
21 changed files with 327 additions and 83 deletions
+6 -5
View File
@@ -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):
+9 -8
View File
@@ -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'))
+11 -10
View File
@@ -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,