Re: About I18N

From: Date: Fri, 22 Nov 2002 14:26:20 +0000
Subject: Re: About I18N
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2811@lists.php.net to get a copy of this message
Marcos Lois Bermúdez wrote:
I see the code of the I18N package and it use a database for tranlations, if the web server are heavy loaded and the pages are complex with a lot of strings to translate, this implementation can overload a bit the database??
that might be the case. what i am doing to prevent this is (1) translating the templates once and saving the compiled templates, so the translateMarkUpString() is only called once for each templates. and since translateMarkUpString() definitely eats performance, since it uses reg-exps heavily it should only be done once. what we are doing is compiling and translating all templates once and deliver only translated templates to the customer, so the translation process is done !!!for all static text!!! (2) for dynamic text i use the method simpleTranslate() (dynamic text for me is this text, which is not statically written in the template/HTML, such as error-messages, etc.) simpleTranslate() only looks up the DB once for each string u pass to it, which means simpleTranslate('How are you') is translated by SELECT * FROM table_srcLanguage s,table_destLanguage d WHERE s.text='How are you' AND s.id=d.id but if the text could not be translated i tell it to use the method translate() which does heavy action, that's true. translate() is actually only needed when the text has dynamic elements, such as 'Error: <Username> is not a valid user!' where <Username> is the dynamic part. there should be some optimizations here, suggestions are welcome :-) so actually the code for translating the dynamic stuff i use is this: function myTranslate( $string ) {
    global $translator;// instance of 'I18N_Message_Translate'
    $translated = $translator->simpleTranslate( $string , $locale );
    // no translation found :-( check if the text is dynamic
    if( $string == $translated )
    	$translated = $translator->translate( $string , $locale );
    return $translated;
} but anyway benchmark tests would be a great thing :-) regards -- Wolfram .. opensource @ vision:produktion ... http://opensource.visionp.de .. translating template engine .... http://sf.net/projects/simpletpl .. authentication system .... http://sf.net/projects/auth > At 20:26 20/11/2002 +0100, you wrote: > >> i am using the i18n in all my applications and it works fine. >> what the I18N_Message_Translate is meant for is to work against a db >> where you have a sourceLanguage and any number of destination >> languages. it really makes sense when using with a template engine >> that compiles the tempaltes and you just translate the compiled >> templates once. so they only need to be retranslated when a change in >> the template occured, which actually doesnt happen in a productive >> environment. >> examples are in the i18n package. >> >> the l10n package is also on the way, until it goes into pear you can >> download it from >> http://opensource.visionp.de/modules/project/l10n.php >> >> regards >> >> wolfram >> >> >> Marcos Lois Bermúdez wrote: >> >>> I want to make a portal in PHP, and use the PEAR code library, at >>> this point i use DB, SOAP, an such others. >>> I need to implement I18n, I10n, for the site, my main headsache are >>> the performance, in other proyects for message translation i use >>> set_locale and gettext >>> I see that a I18n packet are in PEAR, i question if anybody have test >>> it, and where i can get a example of translate messages, to check the >>> performence. >>> Is a good idea make a warper around the gettext function in the I18n >>> package? if it's interesting i can collaborate on them. >>> Any help are apreciated. >>> ----------------------------------------------- >>> Marcos Lois Bermúdez >>> marcos.lois@iqc-services.com >>> IQC - Services >>> Avda. Garcia Barbón, 90 / 4ºB >>> 36201 Vigo (Pontevedra) >>> Tel: +34 986.884.244 >>> Fax: +34 986.415.074 >>> http://www.iqc-services.com >>> ----------------------------------------------- >> >> >> >> -- >> Wolfram >> >> ... translating template engine .... >> http://sf.net/projects/simpletpl >> >> ... authentication system .... >> http://sf.net/projects/auth >> >> >> -- >> PEAR General Mailing List (http://pear.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > > ----------------------------------------------- > Marcos Lois Bermúdez > marcos.lois@iqc-services.com > IQC - Services > Avda. Garcia Barbón, 90 / 4ºB > 36201 Vigo (Pontevedra) > Tel: +34 986.884.244 > Fax: +34 986.415.074 > http://www.iqc-services.com > ----------------------------------------------- > > >

« previous php.pear.general (#2811) next »