Simple gender handling in translations (for languages like french which need

this feature).
Back to previous 'locale' location because it's not possible to access
translations that are defined inside the 'templates' directory while scanning
with django-admin.py from the 'admin' directory.
This commit is contained in:
tonio
2009-03-30 18:16:48 +02:00
parent 010addf422
commit 412540a63e
14 changed files with 277 additions and 116 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
from django import forms
from mailng.admin.models import Domain, Mailbox, Alias
from django.utils.translation import ugettext as _
from mailng.admin.templatetags.admin_extras import gender
class DomainForm(forms.ModelForm):
class Meta:
@@ -10,7 +11,7 @@ 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)
enabled = forms.BooleanField(label=gender("Enabled", "f"), required=False)
class Meta:
model = Mailbox
Binary file not shown.
Binary file not shown.
+10 -25
View File
@@ -1,36 +1,21 @@
from django import template
from django.template.loader import render_to_string
from django.utils.translation import ugettext as _
register = template.Library()
genders = {
"Enabled" : (_("enabled_m"), _("enabled_f"))
}
@register.simple_tag
def domain_menu(domain_id, selection):
return render_to_string('admin/domain_menu.html',
{"selection" : selection,
"domain_id" : domain_id})
# class MyVar(template.Node):
# def __init__(self, value, var_name):
# self.var_name = var_name
# self.value = value
# def render(self, context):
# context[self.var_name] = self.value
# return ""
# import re
# @register.tag(name="var")
# def do_my_var(parser, token):
# try:
# tag_name, arg = token.contents.split(None, 1)
# except ValueError:
# raise template.TemplateSyntaxError, '%r tag requires arguments' \
# % token.contents.split()[0]
# m = re.search('(.*?) as (\w+)', arg)
# if not m:
# raise template.TemplateSyntaxError, "%r tag had invalid arguments" \
# % tag_name
# value, var_name = m.groups()
# return MyVar(value, var_name)
@register.filter
def gender(value, target):
if genders.has_key(value):
return target == "m" and genders[value][0] or genders[value][1]
return value
+229
View File
@@ -0,0 +1,229 @@
# 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: 2009-03-30 18:07+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Antoine Nguyen <tonio@ngyn.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\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/aliases.html:17
#: templates/admin/domains.html:21
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à"
#: admin/templatetags/admin_extras.py:7
msgid "enabled_m"
msgstr "Activé"
#: admin/templatetags/admin_extras.py:7
msgid "enabled_f"
msgstr "Activée"
#: templates/admin/aliases.html:10
msgid "No alias defined."
msgstr "Aucun alias défini."
#: templates/admin/aliases.html:14 templates/admin/domains.html:17
#: templates/admin/mailboxes.html:14
msgid "Actions"
msgstr ""
#: templates/admin/aliases.html:15 templates/admin/mailboxes.html:16
msgid "Address"
msgstr "Adresse"
#: templates/admin/aliases.html:16
msgid "Mailbox"
msgstr "Boite aux lettres"
#: 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: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:14 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 "Aucune boite aux lettres définie."
#: 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."
+29
View File
@@ -0,0 +1,29 @@
# 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: 2009-03-30 10:14+0200\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"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: static/js/domains.js:15
msgid "Delete this domain?"
msgstr "Supprimer ce domaine?"
#: static/js/domains.js:21
msgid "Delete this mailbox?"
msgstr "Supprimer cette boite aux lettres?"
#: static/js/domains.js:27
msgid "Delete this alias?"
msgstr "Supprimer cet alias?"
+4 -4
View File
@@ -11,10 +11,10 @@
{% else %}
<table>
<tr>
<th width="50px">Actions</th>
<th width="150px">Address</th>
<th width="200px">Mailbox</th>
<th width="75px">Enabled</th>
<th width="50px">{% trans "Actions" %}</th>
<th width="150px">{% trans "Address" %}</th>
<th width="200px">{% trans "Mailbox" %}</th>
<th width="75px">{% trans "Enabled" %}</th>
</tr>
{% for alias in aliases %}
<tr>
+1
View File
@@ -3,6 +3,7 @@
<script src="/static/js/form.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
{% load i18n %}
<div class="title"><h1>Alias {{ alias.address }}</h1></div>
{% if error %}<div class="error">{{ error }}</div>{% endif %}
{% url admin.views.editalias alias.mbox.domain.id alias.id as edit_url %}
-12
View File
@@ -1,12 +0,0 @@
{% extends "admin/layout.html" %}
{%block pagetitle %}Administration{%endblock %}
{%block breadcrumb %}Domains{%endblock %}
{% block html_head %}
<script src="/static/js/domains.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
{% include default %}
{% endblock %}
-22
View File
@@ -1,22 +0,0 @@
{% extends "admin/layout.html" %}
{% block html_head %}{% endblock %}
{% block content %}
<div class="header">
<h1>Mailbox {{ mbox.address }}@{{ mbox.domain.name }}</h1>
</div>
<div id="menubar" class="menu2">
{% block menu %}{% endblock %}
</div>
<div id="mboxcontent">
<div class="row">
<label>Name :</label><label>{{ mb.name }}</label>
</div>
<h2>Aliases</h2>
{% for alias in aliases %}
{{ alias.address }}
{% endfor %}
</div>
{% endblock %}
+1 -1
View File
@@ -15,7 +15,7 @@
<th width="130px">{% trans "Name" %}</th>
<th width="170px">{% trans "Address" %}</th>
<th width="60px">{% trans "Quota" %}</th>
<th width="50px">{% trans "Enabled" %}</th>
<th width="50px">{{ "Enabled"|gender:"f" }}</th>
</tr>
{% for mb in mailboxes %}
<tr class="{% cycle 'odd' 'even' %}">
-14
View File
@@ -1,14 +0,0 @@
{% extends "admin/layout_simple.html" %}
{% block html_head %}
<script src="/static/js/form.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
<div class="title"><h1>Aliases for {{ mbox.address }}</h1></div>
<p>
<ul>
{% for alias in aliases %}
<li>{{alias.address}}</li>
{% endfor %}
</ul>
</p>
{% endblock %}
-36
View File
@@ -1,36 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MailNG - {%block pagetitle %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="/static/stylesheets/basic.css" />
<link rel="stylesheet" type="text/css" href="/static/stylesheets/SqueezeBox.css" />
<script src="/static/js/mootools.js" type="text/javascript"></script>
<script src="/static/js/SqueezeBox.js" type="text/javascript"></script>
{%block html_head %}{% endblock %}
</head>
<body>
<div id="header" class="rounded">
<div id="logo"></div>
<div id="title">
<h1>MailNG</h1>
<h2>Simple web messaging solution</h2>
<div id="info"></div>
</div>
</div>
<div id="content">
{%block content %}{% endblock %}
</div>
<div class="spacer"></div>
<div id="footer">
&copy; Antoine Nguyen 2009
</div>
</body>
</html>
+1 -1
View File
@@ -20,7 +20,7 @@ urlpatterns = patterns('',
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
{'packages': ('mailng.admin',),})
{'packages': ('mailng',),})
)
if settings.DEBUG: