Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-17-2008, 11:09 AM
Junior Member
 
Join Date: Aug 2008
Posts: 1
Default Zend Form translate error messages

hi,

i have a problem with the error message translation.

what i have done:

bootstrap:

PHP Code:

$translate 
= new Zend_Translate('gettext'$config->paths->base .'/application/languages''de');
        
$translate->addTranslation($config->paths->base .'/application/languages/de.mo''de');
        
Zend_Registry::set('Zend_Translate'$translate);
        
/*Zend_Validate_Abstract::setDefaultTranslator($translate); 
        Zend_Form::setDefaultTranslator($translate); */
        
Zend_Form::setDefaultTranslator($translate); 
i have a php file called formerror.php where i have the error message identifiers, it's only for poedit for translate.
PHP Code:
$translate->_("NOT_ALNUM");
$translate->_("STRING_EMPTY"); 

and my form class looks like:

PHP Code:
 class Form_Userlogin extends Zend_Form 
 
{
    public function 
__construct($options null
    {    
        
parent::__construct($options);
        
        
$translate Zend_Registry::get('Zend_Translate');
        
        
         
$this->setAction('/account/login')
            ->
setMethod('post');
            
        
        
$username $artist = new Zend_Form_Element_Text('username');
        
$username->setLabel($translate->_("Username"));
        
$username->addValidator('alnum',true,array())
                ->
addValidator('regex'true, array('/^[a-z]+$/'))
                ->
addValidator('stringLength'true, array(420))
                ->
setRequired(true)
                ->
addFilter('StringToLower');
                
        
        
$password = new Zend_Form_Element_Text('password');
        
$password->setLabel($translate->_("Passwort"));
        
$password->addValidator('StringLength'false, array(6))
                ->
setRequired(true);
        
//submit button
        
$submit = new Zend_Form_Element_Submit('submit');
        
$submit->setLabel(" login   ")
                ->
setName('login');
        
//zum form hinzufugen
        
$this->addElements(array($username$password$submit));
        
        
$this->clearDecorators();

        
$this->addDecorator('FormElements')
         ->
addDecorator('HtmlTag', array('tag' => '<ul>'))
         ->
addDecorator('Form');
        
        
$this->setElementDecorators(array(
            array(
'ViewHelper'),
            array(
'Errors'),
            array(
'Description'),
            array(
'Label', array('separator'=>' ')),
            array(
'HtmlTag', array('tag' => 'li''class'=>'formular-left')),
        ));

        
// buttons do not need labels
        
$submit->setDecorators(array(
            array(
'ViewHelper'),
            array(
'Description'),
            array(
'HtmlTag', array('tag' => 'li''class'=>'submit-login')),
        ));

    }
 } 
and the error message what i get is:
'+++++' has not only alphabetic and digit characters

there i must get a german message, but i don't


i also tried this:
PHP Code:
$username->addValidator('alnum',true,array(
                            
'messages' => array('NOT_ALNUM'=>'error määän'))) 
then i get this error message:

Fatal error: Uncaught exception 'Zend_Validate_Exception' with message 'No message template exists for key 'NOT_ALNUM'' in ......

can someone help me plz and say what i have to do?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-18-2008, 07:12 AM
Member
 
Join Date: Aug 2008
Posts: 55
Default

Ask/Look at Zend Framework Forum - Powered by vBulletin.

They are more active than the people here. And this question was already answered there in the past.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:28 PM.