140
GitHub - mouyong/translate: 集成百度翻译、有道云翻译、谷歌翻译、金山词霸翻译
source link: https://github.com/mouyong/translate
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
Translate
Requirement
PHP >= 5.5
Installation
$ composer require "mouyong/translate" -vvv
Usage
<?php use Yan\Translate\TranslateManager; $config = [ 'default' => 'google', 'drivers' => [ // 留空 'google' => [ 'app_id' => '', 'app_key' => '', ], 'baidu' => [ 'ssl' => true, 'app_id' => 'your-baidu-app_id', 'app_key' => 'your-baidu-app_key', ], 'youdao' => [ 'ssl' => false, 'app_id' => '你的有道智云 应用ID', 'app_key' => '你的有道智云 应用密钥', ], // 留空 'jinshan' => [ 'app_id' => '', 'app_key' => '', ] ], ]; $socialite = new TranslateManager($config); $result = $socialite->driver()->translate('测试', 'zh', 'en'); $result = $socialite->driver('google')->translate('测试', 'zh', 'en'); $result = $socialite->driver('baidu')->translate('测试', 'zh', 'en'); $result = $socialite->driver('youdao')->translate('测试', 'zh', 'en'); $result = $socialite->driver('jinshan')->translate('测试', 'zh', 'en'); var_dump($result); var_dump($result->getSrc()); var_dump($result->getDst()); var_dump($result->getOriginal());
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK