An Object Oriented solution for dynamic, multilingual websites.The latest version of SiteTranslator can be downloaded form the SourceForge project page.
SiteTranslator is a tool which allows you to quickly and easily build multilingual websites.All the text rendered on the site is stored in a database, translators are able to login to the site and translate blocks of text interactively. For a full tutorial which details how this set of classes were developed, see my article on the Internet Jugglign Database (which is avaiable in 9 different languages!) - Creating multilingual websites
SiteTranslator consists of the following classes. Rather than document the methods of each in detail, I will provide an overview of the responsibilities of each class and give a few examples of how they may be used.
The following example shows how the SiteTranslator class is typically used.
<? //create an instance of SiteTranslator, the class keeps track of the user's language //preferences. Also it will handle language changes via the configurable GET variable require ("lib/SiteTranslator.php"); $translator = new SiteTranslator(); ?> <html> <head> <? //Output the character set meta tag <meta http-equiv="content-type" content="text/html; charset=<? echo $translator->getCharSet(); ?>"?> ?> <title> <? //Output the localised title for this page, suppressing the translation //HTML tag, because the title cannot contain HTML! echo $translator-?>getLocalisedText("title", true); ?> </title> </head> <body> <? //if the visitor to the page is logged in as a translator, provide a link to the logout page if ($translator->isLoggedIn()) echo '<a href="logout.php">Log out</a>'; //output the different languages which this site is available in. The flags provide hyperlinks //which allow the visitor to select their preferred language. echo $translator->showFlags("", false, $_SERVER["PHP_SELF"]); //output the text for this page echo $translator->getLocalisedText("front_page_introduction"); //output the navigation menu. Note the 'false' parameter passed to getLocalisedText. When //a translator browses this page, 'translate' links are appended to the localised text. We need //to suppress these links otherwise the following code will created nested <a> tags echo '<a href="home.php">' .$translator->getLocalisedText("menu_home", false) .'</a>'; echo '<a href="about.php">'.$translator->getLocalisedText("menu_about", false).'</a>'; echo '<a href="faq.php">' .$translator->getLocalisedText("menu_faq", false) .'</a>'; ?> </body> </html>
Although the page illustrated above is a little simple, it does show the key functionality of the SiteTranslator class. If you use this system within your site, I would strongly recommend that you place most of the above code, e.g. the SiteTranslator instantiation, the character set output, flag output etc... into your website template. You are using a template aren't you?
There are two different types of 'editors':
The framework used by the editors and translators is found in the 'translation' directory. These files use the SiteTranslatorAdmin class to edit, modify and update the text in the database. The following image shows the interface they use to edit the text on the website:
Full installation instructions are found in the README.txt file within the download package.
If you do use SiteTranslator within your website - please let me know.
Colin E. (email@example.com)