This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Symfony forms: Internationalization
Symfony forms: Internationalization [message #102729] Mon, 19 July 2010 10:49 Go to next message
pixworld  is currently offline pixworld
Messages: 13
Registered: July 2010
Location: Le Mans
Junior Member
Hi everyone, I'm having a minus issue on internationalizing forms.

Here is for example the file:

abstract class BaseutilisateurForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'civilite'         => new sfWidgetFormSelect(array('choices' => array('M.' => 'M.', 'Mme' => 'Mme', 'Mlle' => 'Mlle'))),
      'nom'              => new sfWidgetFormInputText(),
      'prenom'           => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'civilite'         => new sfValidatorString(array('max_length' => 5)),
      'nom'              => new sfValidatorString(
								array('min_length' => 2, 'max_length' => 50),
								array('required' => 'Please enter your name.',
									  'min_length' => "Last name must be at least 2 characters.",
									  'max_length' => "Last name must be 50 characters or less."
									 )
								),
      'prenom'           => new sfValidatorString(
								array('min_length' => 2, 'max_length' => 50),
								array('required' => "Please enter your first name.",
									  'min_length' => "First name must be at least 2 characters.",
									  'max_length' => "First name must be at least 2 characters.");
		
	$this->widgetSchema->setLabels(array(
		'civilite' => 'Prefix *',
		'nom' => 'Last name *',
		'prenom' => 'First name *',
		));


I've put matching records in messages.xml file, and internationalization works with Labels like Last name * or First name * but doesn't work with validators string like Please enter your first name.


Some people might have the same problem here:

http://www.developpez.net/forums/d934502/php/bibliotheques-f rameworks/symfony/internationalisation-messages-derreur-form ulaire/#post5352363 (french language)


Have you got any idea/clue ?

Thanks a lot
Re: Symfony forms: Internationalization [message #103059 is a reply to message #102729 ] Sun, 25 July 2010 20:18 Go to previous messageGo to next message
pixworld  is currently offline pixworld
Messages: 13
Registered: July 2010
Location: Le Mans
Junior Member
Hi,

we wait for a solution at the same problem, if you have one since your post.

Thanks.
Re: Symfony forms: Internationalization [message #103062 is a reply to message #103059 ] Sun, 25 July 2010 21:44 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
i believe it s something lacking in symfony.

What you could try is somehow geting i18n helpter in your form configure and use __('Please enter your first name.') when you set your error message, i m pretty sure i read something like that sometime ago.
Re: Symfony forms: Internationalization [message #103091 is a reply to message #102729 ] Mon, 26 July 2010 16:02 Go to previous messageGo to next message
claudia_k  is currently offline claudia_k
Messages: 29
Registered: June 2010
Junior Member
Hmm - translating validation errors works perfectly fine for me (symfony 1.4.6). I have set it up such that my validation strings come out of the db instead of an xliff file, but hopefully this does not matter.

Do you maybe use a custom formSchemaFormatter and have changed the translation catalogue? Also make sure that your translation file is correct - look especially at spaces and punctuation in your source string.

Good luck

Claudia


http://www.knewledge.com
Re: Symfony forms: Internationalization [message #103117 is a reply to message #102729 ] Tue, 27 July 2010 08:31 Go to previous messageGo to next message
pixworld  is currently offline pixworld
Messages: 13
Registered: July 2010
Location: Le Mans
Junior Member
Thanks a lot for your reply, but I still got my problem.

Another tricky thing is that internationalization on form error message works for modules generated with the admin-generator, but not for classical modules.

Moreover, if use my utilisatorForm.class.php for 2 modules, a normal one, and one which was generated by admin-generator, internationalization works for the second one and doesn't for the first one ...
Re: Symfony forms: Internationalization [message #103125 is a reply to message #103117 ] Tue, 27 July 2010 12:13 Go to previous message
claudia_k  is currently offline claudia_k
Messages: 29
Registered: June 2010
Junior Member
Hmm - no idea. I have not really checked i18n validation messages in the backend yet - in the frontend this is working fine for me.

Just for debugging you could have a look at sfWidgetFormSchemaFormatter::translate or directly at sfI18N::__ - this way you could see which string will be translated with which catalogue - maybe this helps somehow.


Good luck

Claudia


http://www.knewledge.com
Previous Topic:Propel behavior - parameter, string instead of array
Next Topic:sfValidatorAnd inner error messages
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software