PHP code example of ddctd143 / google-translate
1. Go to this page and download the library: Download ddctd143/google-translate 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/ */
ddctd143 / google-translate example snippets
php artisan vendor:publish \
--provider="Dedicated\GoogleTranslate\GoogleTranslateProvider" --tag=config
...
/**
* Google key for authentication
*/
'api_key' => 'YOUR-GOOGLE-API-KEY-GOES-HERE',
...
$translator = new Dedicated\GoogleTranslate\Translator;
$result = $translator->setSourceLang('en')
->setTargetLang('ru')
->translate('Hello World');
dd($result); // "Привет мир"