PHP code example of yansongda / translate

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

    

yansongda / translate example snippets




use Yansongda\Translate\Translate;

$config = [
    // 可选
    'strategy' => Yansongda\Translate\Strategies\OrderStrategy::class,

    'gateways' => [
        'baidu' => [
            'appid' => 'xxxx',
            'appsecret' => 'xxxx',
        ],
        'youdao' => [
            'appid' => 'xxxx',
            'appsecret' => 'xxxx',
        ],
    ],
    
];

$t = new Translate($config);

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