Re: New class - how to contribute ?

From: Date: Wed, 18 Sep 2002 17:50:59 +0000
Subject: Re: New class - how to contribute ?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9175@lists.php.net to get a copy of this message
On 2002-09-18 19:29, while getting another beer from the fridge I saw a little yellow card, on which Brent Cook wrote::
So, is it fair to say that that this class is similar to PHP's built-in gettext functions in scope; the major difference being that it draws the translated strings from a database rather than a .po file (which is a type of database I suppose). I would like to see it able to get translation strings from other sources however, since not everyone who wants translation necesarily needs a relational database. What do you think? I like the approach of just translating strings rather than getting into a full-blown template system (for which we have several in PEAR already). That makes it more versatile in my opinion, since it would be appropriate for a PHP-GTK application too. But then again, that was the original intention of gettext. What is your opinion of the gettext functions? - Brent
To tell the truth - I naver used gettext functions... Maybe you're right this might be something like discovering the wheel from the beginning. However as far as I learned from the doc - gettext is the function for getting the translations of specific language from a flat file. Imagine that the site is quite large - then the opeartions on the flat files will be much slower then operating on the DB. And in such case - gettext gives you no alternative - you must use a flat file :) Of course - you can use several files - but imagine how difficult it can be to manage the strings located in the several (or even more then just several) files. Besides this class is not the very simple code, that when you want a translation will make a query (which can couse that on one page having 10 translated texts it would do 10 queries). It is designed as a class becouse when you're creating an object (usually on the beginning of the page) it gets all the strings needed for this page and keeps it in some kind of cache. So the query is done only once. As I can imagine the gettext function checks the file every time it wants to get a translated string. So if you have 10 texts to translate - it has to open the file, read the text and close it 10 times. And imagine what will happen if you have 10 000 texts ? There can be another approach - loading the full .po file into the memory - but what if the file is really large ? Why to use this memory, while you don't need to ? This memory can be helpful for another things - don't you think so ? Besides of all things above - my class has some additional functions that makes managing of the strings much easier, than managing the strings in the flat files. Summarizing - I think my class is similar to gettext, but it will be better for the large sites. Besides it has some mechanisms, that makes this class more optimized, then the gettext function. Regards Voyteck

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