justmd5/deeplx

deeplx is a simple and fast free deepl library for PHP.

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

This package is auto-updated.

Last update: 2024-11-29 06:58:18 UTC


README

deeplx is a simple and fast free deepl library for PHP.

Installing

$ composer require justmd5/deeplx -vvv

Usage

<?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);
}

without verify

\Justmd5\DeeplX\DeepLTranslator::withoutVerifying()->en2zh('hello');

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT