PHP code example of aalfiann / google-translate-api-php
1. Go to this page and download the library: Download aalfiann/google-translate-api-php 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/ */
aalfiann / google-translate-api-php example snippets
use \aalfiann\GoogleTranslate;
$lang = new GoogleTranslate();
$lang->source = 'id';
$lang->target = 'en';
$lang->text = 'Selamat datang di kampung halamanku!';
$result = $lang->translate()->getText();
echo $result;
use \aalfiann\GoogleTranslate;
$lang = new GoogleTranslate();
$text = 'Arigatou!';
$result = $lang->setTarget('en')->setText($text)->translate()->getText();
echo $result;
composer