Re: simplifying raiseError
| From: | Brent Cook | Date: | Wed, 10 Jul 2002 18:20:48 +0000 |
| Subject: | Re: simplifying raiseError | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7647@lists.php.net to get a copy of this message | ||
On Wed, 10 Jul 2002, Tomas V.V.Cox wrote:
> Brent Cook wrote:
> >
> > > A current limitation of the PEAR Error system is that it can't handle
> > > dynamic error messages: "The max value is [int]" (and of course [int]
> > > may change its position in the string in a different language). So I
> > > guess we would need a system that can accept data to "bind" to the error
> > > message and placeholders for the messages (I'd vote for the gettext
> > > style):
> > >
> > > $this->raiseError("The max value is %s", null, null, $max);
> > > or
> > > $this->raiseError(null, SOME_CODE, null, $max);
> >
> > Do I misunderstand you, or would this not suffice?
> >
> > $this->raiseError("The max value is $max");
> >
>
> Please re-read the part of this email I wrote. When $max is dynamic you
> can't integrate it into a translation system. For ex:
>
> english: "The max value is %s"
> spanish: "%s es el valor maximo"
>
> One can't have "$max" strings to translate :-) Of course if the string
> is static: "Max value reached", just doing $this->raiseError("Max value
> reached") will be enough.
So, something like this then:
$this->raiseError(sprintf(_("The max value is %s"), $max));
Would not the gettext() call move the %s for processing with sprintf()?
- Brent