Translation Script

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:

  • German
  • Spanish
  • French
  • Italian
  • Portuguese
  • Russian
  • Japanese
  • Korean
  • Traditional Chinese
  • Simplified Chinese
  • Arabic (Not supported by Yahoo Babelfish)

Yahoo Babelfish currently supports the following destination languages:

  • German
  • Spanish
  • French
  • Italian
  • Portuguese
  • Russian
  • Japanese
  • Korean
  • Traditional Chinese
  • Simplified Chinese
  • Dutch (Not supported by Google Translate)
  • Greek (Not supported by Google Translate)

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

Support Files

The support files are usually stored in the /includes/ directory of your web site. These files are:

  • flags.shtml
  • flags-google.shtml
  • flags-yahoo.shtml
  • flags-all.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.

flags.shtml is a sample include file which calls all languages from the Google Translate engine, plus Dutch and Greek from the Yahoo Babelfish engine.

flags-all.shtml is a sample include file which calls all languages from both engines.

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.

The graphics files are usually stored in the /graphics/ directory of your web site.

Utilities

  • report.sh

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

  • Create a directory called /translate
  • Copy the files .htaccess, index.php, and translate.php into the /translate directory
  • Edit index.php to include your site name on line nine
  • Make a directory called g in the /translate directory
  • Change the permissions of the /lang/g directory to drwxrwxrwx (`chmod 777 g`)
  • Make a directory called y in the /translate directory
  • Change the permissions of the /lang/y directory to drwxrwxrwx (`chmod 777 y`)
  • Create a directory called /lang
  • Create a directory called /ylang
  • Copy the /lang/.htaccess file in the /lang/ directory
  • Copy the /ylang/.htaccess file in the /ylang/ directory
  • Create a directory called /graphics
  • Copy the graphics to your /graphics directory
  • Place the links from one of the flag files somewhere on your web page

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/index.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.

Upgrading from Prior Versions of the Script

If you want to upgrade from the last release of the translation script, you should do two things:

  • Move the contents of your Yahoo cache from /ylang/trans_cache/ to /translate/y/
  • Move the contents of your Google cache from /lang/trans_cache/ to /translate/g/

Download

The current revision of the script can be downloaded from here.

Current Issues

There are no known issues at this time.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists