Hallo,
Michel Thadeu hat gesagt: // Michel Thadeu wrote:

> > 1. The error-messages are hard-coded (i.e. english text).
> 
> I don?t use the formkit, but I use the funformkit and had similar
> problems. 

I also don't know FormKit, but FunFormKit and I also had to translate
errors to another language (German). This required a bit reading but
then turned out to be easy. Here's the (long) relevant snippet of my
app which is in action if you try to buy something at
http://normalmailorder.de :

from FunFormKit.Form import *
from FunFormKit.Field import *
import FunFormKit.Validator
#...

emptyMessage = {"empty": "Bitte ausfüllen"}

emailMessages = {
'noAt': 'Eine E-Mail-Addresse sollte ein @ enthalten',
"badUsername":
    "Der Name in der E-Mail-Addresse ist ung�ltig (der Teil vor dem @: %(username)s)",
"badDomain":
"Die Domaine in der E-Mail-Addresse ist ung�ltig (also der Teil nach dem @: 
%(domain)s)<br /> (sieht nicht aus wie notdot.com)",
"domainDoesNotExist":
    "Die Domaine in der E-Mail-Addresse existiert nicht (also der Teil nach dem @: 
%(domain)s)",
}

def myFormatError(value):
        """
        It prints the error message in red
        """
        if type(value) is type([]):
                value = string.join(filter(None, value), " <br>\n")
        return '<span class="babyred">%s</span><br>' % value

                   
formDef = FormDefinition(
        "",
        [TextField("vorname", description="VORNAME", maxLength=20, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextField("nachname", description="NACHNAME", maxLength=50, size=20, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextField("email", description="E-MAIL", size=20, 
                validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage), 
FunFormKit.Validator.Email(messages=emailMessages)]),
         TextField("strasse", description="STRASSE + HAUSNUMMER | POSTFACH", 
maxLength=200, size=40, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextField("land", description="LAND", maxLength=100, size=2, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextField("plz", description="PLZ", maxLength=5, size=5, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextField("stadt", description="STADT", maxLength=100, size=20, 
validators=[FunFormKit.Validator.NotEmpty(messages=emptyMessage)]),
         TextareaField("message", description="WEITERE BEMERKUNGEN", rows=4, cols=40),
         SelectField("payment", description="ZAHLUNGSWEISE", 
                selections=[("Lastschrift", "Lastschrift"), ("Nachnahme", "Nachnahme 
(+ 2,55 N/N"), ("Vorkasse", "Vorkasse")] ),
         TextField("kundennummer", description="KUNDENNUMMER (WENN BEKANNT)", size=5, 
maxLength=10),
         SubmitButton("submit", description="KAUFEN!", methodToInvoke="register"),
         ], errorFormatter=myFormatError)

layout = [("vorname*", "nachname*"),
                  "email*",
                  "strasse*",
                  ("land", "plz*", "stadt*"),
                  ("kundennummer", "payment*"), 
                  "message",
                  "submit",
                 ]
ciao.
-- 
Frank 


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to