PHP code example of sayhe110 / easy-translation

1. Go to this page and download the library: Download sayhe110/easy-translation 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/ */

    

sayhe110 / easy-translation example snippets




use Sayhe110\Translation\Translation;

$key = 'XXXXXXXXXXXXXXXXXXXXXXXX';
$appid = 'XXXXXXXXXXXXXXXXXXXXXXXX';

$translation = new Translation($key, $appid);
$result = $translation->translation('我要翻译这段话');

print_r($result);

'translation' => [
     'key' => env('TRANSLATION_KEY'),
     'appid' => env('TRANSLATION_APPID'),
],

TRANSLATION_KEY=XXXXXXXXXXXXXXXXXXXXXXXX
TRANSLATION_APPID=XXXXXXXXXXXXXXXXXXXXXXXX

use Sayhe110\EasyTranslation\Translation;

public function translation(Translation $translation)
{
    return $translation->translation('我要翻译这段话。。');
}

public function translation()
{
    return app('translation')->translation('我要翻译这段话。。。');
}

translation($text, $from, $to, $canHttps)