Bonjour à tous,
Je suis actuellement entrain de découvrir ce merveilleux framework qu'est Symfony. Je rencontre un problème lors de l'internationalisation des messages d'erreur d'un formulaire alors que pourtant je parviens bien à traduire mes labels. Ci-après le code du formulaire concerné.
et voici mon fichier de traduction i18n/fr/messages.xml dans lequel apparait bien le texte de mes labels et de mes messages d'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 class MembresForm extends BaseMembresForm { public function configure() { unset( $this["lvl"], $this["etat"], $this["id"], $this["ip_inscription"], $this["last_login"], $this["date_inscription"] ); $culture = sfContext::getInstance()->getUser()->getCulture(); $this->setWidgets(array( 'login' => new sfWidgetFormInputText(), 'email' => new sfWidgetFormInput(), 'pass' => new sfWidgetFormInputPassword(), 'repassword' => new sfWidgetFormInputPassword(), 'pays' => new sfWidgetFormI18nChoiceCountry(array('culture' => $culture)), 'captcha' => new sfWidgetFormInput() )); $this->widgetSchema->setLabels(array( 'login' => 'Login', 'email' => 'Email address', 'pass' => 'Password', 'repassword' => 'Retype password', 'pays' => 'Country', 'captcha' => 'Captcha' )); $this->widgetSchema->setHelp('repassword', 'Retype the previous password to prevent errors.'); $this->widgetSchema->setHelp('email', 'Require a valid email address.'); $this->widgetSchema->setHelp('login', 'Login between 3 and 20 alphanumerics characters.'); $this->widgetSchema->setNameFormat('membre[%s]'); $this->setValidators(array( 'login' => new sfValidatorAnd( array( new sfValidatorString( array('min_length' => 3, 'max_length' => 14), array( 'min_length' => "The login is too short. 3 characters minimum.", 'max_length' => "The login is too long. 14 characters maximum", ) ), new sfValidatorRegex( array('pattern' => '/^[a-zA-Z0-9-]+$/') ) ), array(), array( 'required' => "The login is required" //'invalid' => "The nickname could not contain special characters." ) ), 'pass' => new sfValidatorString( array('required' => true, 'min_length' => 6, 'max_length' => 20), array( 'min_length' => "The password is too short. 6 characters minimum.", 'max_length' => "The password is too long. 20 characters maximum", 'required' => "Password is required", 'invalid' => "The password must contains between 6 and 20 characters" ) ), 'repassword' => new sfValidatorString( array('required' => true, 'min_length' => 6, 'max_length' => 20), array( 'min_length' => "The password is too short. 6 characters minimum.", 'max_length' => "The password is too long. 20 characters maximum", 'required' => "Password confirmation is required", 'invalid' => "The password must contains between 6 and 20 characters" ) ), 'email' => new sfValidatorEmail( array('required' => true), array( 'required' => "Email is required", 'invalid' => "This email isn't correct. Please give a valid one." ) ), 'pays' => new sfValidatorString( array('min_length' => 2, 'max_length' => 2), array('invalid' => "Select the country in the list") ), )); $this->validatorSchema->setPostValidator( new sfValidatorSchemaCompare('pass', sfValidatorSchemaCompare::EQUAL, 'repassword') ); if (strlen($culture) > 2) { $pays = strtoupper(substr($culture, -2, 2)); } else { $pays = strtoupper($culture); } if ($pays == 'EN') $pays = 'GB'; $this->setDefault('pays', $pays); } }
Un détail doit m'échapper, mais je ne vois pas du tout quoi. Auriez-vous des suggestions?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-open.org/committees/xliff/documents/xliff.dtd"> <xliff version="1.0"> <file source-language="EN" target-language="fr" datatype="plaintext" original="messages" date="2010-06-01T00:34:51Z" product-name="messages"> <header/> <body> <trans-unit id="1"> <source>How are you doing today ?</source> <target>Comment vas-tu aujourd'hui ?</target> </trans-unit> <trans-unit id="2"> <source>Watch My Desk - Show Off your Geekstation</source> <target>Watch My Desk - Show Off your Geekstation</target> </trans-unit> <trans-unit id="3"> <source>Browse</source> <target>Explorer</target> </trans-unit> <trans-unit id="4"> <source>Join now</source> <target>S'inscrire</target> </trans-unit> <trans-unit id="5"> <source>Log in</source> <target>Identification</target> </trans-unit> <trans-unit id="6"> <source>Your desk</source> <target>Ton bureau</target> </trans-unit> <trans-unit id="7"> <source>Show off</source> <target>Montre</target> </trans-unit> <trans-unit id="8"> <source>your geekstation</source> <target>ton bureau de geek</target> </trans-unit> <trans-unit id="9"> <source>Watch My Desk is a website where you can share, browse and rate pictures of desks and computers of the world</source> <target>Watch my desk est un site où vous pouvez partager, explorer et noter des photos du bureaux et ordinateurs du monde entier</target> </trans-unit> <trans-unit id="10"> <source>Join the website to share your desk or post comments, just in 2 clics !</source> <target>Inscrivez vous pour partager vos bureaux, poster des coms... en 2 clics !</target> </trans-unit> <trans-unit id="11"> <source>Join now and show off your desk with the community !</source> <target>Inscris-toi maintenant et partage ton bureau de geek avec la communauté !</target> </trans-unit> <trans-unit id="12"> <source>Register to Watch My Desk</source> <target>S'inscrire sur Watch My Desk</target> </trans-unit> <trans-unit id="13"> <source>Register</source> <target>S'inscrire</target> </trans-unit> <trans-unit id="14"> <source>Login</source> <target>Pseudo</target> </trans-unit> <trans-unit id="15"> <source>Email address</source> <target>Adresse email</target> </trans-unit> <trans-unit id="16"> <source>Password</source> <target>Mot de passe</target> </trans-unit> <trans-unit id="17"> <source>Retype password</source> <target>Retapez le mot de passe</target> </trans-unit> <trans-unit id="18"> <source>Country</source> <target>Pays</target> </trans-unit> <trans-unit id="19"> <source>Captcha</source> <target>Captcha</target> </trans-unit> <trans-unit id="20"> <source>Create your account</source> <target>Créez votre compte</target> </trans-unit> <trans-unit id="21"> <source>Login between 3 and 20 alphanumerics characters.</source> <target>Pseudo compris entre 3 et 20 caractères alphanumériques.</target> </trans-unit> <trans-unit id="22"> <source>Require a valid email address.</source> <target>Adresse email valide requise.</target> </trans-unit> <trans-unit id="23"> <source>Retype the previous password to prevent errors.</source> <target>Saisissez de nouveau le mot de passe.</target> </trans-unit> <trans-unit id="24"> <source>The login is too short. 3 characters minimum.</source> <target>Le pseudo est trop court. 3 caractères minimum.</target> </trans-unit> <trans-unit id="25"> <source>The login is too long. 14 characters maximum</source> <target>Le pseudo est trop long. 14 caractères maximum</target> </trans-unit> <trans-unit id="26"> <source>The login is required</source> <target>Le pseudo est requis</target> </trans-unit> <trans-unit id="27"> <source>The login must be an alphanumeric string between 3 and 14 characters</source> <target>Le pseudo doit comporter entre 3 et 14 caractères alphanumériques</target> </trans-unit> <trans-unit id="28"> <source>The nickname could not contain special characters.</source> <target>Le pseudo ne peut pas contenir de caractères spéciaux.</target> </trans-unit> <trans-unit id="29"> <source>The password is too short. 6 characters minimum.</source> <target>Le mot de passe est trop court. 3 caractères minimum.</target> </trans-unit> <trans-unit id="30"> <source>The password is too long. 20 characters maximum</source> <target>Le mot de passe est trop long. 14 caractères maximum</target> </trans-unit> <trans-unit id="31"> <source>Password is required</source> <target>Le mot de passe est requis</target> </trans-unit> <trans-unit id="32"> <source>The password must contains between 6 and 20 characters</source> <target>Le mot de passe doit contenir entre 6 et 20 caractères</target> </trans-unit> <trans-unit id="33"> <source>Password confirmation is required</source> <target>Le mot de passe de confirmation est requis</target> </trans-unit> <trans-unit id="34"> <source>Email is required</source> <target>L'email est requis</target> </trans-unit> <trans-unit id="35"> <source>This email isn't correct. Please give a valid one.</source> <target>Cette adresse email est incorrecte. Merci d'en spécifier un valide.</target> </trans-unit> <trans-unit id="36"> <source>Select the country in the list</source> <target>Sélectionnez un pays dans la liste</target> </trans-unit> <trans-unit id="37"> <source>The password and password confirmation are different</source> <target>Le mot de passe et mot de passe de confirmation sont différents</target> </trans-unit> </body> </file> </xliff>
Partager