PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Ö. Karatag   karatag Google Translation   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example File to test the translation
Class: karatag Google Translation
Translate Web pages with Google Translator
Author: By
Last change:
Date: 16 years ago
Size: 810 bytes
 

Contents

Class file image Download
<?php
// Include the translator class
require_once('./translator.class.php');

$YourDomain = 'http://www.karatag.de';
$lg = 'de';

$gt = new translator();

$gt->setVar('url', 'http://'.$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
$gt->CurrentLanguage($lg);

$lp = $gt->langPair();

$turls = array();
if (
sizeof($lp) >= 1) {
  foreach (
$lp as $value) {
   
$turls[] = $gt->setTranslateUrl($lg.'|'.$value);
  }
}


// Now you can use the result
echo '<h1>&Uuml;bersetze mir diese Seite bitte!</h1>';

if (
sizeof($turls) > 0) {

  echo
'<br /><b>&Uuml;bersetzung:</b><br />';
  foreach (
$turls as $ti => $translation) {
    echo
'<a href="'.$translation.'">'.$gt->languages($lp[$ti]).'</a><br />';
  }
} else {
  echo
'No translation for this language.';
}

exit();
?>