Apr

14

Just like many other amazing Google products like Google Maps and Gmail, Google’s Language Tools serves as an excellent online translator that remains fast, effective, and (best of all) free. Another excellent online translator service is provided by Google’s rival, Yahoo! BabelFish, which is also highly efficient and free of charge.

I am going to present a very useful trick for things you can or may want to do with Google’s Language Tools using htaccess. You can make a automatic translation page via htaccess, in another words to say, you can serve alternate language versions of your site content with just a few lines in your htaccess file.

a. For instance, if you want Español and Deutsche version of your web page, in your site’s root .htaccess file, add the following lines of code:

# Automatic Language Translation
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://domain.com/$1 [R,NC]
RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://domain.com/$1 [R,NC]

Ensure that you have replaced the instance of “domain.com” with your domain name. You will also want to customize according to which languages you wish to provide translations. In each of the last two lines of the code above, there are two instances of the abbreviation for the language to be translated via that particular line. To customize your set of languages to be translated, simply edit both of the language abbreviations in each line according to the corresponding country abbreviations. Add or delete languages by adding or deleting their corresponding .htaccess expressions.

b. Assume you have a English version HTML page of example.html, you can add in the following two links.

<a href="example.html-es" title="Traducir a Español">Traducir a Español</a>
<a href="example.html-de" title="In Deutschen übersetzen">In Deutschen übersetzen</a>

Notice the two-digit language abbreviation hyphenated to the end of each anchor reference. Click on the link, and the users will be able to see the translated pages.



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

2 Comments so far

  1. gracie114 on June 3, 2008 9:31 am

    Google rocks!

  2. Lucki on December 5, 2008 3:44 pm

    this code isn’t working in my website. :(
    but the mod rewrite is active?

    what can be the problem?
    thx

Sponsors




Links