justmd5 / deeplx
deeplx 是一个简单快速的免费 Deepl 库,用于 PHP。
v1.7.0
2024-08-29 03:38 UTC
Requires
- php: >=7.2||8.*
- ext-curl: *
- ext-json: *
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- jetbrains/phpstorm-attributes: ^1.0
- laravel/pint: ^1.10
- mockery/mockery: ^1.2
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.10
README
deeplx 是一个简单快速的免费 Deepl 库,用于 PHP。
安装
$ composer require justmd5/deeplx -vvv
使用
<?php require __DIR__.'/vendor/autoload.php'; $deeplx=new \Justmd5\DeeplX\DeepLTranslator(); try { //translate chinese to english var_dump($deeplx->zh2en("你好")); //output: // array(4) { // ["status"]=> // int(1000) // ["code"]=> // int(1000) // ["message"]=> // string(2) "ok" // ["data"]=> // string(12) "How are you?" // } //translate english to chinese var_dump($deeplx->en2zh("hello my friend.")); //output: //array(4) { // ["status"]=> // int(1000) // ["code"]=> // int(1000) // ["message"]=> // string(2) "ok" // ["data"]=> // string(24) "你好,我的朋友。" //} //normal translate func demo $result = $translator->translate('hello', 'ja')->result(); var_dump($result); //output: //array(4) { // ["status"]=> // int(1000) // ["code"]=> // int(1000) // ["message"]=> // string(2) "ok" // ["data"]=> // string(12) "こんにちわ" //} } catch (Exception $e) { var_dump($e); }
无需验证
\Justmd5\DeeplX\DeepLTranslator::withoutVerifying()->en2zh('hello');
贡献
您可以通过以下三种方式之一进行贡献:
代码贡献过程不是很正式。您只需确保遵循 PSR-0、PSR-1 和 PSR-2 编码指南。任何新的代码贡献都必须附有适用的单元测试。
许可
MIT