Re: Translation class proposal

From: Date: Sun, 22 Sep 2002 22:51:05 +0000
Subject: Re: Translation class proposal
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9323@lists.php.net to get a copy of this message
fyi here a short info about what the *current I18N class(es)* as far as what i have done concerning translation (i am not very deep into the stuff that Naoki Shima did) is capable of and what it was meant for the translation (now in the Message-dir) as i created it was intended mainly to work with X/HTML, it can surely be extended to work with gtk-stuff, which i think is necessary to have the right to call itself I18N :-) my actual intention was to give it a X/HTML-string (which might be the entire file) and translate stuff that is meant to be translated by - getting the source-language strings from a db (should be abstracted to work on other sources too, such as gettext, file, webservice, etc.) - looking for it in the ML-string and replace it by the destination- language string, which it gets from the db too I simply dont want to maintain a template/HTML file for each language, i want a translator-class to translate that for me (that's why SimpleTemplate also has a locale-option!). how does it detect what is meant to be translated? first it has pieces of regular expressions given which tell where to search for translatable string. such as inside > and < and in the "value" of an input-tag. that's how it does it now. so the following will be done:
    <b class="dontTranslateThis">translate me</b>
    <input value="translate me too" name="but DONT translate me">
so you can see that it tries to sort out what is really translatable, in a reasonable way (may be the XML-Transformer would be perfect to use here, some guru got a hint for me? i would be interested)
furthermore it does also replace strings with dynamic strings inside, like
    <b>Hello user {$username}, how are you today?</b>
in the source language (english in this case) you have in your db-table the following string:
    Hello user .*, how are you today?
where .* is simply what the regular expression translates and the destination language has the following string in its table
    Hallo User $1, wie gehts dir heute?
(german). There you see that any part inside a string can be replaced furthermore the class can: - convert translated strings into proper HTML - do simple translation via a method call, such as $obj->translate('string to translate') - it should be easily useable with any template engine such as smarty, Flexy, etc. though i never tried it Wojciech, another thing i would like to suggest is that the translation-tool that enables you to manage the table with the translated strings should be a seperate application, i.e. in a tool-directory, since it is only needed/used seldomly and the code only takes up space in the actual working class. what do you think? wolfram Wojciech Zielin'ski wrote:
On 2002-09-20 18:40, while getting another beer from the fridge I saw a little yellow card, on which Wolfram Kriesing wrote:
Wojciech Zielin'ski wrote:
On 2002-09-20 12:55, while getting another beer from the fridge I saw a little yellow card, on which Wolfram Kriesing wrote:
i started the I18N translation stuff, sorry that i was not really actively replying yet, but i was reading all the posts with big interest. and i really want to have a look at your class this weekend. unfortuantely this week is really busy, but i am planning to have a look at it. and i see the need that we can either merge (into I18N) or add your class to pear, as from what i have read on the list. what i just want to propose is, that a common and flexible translation database-structure might be found.
Such database-structure is already implemented in Translation class. The class is indeed not only the PHP code, but also some SQL queries that are creating the DB structure for using with this class.
that's the problem i am talking about. in the current I18N implementation there is also a db-strucutre given.
So - as far as I understand you - you want Translation class and I18N to use the same DB structure ? Sounds interesting. The structure of the Translation class you see after running the queries contained by the example - in the example also you can find the queries. Some suggestions of how to improve that ? Regards Voyteck
-- Wolfram ... translating template system ... http://sourceforge.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth

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