|
|||
|
Is it possible to make Zend_Translate automatically create strings for translation according to it's request?
I mean for example I need to translate some form and it's error messages. Generally I don't know what exact message I will have and I desire to see translation source string of message in my translation file after first call of this. ... form code here ... $firstname = new Zend_Form_Element_Text(.....) $firstname->setLabel('Your firstname') ... form code .... After I set translator for this form it should call translation functions when I render form. After first render I want to see "Your firstname" in my translation file (for example with gettext adapter) and empty translation for this. Is it possible? PS. Why I ask this question? Primary because of usibility, secondary just imagine that I need to validate $firstname by LessThan Validator. It has a message template '%value%' is not less than '%max%', so actually as simple user I don't know what message used for this. Visually I see only "'[entered name]' is not less than '10'" for example and I don't know what to translate generally Last edited by OmeZ : 08-10-2008 at 11:59 PM. Reason: PostScriptum |
|
|||
|
Quote:
If you want the keys of the errors, you have to call your method after submitting the form. $form->getErrors() will return an array with all occured errors.
__________________
www.roetgers.org | Weblog, Screencasts and Tutorials |
|
|||
|
Beware that such a methodology is problematic in a production environment.
It will probably kill your performance.
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
|
|||
|
That shell script won't work in this case because there are no keywords which xgettext could find if you work with Zend_Form.
Quote:
__________________
www.roetgers.org | Weblog, Screencasts and Tutorials |
|
|||
|
look, actually I thought about to use translation interface itself to do all dirty work. Maybe it's better to use some cover under method _() in translator object which first will check context for exsiting translation, if not - add a key into .po, gettext etc. I suppose it should be very useful in all situation not only when I translate form or something else. Also it could be used in production because adding key action will be called only once. What you think?
|
|
|||
|
There is no need to add something additionally to check if a translation is available.
When you look into Zend_Translate you will see that there is a isTranslated() method. Why not simply use this ?
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
![]() |
| Thread Tools | |
| Display Modes | |
|
|