Apr
14
Google Text Translation Using htaccess
April 14, 2008 |
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
- Block people from Certain URL Using htaccess
- htaccess Remove the www From Domain URL
- Use htaccess with Site Maintenance Page
- Use htaccess for 404 Redirect
- Create Custom Error Pages Using htaccess PHP
- htaccess Explicitly Define Default Index File
- htaccess Permanently redirect file or directory
- htaccess gzip for Faster Loading and Bandwidth Saving
- Use htaccess to Fake Different File Extension
- Use htaccess to Deny Access Directory Listing
- htaccess Require the www For Domain URL
- htaccess Conditional Loop Redirect
- Set Local Timezone Using htaccess
- Remove File Extension Using htaccess
- Force Files Like PDF Download using htaccess
- Block IPs Using htaccess
- Use htaccess to Deny Access to hidden Files
- htaccess Limit the Number of Concurrent Visitors to your Website
- Useful mod_rewrite Resources
- htaccess Deny Diractory Access During a Specific Time
- Apache htaccess Prevent Users from Uploading and Executing Files
- Deny Access to inc Files Using htaccess
Comments
2 Comments so far



































Google rocks!
this code isn’t working in my website. :(
but the mod rewrite is active?
what can be the problem?
thx