2009年9月7日星期一

Re: [fw-mvc] Zend_translate in Form

I would set the translator application wide within your bootstrap:
Zend_Registry::set('Zend_Translate', $translate);

Or do you want to use different languages for the same user ? :-)

Additionally, when you already set a default translator, you don't need to
add translation to the element again. Only when you use a textparser to
extract these strings when you don't have them anywhere else.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com


----- Original Message -----
From: "whisher" <whisher@mp4.it>
To: <fw-mvc@lists.zend.com>
Sent: Monday, September 07, 2009 11:41 PM
Subject: [fw-mvc] Zend_translate in Form


>
> Hi.
>
> I'm wondering if this is the right way to proceed
>
> to get the translation in the Zend_Form
>
> In my bootstrap
>
>
> protected function _initIn18()
> {
> $translate = new Zend_Translate('array', APPLICATION_PATH .
> '/languages/en_US.php', 'en_US');
> $translate->addTranslation(APPLICATION_PATH .
> '/languages/it_IT.php', 'it_IT');
> $translate->setLocale('it_IT');
> Zend_Form::setDefaultTranslator($translate);
> }
> In my Form
>
>
> $translator = $this->getTranslator();
> // Firstname
> $this->addElement('text', 'firstname', array(
> 'required' => true,
> 'maxlength' => 25,
> 'title' =>
> $translator->translate('form_User_Register_Tooltip_Uname'),
> 'label' => 'form_User_Register_Label_Uname',
> 'filters' => array('StringTrim','StringtoLower'),
> 'validators' => array(
> array('stringLength',true, array(2, 25)),
> array('regex', false, array('#^[a-z]+#i')))
> ));
> Thanks in advance
>
> Bye
>
> --
> View this message in context:
> http://www.nabble.com/Zend_translate-in-Form-tp25336723p25336723.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>

没有评论: