PHP code example of diankemao / translate

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

    

diankemao / translate example snippets




use Diankemao\Translate\Translate;
use Diankemao\Translate\Strategies\OrderStrategy;

$config = [
    // 可选
    'strategy' => OrderStrategy::class,
    'gateways' => [
        'baidu' => [
            'appid' => 'xxxx',
            'appsecret' => 'xxxx',
        ],
        'youdao' => [
            'appid' => 'xxxx',
            'appsecret' => 'xxxx',
        ],
    ],
    
];

$t = new Translate($config);

// 翻译
echo $t->trans("你好");