nofuture17/translate-api

Yandex.Translate API 客户端

2.0.0 2016-03-26 12:15 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:30:39 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

API 参考

版本控制

包版本对应于 API 版本。

安装

将以下内容添加到您的 composer.json

{
  "require": {
    "nofuture17/translate-api": "1.5.x"
  }
}

用法

获取您的 API 密钥

use Yandex\Translate\Translator;
use Yandex\Translate\Exception;

try {
  $translator = new Translator($key);
  $translation = $translator->translate('Hello world', 'en-ru');

  echo $translation; // Привет мир

  echo $translation->getSource(); // Hello world;

  echo $translation->getSourceLanguage(); // en
  echo $translation->getResultLanguage(); // ru
} catch (Exception $e) {
  // handle exception
}

许可证

MIT