PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Pawan Adhikari   Small Google Translator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: SmallGoogleTranslator - Example
Class: Small Google Translator
Translate text using Google Traslate API
Author: By
Last change:
Date: 13 years ago
Size: 1,781 bytes
 

Contents

Class file image Download
<?php
   
   
include('../plugins/google.translate.inc');
   
   
   
/* The Header Definition For HTML, To Be Used In <head> of the HTML Document */
   
$utfCharSet = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
   
   
/* The Primary Text To Be Translated */
   
$txtToTranslate = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
   
   
$translateFromLanguage = 'English';
   
$translateToLanguage = 'German';
   
    echo
"<b>Original</b>: $txtToTranslate<br /><br />";
    echo
"<i>Translated from $translateFromLanguage to $translateToLanguage:</i><br /><br />";
   
   
$result = new SmallGoogleTranslator($txtToTranslate, $translateFromLanguage, $translateToLanguage);
    if (!
$result){
        echo
"Translation failed.";
    }else{
        echo
"<b>Translation</b>: $result";
    }
   
    echo
"<br/><br/>";
   
   
$translateFromLanguage = 'English';
   
$translateToLanguage = 'French';
   
    echo
"<b>Original</b>: $txtToTranslate<br /><br />";
    echo
"<i>Translated from $translateFromLanguage to $translateToLanguage:</i><br /><br />";
   
   
$result = new SmallGoogleTranslator($txtToTranslate, $translateFromLanguage, $translateToLanguage);
    if (!
$result){
        echo
"Translation failed.";
    }else{
        echo
"<b>Translation</b>: $result";
    }
   
   
   
?>