Find file
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (29 sloc) 2.73 KB


Transformer - A whole site translation resolution


Transformer is a whole site translation tool. If you want to translate a website, and host is in another domain, and want all the picture and style are all keep same as origin websites, Then this tool is for you.

If fact transformer is a reverse proxy cache server. But there is another layer above the cache: translation. So when some access come, the server first lookup if there is a translation for this page. If there do be a translation, it will serve the user with this translation. Or it will look for cached file and serve the cache to the user. If there is no cache, it will get page from the origin website, and after serve the user, the page will be write to the cache.

How to run?

Decide a domain for your translation site.

Assume your want to translate, than maybe you should register a domain like or .


    our $config = {
        host_map => {
            '' => '',
            '' => '',
            '' => '',
        cache_timeout => 600,
        cache_timeout_rand => 120,

Modify host_map , put your translation domain (eg. ) as a key, and origin domain (eg. as a value.

Start up

    starman --port 80 transformer.psgi

Change the port to what you need.

Access you translation site

Point you browser to (eg., you will see the same content as your origin website, nothing translated. But note the domain in you browser's address field, it is your translation domain. Now you translation website is just a reverse proxy cache for you origin website. Next, we will do translations.

Create translation scaffold

    perl data/origin/

The cached files are in data/origin/yourorigindomain/pathencoded.old, you can pick one of them and pass it as a parameter to script to create the scaffold. After running the script, you will get two files, one is data/origin/ (this file recored the file your translation based for. In the feture, the origin file and cached file maybe change, but this file doesn't change. So you can diff on .new and this file to see what have changed and update you translation.) The other file is data/trans/, this is where you do translation.

Do translation

Use your faverate editor to translate data/trans/, save it, and then access it in your brower. You will find the translation applied.