Re: Language class for PEAR?
| From: | Colin Viebrock | Date: | Tue, 02 Apr 2002 23:03:03 +0000 |
| Subject: | Re: Language class for PEAR? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-5174@lists.php.net to get a copy of this message | ||
> > I would use the gettext style here: "Welcome %s to %s".
>
> providing the gettext style is no problem. But how can the order of
> the dynamic text in the translation be determined? As in "Willkommen
> $2, $1!" which switches the order of $APPLICATION_NAME and $USERNAME
> in the into german translated message.
Sorry for the really delayed response, but this can be done as follows:
EN: $format="Welcome %s to %s!";
sprintf($format, $APP, $USER );
DE: $format = "Willkommen %2$s, %1$s!";
sprintf($format, $APP, $USER );
Bascially, that functionality is built into sprintf().
> A small admin-application needs to be written for that, right now i
> am still writing the translated text straight in the DB. :-)
> an example which uses this translation class is here:
>
> http://wolfram.kriesing.de/libs/php/examples/SimpleTemplate/fullFeatu
> red/ just push on the "german" link to translate part of the text. (i
> was to lazy to translate all of it :-)
> i hope that explains it a bit. you can also find the source and a
> DB-dump there
I've donated to the folks at HORDE (www.horde.org) an application called
Babel that provides a translation interface to files within a CVS
repository. While I use it personally for production sites, it's
integration into HORDE is still in the alpha-stage, I think. You can browse
the source at http://cvs.horde.org/cvs.php/babel.
- Colin