Re: New class in PEAR: Translation
| From: | Radek Maciaszek | Date: | Tue, 01 Oct 2002 13:32:36 +0000 |
| Subject: | Re: New class in PEAR: Translation | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9748@lists.php.net to get a copy of this message | ||
Hi!
Lukas Smith wrote:
well i would not use a text string as your "base". What if you decide to change the english text for one of your clients? Maybe the client is addressing a younger audience so the text should be less formal etc. The base should be something more abstract like "mail_error" and also it would make sense to group the texts into something like general and modul specific. So you can say $t->get('mail_error', 'contact'); ommitting 'contact' would mean you want the general translation.Wojtek +1 for your class. But think you should change license :) BTW It's funny but i also had to wrote my own class for translations. I don't know it is good idea to add third class to translate but.. just a thought ;) Here are features of this class: It don't use sql insteed using files. First you have to create definition file, example: user.php: <?php require_once( "lib/SiteVars.php" ); $my_site = new SiteVars( "Your profile", "user" ); // SiteVars( $title, $site_code ); // $title - for translating pages, tranlators should know which page // they translate // $site_code - you must specify name of the translating module // after this we put every string index here $my_site->putVar( "title" ); $my_site->putVar( "error" ); $my_site->putVar( "login" ); $my_site->putVar( "pass" ); // etc return $my_site; ?> The next step is translating. In tranlating module (which i wrote) you have got listing of all modules by $site_code. Just choose which one you want to translate and in which language and you will get form with eg: "title", "error", "login", "pass" (if you choose "user"). Write your text to textareas and save. All data is saving to: [language_code]/work_copy/user.php in array format: <?php $translated["title"] = "My title"; $translated["error"] = "Some error"; return $translated; ?> After saving admin must confirm these changes so this file replace original one in: [language_code]/user.php. (in TODO list i have support for cvs here) If you translate your module in one language in next translations you will get in textareas this translation so it will be easy to translators tranlating some text to another language. In site where you want some translating: $site = new FileStatus( $site_code, $site_lang ); and just: print $site->get( "title" ); etc. I also cache these $site objects with Pear::Cache and upgrade this cache when some changes in translating module was done. In easy way i could write function: $site->get( "title", $site_lang ); If somebody want i could rewrite this code to pear standards. Very old project :)) Cheers! Chief