The problem from your description is that you need to have two different
translations for one messageid.
How should Zend_Translate know what you want when you ask for "mess1" ? Do
you mean component1 or component2.
The only thing to handle such things is
* Use different messageids
or
* Use two translation objects
Also I don't think that "Value is required" is available more than once.
Searching through the complete framework I find this messageid only once.
Could it be that you use the formkey as translationkey ?
Well... this would not work when you have the same key more than once as you
described.
This is the reason why translations are always done on the output. When the
translation does not work in your case, then "isEmpty" would be returned
instead of the messageid "Value is required"... not really a wished
behaviour :-/
Use the message to translate as messageid and not the array-key. This is
really a no-no. You see what the problem with this is...
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Xavier Vidal Piera" <[EMAIL PROTECTED]>
To: "Thomas Weidner" <[EMAIL PROTECTED]>
Cc: "Zend Framework General" <[email protected]>
Sent: Monday, April 28, 2008 4:33 PM
Subject: Re: [fw-general] Overriding Zend_Validate messages
Ok, let's see.
I have a form with a Text input, a Password input and a Checkbox.
The "Zend_Validate_NotEmpty" validator has a message id "isEmpty".
In my translations file i have a translation for the "isEmpty" key, for
example, "Value is required".
When i setup the form, i call the "Zend_Form::setDefaultTranslator(...)"
to
pass my Zend_Translate object.
Ok, at the moment, every "Required" field error will throw my translated
message.
But, i need to have a different message when the checkbox is not set.
Althought i can call "setMessage" and override the template message in the
NotEmpty validator on the Checkbox form element, my new message will be
override later by the Translator because is using the same key.
On Mon, Apr 28, 2008 at 3:36 PM, Thomas Weidner <[EMAIL PROTECTED]>
wrote:
Xavier,
I quite dont understand your problem.
When doing a translation with Zend_Translate all inputs are translated to
defined output.
When you don't want something to be translated then don't call
Zend_Translate on it.
Of course will Zend_Translate translate all given messageids... that's
the
reason why we created it. :-)
There is no way of switching off translation for particular messageids
because you will eighter NOT CALL Zend_Translate on them of simply have
no
translation for this messageids.
It would be better when you give some examplecode so your problem is
reproducable.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message ----- From: "Xavier Vidal Piera" <
[EMAIL PROTECTED]>
To: "Zend Framework General" <[email protected]>
Sent: Monday, April 28, 2008 2:04 PM
Subject: [fw-general] Overriding Zend_Validate messages
Hi
>
> We're using a Zend_Translate object as a default translator for our
> Zend_Form objects.
>
> In this Translation object we have all our common translations but,
> sometimes we want to override a validation error message with the
> method
> "$v->setMessage()" but looking at the source code we can see that
> Zend_Translate always replaces the messages althought we've override
> the
> validator default message template.
>
> Is there any way to override these message templates without disabling
> the
> Form's default translator and without extending validators?
>
> Thanks
>
> --
> Xavier Vidal Piera
> Enginyer Tècnic Informàtic de Gestió
> Tècnic Especialista Informàtic d'equips
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> http://web.xaviervidal.net
> 610.68.41.78
>
>
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://web.xaviervidal.net
610.68.41.78