1. Insert the following variables:
# Configuration/constant variables: $GoogleTranslation
2. Add a variable-option to toggle the translation:
# Major options: $GoogleTranslation = 1; # 1 = with automatic Google-translation , 0 = no Google-translation
3. Include the following code within the subroutine GetFooterText:
sub GetFooterText {
(...)
$result .= '<br>' . &GetSearchForm();
## Patch: GoogleTranslation
$result .= $q->endform;
if ($GoogleTranslation) {
$result .= ' ' . &GetTranslateForm($id);
}
# END GoogleTranslation
(...)
}
4. Insert a new subroutine GetTranslateForm? under the subroutine GetSearchForm:
sub GetSearchForm {
(...)
}
## Patch: GoogleTranslation
sub GetTranslateForm {
my ($page) = @_;
my ($res) = '';
$res .= '<form action="http://translate.google.com/translate" target="self">';
#$res .= '<a HREF="http://www.google.com/"><img SRC="google.gif" ALT="Google" BORDER=0></a>'; # GooglePicture
$res .= '<input type="hidden" name="u" value="'.$SiteBase.'/wiki.pl?'.$page.'">';
$res .= T('Translation: ');
$res .= '<select name="langpair">';
$res .= '<option value="de|en">Englisch</option>';
$res .= '<option value="de|fr">Französisch</option>';
$res .= '</select>';
$res .= '<input type="hidden" name="hl" value="de">';
$res .= '<input type="hidden" name="ie" value="UTF-8">';
$res .= '<input type="hidden" name="oe" value="UTF-8">';
$res .= '<input type="hidden" name="prev" value="/language_tools">';
$res .= $q->submit('submit', T('Translate'));
$res .= $q->endform;
return $res;
}
# END GoogleTranslation
If you want to add other Google-Translations see here http://www.google.de/language_tools. You just have to change the code in the subroutine GetTranslateForm?.
<option value="en|de">English to German</option> <option value="en|es">English to Spanish</option> <option value="en|fr">English to French</option> <option value="en|it">English to Italian</option> <option value="en|pt">English to Portugese</option> <option value="de|en">German to English</option> <option value="de|fr">German to French</option> <option value="es|en">Spanish to English</option> <option value="fr|en">French to English</option> <option value="fr|de">French to German</option> <option value="it|en">Italian to English</option> <option value="pt|en">Portugese to English</option>If your native language is not german, you should change the "hl" form "de" to your home-language also:
<input type="hidden" name="hl" value="de">