yandex/translate-api

Client for Yandex.Translate API

1.5.2 2015-07-27 15:00 UTC

This package is not auto-updated.

Last update: 2024-04-15 02:26:55 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Api reference

Versioning

Package version corresponds to the version of the API.

Installation

Add into your composer.json:

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

Usage

Get your own api key

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
}

License

MIT