HTML_QuickForm2: How to handle error message translation
| From: | Christian Weiske | Date: | Thu, 20 May 2010 17:15:57 +0000 |
| Subject: | HTML_QuickForm2: How to handle error message translation | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-53486@lists.php.net to get a copy of this message | ||
Hello Alexey,
> Yes, that's the way to go with QF2. We already implemented validate()
> method in InputFile element that handles errors from PHP's $_FILES
> array and outputs relevant error messages.
>
> (BTW, we need translations for these error messages)
The current way to translate error messages in InputFile.php is to
pass an array of error messages for every language one wants to have
and to set the preferred language in the element options.
While this approach solves the problem, it does not do that efficient,
nor does it scale well:
- All error messages translated in all languages need to be available
when creating the element. This is hard to accomplish when using i.e.
some database for translation storage; all translations would need to
be fetched from the DB and put into that array.
Many of those translations
- Setting the error messages *and* the preferred language has to be done
for every single input element - best would be to do that form-wise
or for the whole application.
I would like to have the possibility to "plug in" my own translation
system. QF2 would define an interface that a translation system class
needs to implement (i.e. "public function _($msg)"). An instance of the
translation class is passed to the quickform2 form object and will be
used whenever a message needs to be translated. QF2 would provide a
default implementation containing the error messages of the base
elements.
Thoughts?
--
Regards/Mit freundlichen Grüßen
Christian Weiske
-=≡ Geeking around in the name of science since 1982 ≡=-
Attachment: [application/pgp-signature] signature.asc
Attachment: [application/pgp-signature] signature.asc