This tool was originally authored by Interlogic, and has been improved by DCT, f3ze, Sameer, myself, and Eric Schneider.
This tool enables you to automatically and transparently translate your web site using either Google Translate or Yahoo Babelfish.
Google Translate currently supports the following destination languages:
- Arabic
- Bulgarian
- Catalan
- Chinese - Simplified
- Chinese - Traditional
- Croatian
- Czech
- Danish
- Dutch
- English
- Filipino
- Finnish
- French
- German
- Greek
- Hebrew
- Hindi
- Indonesian
- Italian
- Japanese
- Korean
- Latvian
- Lithuanian
- Norwegian
- Polish
- Portuguese
- Romanian
- Russian
- Serbian
- Slovak
- Slovenian
- Spanish
- Swedish
- Ukrainian
- Vietnamese
Yahoo Babelfish currently supports the following destination languages:
- Chinese - Simplified
- Chinese - Traditional
- Dutch
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Requirements
- Apache (1.3 or 2.x)
- Apache mod_rewrite
- PHP cURL support
- PHP safe_mode disabled
Necessary Files
The files necessary to make this script run are usually stored in the /translate/ directory of your web site. These files are:
- .htaccess
- index.php
- translate.php
- tr_config.php
- tr_log.php
Example Files
The example files are usually stored in the /includes/ directory of your web site. These files are:
- flags-google.shtml
- flags-yahoo.shtml
flags-google.shtml is a sample include file which calls the Google Translate engine.
flags-yahoo.shtml is a sample include file which calls the Yahoo Babelfish engine.
Graphics
The script comes with an assortment of flag graphics. You can use these flags, replace these flags, or even use plain text links instead of these graphics.
A complete set of national flags is available in translate/graphics/.
A set of flags provided with older implementations of this script is available in translate/graphics-old/.
Utilities
report.sh
report.sh is a little script that counts the number of files in your cache for each language. The output looks like this:
Google:
Arabic: 1765
German: 1723
Spanish: 1743
French: 1724
Italian: 1722
Japanese: 1723
Korean: 1721
Portuguese: 1726
Russian: 1696
Chinese Simplified: 1730
Chinese Traditional: 1699
Yahoo:
German: 1716
Spanish: 1710
French: 1709
Italian: 1715
Japanese: 1712
Korean: 1713
Portuguese: 1727
Russian: 1726
Chinese Simplified: 1720
Chinese Traditional: 1722
Dutch: 1736
Greek: 1707
report.sh expects all of your files to have the .html extension. If your files have another extension, you may have to edit the script.
Installation of the Script
Unzip the translation script into the DocumentRoot of your Apache virtual host
This will create these directories:
The lang and ylang directories will contain only one file each, .htaccess.
The translate directory will contain these files:
- .htaccess
- index.php
- translate.php
- tr_config.php
- tr_log.php
- report.sh
- readme.html
The translate directory will also contain these directories:
- g
- y
- graphics
- graphics-old
- includes
Ensure that the permissions of the /translate/g directory are drwxrwxrwx (`chmod 777 g`)
Ensure that the permissions of the /translate/y directory are drwxrwxrwx (`chmod 777 g`)
Edit translate/tr_config.php so that site_url is set to the URL of your web site.
Paste the contents of translate/includes/flags-google.shtml or translate/includes into your web page(s).
Configuration of the Script
The purpose of script configuration is to limit load on Yahoo and Google's translation engines, while at the same time providing visitors with the translations of your valuable content.
- In translate/tr_config.php, set your translator_cache_days on line six to the number of days that you want a cache file to be considered "current."
- In translate/.htaccess, configure any directories which you do not want to be translated.
- In translate/.htaccess, configure any file extensions which you do not want to be translated.
Bookmarks