Translation2-alpha preview
| From: | Lorenzo Alberton | Date: | Sun, 04 Jan 2004 02:14:59 +0000 |
| Subject: | Translation2-alpha preview | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-24733@lists.php.net to get a copy of this message | ||
Eventually I found some time to work on PEAR::Translation2.
I tried to write a simple API without compromising any feature.
If you think something can be done better, I'm eager to listen
to your suggestions.
The first working alpha can be downloaded from this link:
http://cambiano.onlinein.it/pearzone/Translation2/Translation2-0.0.1.tgz
An in-depth usage example is provided in the tarball
(its output can be seen at this address: [1])
Online sources:
========================
main class:
http://cambiano.onlinein.it/pearzone/Translation2/Translation2.phps
container base class:
http://cambiano.onlinein.it/pearzone/Translation2/Container.phps
PEAR::DB container:
http://cambiano.onlinein.it/pearzone/Translation2/Container/db.phps
PEAR::MDB container:
http://cambiano.onlinein.it/pearzone/Translation2/Container/mdb.phps
============
There are still many things to do, such as the admin classes
(i.e. classes to add/remove languages and strings).
I'd appreciate some feedback on what I've done so far,
and suggestions on how to improve the base class.
There's a 'prefetch' options that acts as an optimization
switch (if true, db queries are minimized, if false =>
network traffic is minimized).
The internal cache is quite powerful, but of course
is just a cache-per-request, and not an external one
(which could be optionally implemented) which lives
between different page requests.
Table and column names are customizable.
You can specify a fallback language when a string
in the default lang is empty.
You can set the lang and the pageID at the top of the page,
so the get() method can be called with one parameter only
(the stringID), making site development faster.
Strings can have parameters whose format can
be defined in the options. Parameters are associative
arrays (not just ordered like Translation 1.x) to allow
a wider range of uses. For instance, strings like
"hi, &&user&&, how are you today?" and
"hi, &&1&&, how are you today?" are both valid.
I'd be glad to hear the opinion of a gettext user about
the feasibility of a gettext container for Translation2.
Known issue:
- When using getPage() directly, empty strings are
left as-is (without resorting to fallback language or
to default[text|errorMsg]
I'll add the class to PEAR CVS soon and hopefully
make an official alpha release within a week.
I will also roll out a release of Translation 1.x with
some bugs fixed. If you found other bugs still present
in current PEAR CVS files, please tell me and I
will include them in the release.
Best regards,
Lorenzo
[1] http://cambiano.onlinein.it/pearzone/Translation2/example.html