|
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);
}
|
|
Administrator
|
-- whisher <[hidden email]> wrote
(on Monday, 07 September 2009, 02:41 PM -0700): > 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 Yes, this will work fine. -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ |
|
In reply to this post by whisher
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" <[hidden email]> To: <[hidden email]> 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. > |
|
Hi Thomas,
Are there any examples of these textparsers anywhere? I can't seem to find a lot of information about it anywhere, but it must be a big problem for anyone with a large international code base. Are there any ZF components that do this, or is there scope for such a component? Possibly part of Zend_Tool? -Johanna |
| Powered by Nabble | See how NAML generates this page |
