justmd5/deeplx

deeplx 是一个简单快速的免费 Deepl 库,用于 PHP。

v1.7.0 2024-08-29 03:38 UTC

This package is auto-updated.

Last update: 2024-08-29 06:29:03 UTC


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');

贡献

您可以通过以下三种方式之一进行贡献:

  1. 使用 问题跟踪器 提交错误报告。
  2. 问题跟踪器 上回答问题或修复错误。
  3. 贡献新功能或更新 wiki。

代码贡献过程不是很正式。您只需确保遵循 PSR-0、PSR-1 和 PSR-2 编码指南。任何新的代码贡献都必须附有适用的单元测试。

许可

MIT