Re: Translation class proposal

From: Date: Mon, 23 Sep 2002 12:20:36 +0000
Subject: Re: Translation class proposal
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9356@lists.php.net to get a copy of this message
Wojciech Zielin'ski wrote:
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 intetion was to create the class that works mostly with PHP files - not the X/HTML ones :) But such approach you took makes this engine template-oriented - so much larger and more complicated....
ok, i think it would be easy (and is also possible now, i think) to use it the way u do!
    <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
But this approach lets you use only 1 "untraslated" string inside string
you're translating. I use the &&x&& strings - where x can be a incrementing numbers - which lets me to not only make many "untraslated"
string inside my string, but also lets me change their order - e.g.: You've got 2 languages and you call $tr->gstr("STRING", array("Ala","cat")); for each of them:
1. en: &&1&& has a &&2&&            : Ala has a cat
2. de: &&1&& hat ein &&2&&            : Ala hat ein cat
3. pl: &&2&& jest posiadany przez &&1&&        " cat jest posiadany
przez Ala As you can see - the class was designed knowing that in several languages the inversions can occure. Your solution does not provide (as
far as I understood) changing the order of untranslated strings.
well my solution takes care of that too. sorry, i didnt mention it the correct source language string has to be:
    Hello user (.*), how is your (.*)?
in german
    Hallo User $1, wie geht's deinem $2?
where you can playce $1 and $2 in any place or order, as you have it too.
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?
That's a good idea - will have to make such separation :) Summarizing - I still think your solution is much more complex and it is
designed for much complex usage. I created the class only for translating specific, given strings. My proposal is maybe you would use my class inside the I18N class while doing the translation - and also my
class would be available separatelly - so simply I18N would be dependend
on Translation - and if someone would want to use only the translation thing - he would get my class, and if someone would like your aproach - he would get your class. What do you think ?
please have a look at the other solution from Naoki Shima, who has implemented something like yours, *i think* (please note: i am not sure :-) ). but if that is not the case we should add your solution too! therefore i would like to suggest to design some kind of common API/Interface which provides all translation methods. something like PEAR::DB where you can choose what to use. Do you know what i mean :-) ? or do you think that is too oversized? what about seperating the translation-tool from the actual translation-class? -- Wolfram ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth

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