Re: Re: QuickForm2: messages and translations
| From: | Christian Weiske | Date: | Thu, 19 May 2011 05:34:20 +0000 |
| Subject: | Re: Re: QuickForm2: messages and translations | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-54285@lists.php.net to get a copy of this message | ||
Hello Alexey,
> >> A couple of questions Bertrand raised:
> >> 1) Is get() a good enough method name? Won't it lead to name
> >> conflicts in MessageProvider implementations?
> > That depends on the message provider implementation. If it's a class
> > with the single task of translating messages, get() is fine, maybe
> > even "->_()" like the gettext function is called.
> > If the class does several things, get() is obviously not the correct
> > way.
>
> Yes, that part is understandable. The question is: how probable is a
> class that will do several things at once?
Not probable, except in bad written apps :)
> I suspect message providers will be backed by some existing
> translation / locale package. These packages tend to follow the
> Factory pattern (see PEAR::Translation2, PEAR::I18Nv2) and it is hard
> to create a subclass implementing HTML_QuickForm2_MessageProvider.
> Proxy is much easier.
Yep.
> > By the way, this reminds me of specifying a callback instead of
> > the message provider object - the method naming problem does not
> > exist there.
>
> I think this will only work with PHP 5.3 and closures, as callback
> will need to keep some state (i.e. messages it is going to return).
> You definitely can instantiate an object and pass its method as a
> callback, but then why not pass the whole object instead?
It'd only free one from having a hard defined method name, nothing more.
> >> 2) Is it OK that get() can return an array of messages rather
> >> than a single message? Of course, if it can only return strings,
> >> we'll need 12 get() calls in a loop in Date element for getting
> >> the month names.
> > I do think so. QF2 could even provide a proxy provider for
> > simple message providers that don't accept multiple translation
> > requests at once, while one can always supply a sophisticated one.
>
> OK, lets keep it that way, then.
I'm with you here :)
--
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