PHP code example of ammarfaizi2 / googletranslate
1. Go to this page and download the library: Download ammarfaizi2/googletranslate library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ammarfaizi2 / googletranslate example snippets
quire "vendor/autoload.php"; // when using composer
use GoogleTranslate\GoogleTranslate;
// Translate from Indonesia to English.
$text = "Apa kabar?";
$from = "id"; // Indonesia
$to = "en"; // English
$st = new GoogleTranslate($text, $from, $to);
$result = $st->exec();
echo $result; // How are you?