From: Hani N. <ha...@na...> - 2004-09-08 09:09:36
|
Hi guys just a thought, When we did this stuff in OA we felt there was a strong requirement not to require gettext compiled into php. I am not sure it should have been such a strong requirement, but I did not want to have to install it at home and my stupid host did not have it installed at the time (he has it now). I also don't think it hurts anyway, so you might as well have it. We used this: http://phptal.sourceforge.net/bagpack/GetText/ I modified it slightly to remove the dependency to pear and also created a lang.php which created a few shortcut functions (like _() which used GetText). It also provides all this variable stuff. For example _set("name",$name); _set("occupation",$occupation); echo _("${name} works as a ${occupation}"); Once you guys settle on the approach I can give you a hand with some scripts although you would have to let me know which ones :) Good luck, Hani luc...@pd... wrote: >*This message was transferred with a trial version of CommuniGate(tm) Pro* >Hello all. >As stated in my previous message, I was trying to solve the problem of sentences with one or more parameters. As an example just consider -"Display ". $ModuleName . " options:"- in www_users. >Here's my proposed solution. >I am using special tags in the tobetranslated and translated sentence, i.e : >ENGLISH: Display __Parameter1__ options >ITALIAN: Mostra opzioni per il modulo __Parameter1__ > >when I have to translate this sentence I make this call: >translate('Display __Parameter1__ options',$ModuleName) > >Here's the definition of the function translate: >function translate($idOfLabelToBeTranslated) >{ > global $lang; > if ($lang[$idOfLabelToBeTranslated]!=null){ > $numargs = func_num_args(); > if($numargs >1){ > $arg_list = func_get_args(); > $returnString=$lang[$idOfLabelToBeTranslated]; > for ($i = 0; $i < $numargs; $i++) { > //echo "Argument $i is: " . $arg_list[$i] . "<br />\n"; > $returnString = str_replace('__Parameter'.$i.'__',$arg_list[$i],$returnString); > } > return $returnString; > } > else //number of arguments is 1 > return $lang[$idOfLabelToBeTranslated]; > } > else //there is no translated label in the array > return $idOfLabelToBeTranslated; >} > >As you can see it takes a variable number of arguments. If we have more than 1 argumentes, i.e. some parameters have to be inserted in the sentence, it simply gets the translated label, which contains the varios strings __Parameter1__ ... __ParameterN__. Then it substitutes the parameter string with the values passed as arguments. > >The main concern I still have on this solution is: >"__ParameterN__" as the tobereplaced string is cabled, thus every translator has to keep in mind to strictly use this formalism. Of course any suggestion on how to choose a formalism wich can be surely not confused with any real life word, will be appreciated. > > > >------------------------------------------------------- >This SF.Net email is sponsored by BEA Weblogic Workshop >FREE Java Enterprise J2EE developer tools! >Get your free copy of BEA WebLogic Workshop 8.1 today. >http://ads.osdn.com/?ad_idP47&alloc_id808&op=click >_______________________________________________ >Web-erp-developers mailing list >Web...@li... >https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > > > |