Re: New class in PEAR: Translation

From: Date: Wed, 02 Oct 2002 08:59:03 +0000
Subject: Re: New class in PEAR: Translation
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9796@lists.php.net to get a copy of this message
Markus Wolff wrote:
The "get" method will look up the string in a database table that looks like this:
BASE (Primary Key)      | DE                            | FR
------------------------+-------------------------------+-------------------------
Translation is good     | Übersetzung ist gut           | Je ne parle pas Francais
You have % unread mails | Sie haben %s ungelesene Mails | The field "BASE" will always contain the original strings in the base language. This is the language that I´m using in my PHP code and will be English in most cases I guess. This way my code is very easy to read and understand. Also, it doesn´t matter on which page I am which is especially important as I sometimes need to output stuff in scripts when I can´t possibly know where I am at the moment. When a string is not yet in the database, it will be added for future reference. The other column names are identical to the language string that is passed to the translation class constructor. If no translation for a specific string is available (meaning the target language´s column is empty or doesn´t exist), the string will always be returned in the base language. This is a drop-dead-simple method of translation that is not only easy to use but also easy to maintain even with tools like phpMyAdmin. If someone here knows a class that already does this or something very similar, please drop me a line. If not, I´ll have to write this myself as I need something like this and have no use for page-oriented translation. Regards, Markus
may be u have a look at the I18N class Messages/Translate.php there is a method 'translate' which simply does what u need. ok, it takes the language as a second parameter, but i am sure u can write a simple wrapper to make it work the way u want. and the db structure is not 100% as u want it. but the way u described is the same as it works there :-) -- Wolfram .. translating template engine .... http://sf.net/projects/simpletpl .. authentication system .... http://sf.net/projects/auth

« previous php.pear.dev (#9796) next »