GoogLang

This script facilitates translation of web pages on your website using Google's Language Tools.

<?php
/*************************************************************************************************************************
*
* Name: GoogLang
* Code developed by: Tomas J. Fulopp ( http://vacilando.net/tf )
* Source code: http://vacilando.net/node/264605
* First created: 20040321. Last update: 20040328. Version: 1.1
* If you have any comment, bug report, or question, please don't hesitate to contact me: i n f o AT vacilando DOT n e t
*
* This script facilitates translation of web pages on your website using Google's Language Tools ( http://translate.google.com ).
* Just copy and paste it into your pages. You can obviously replace the words by images of little flags or something else.
*
* The number of languages will presumably increase, so it's worth checking Google's Language Tools from time to time and adjust this script accordingly (in such case, please let me know, so that I update this script).
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The GNU General Public License is to be found at http://www.gnu.org/licenses/gpl.txt In case you do not find it, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*************************************************************************************************************************/

$thisurl = $_SERVER["PHP_SELF"]; // path coming after the domain... e.g. http://www.vacilando.org/research/migration/home.php becomes /research/migration/home.php
if ( $_SERVER['QUERY_STRING'] <> '') {
  $thisurl .= "?" . $_SERVER['QUERY_STRING']; // and we have to add every possible arguments...
}
$thisurl = 'http://' . $_SERVER["SERVER_NAME"] . $thisurl;
$thisurl = str_replace(":", "%3A", $thisurl);
$thisurl = str_replace("/", "%2F", $thisurl);
$thisurl = str_replace("&", "%26", $thisurl);

/*************************************************************************************************************************
* Usage:
* <a title="English to German" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=en%7Cde&hl=en&ie=UTF-8&oe=UTF-8">English to German</a> |
* <a title="English to Spanish" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=en%7Ces&hl=en&ie=UTF-8&oe=UTF-8">English to Spanish</a> |
* <a title="English to French" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=en%7Cfr&hl=en&ie=UTF-8&oe=UTF-8">English to French</a> |
* <a title="English to Italian" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=en%7Cit&hl=en&ie=UTF-8&oe=UTF-8">English to Italian</a> |
* <a title="English to Portuguese" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=en%7Cpt&hl=en&ie=UTF-8&oe=UTF-8">English to Portuguese</a> |
* <a title="German to English" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=de%7Cen&hl=en&ie=UTF-8&oe=UTF-8">German to English</a> |
* <a title="German to French" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=de%7Cfr&hl=en&ie=UTF-8&oe=UTF-8">German to French</a> |
* <a title="Spanish to English" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=es%7Cen&hl=en&ie=UTF-8&oe=UTF-8">Spanish to English</a> |
* <a title="French to English" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=fr%7Cen&hl=en&ie=UTF-8&oe=UTF-8">French to English</a> |
* <a title="French to German" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=fr%7Cde&hl=en&ie=UTF-8&oe=UTF-8">French to German</a> |
* <a title="Italian to English" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=it%7Cen&hl=en&ie=UTF-8&oe=UTF-8">Italian to English</a> |
* <a title="Portuguese to English" href="http://translate.google.com/translate?u=<?echo $thisurl;?>&langpair=pt%7Cen&hl=en&ie=UTF-8&oe=UTF-8">Portuguese to English</a>
*************************************************************************************************************************/
?>

Tomáš Fülöpp
Anderlecht, Belgium
March 21, 2004, March 28, 2004
Tomáš Fülöpp (2012)

Related linksRelated links

Tagstranslationlanguagegoogleproject
LanguageENGLISH Content typeARTICLELast updateOCTOBER 20, 2018 AT 01:46:40 UTC