Rusty Spigot.

The computer science source

Archive for the ‘htaccess’ Category

On the fly translate with .htaccess

A neat trick I saw on corz.org is that you can do on the fly translation using .htacces and Google or Altavista translate.

By re-writing anything ending in -fr, for example, to the url of the french google translator. For example, the .htaccess will translate on the fly:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)-fr$ http://www.google.com/translate_c?hl=fr&sl=en&u=http://www.rustyspigot.com/$1 [r,nc]
RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://www.rustyspigot.com/$1 [r,nc]
RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://www.rustyspigot.com/$1 [r,nc]
RewriteRule ^(.*)-it$ http://www.google.com/translate_c?hl=it&sl=en&u=http://www.rustyspigot.com/$1 [r,nc]
RewriteRule ^(.*)-pt$ http://www.google.com/translate_c?hl=pt&sl=en&u=http://www.rustyspigot.com/$1 [r,nc]