/language-translation

自然语言翻译组件

Primary LanguagePHPMIT LicenseMIT

language-translation

A Natural language translation SD..

Build Status StyleCI build status Latest Stable Version Latest Unstable Version Total Downloads License

介绍

目前已支持有道平台

安装

$ composer require aliliin/language-translation dev-master  -vvv

使用

require_once __DIR__ . '/vendor/autoload.php';

use Aliliin\LanguageTranslation\Translation;

$config = [
    'provider' => 'youdao',
    'youdao' => [
        'provider' => [
            'app_key' => 'xxxxxxx',
            'sec_key' => 'xxxxxxxx',
        ],
        'language' => [ 
            'from' => 'zh-CHS',
            'to' => 'en',
        ]
    ],
];

$translation = new Translation($config);

获取翻译结果

$res = $translation->translation('高兴');

示例:

[
    "happy",
]

参数说明

 translation(string $language) 

-$language - 需要翻译的词语

License

MIT