Translate-api

Wrapper for Yandex.Translate API

View the Project on GitHub yandex-php/translate-api

Yandex Translate API

Latest Stable Version Total Downloads Latest Unstable Version License

Api reference

Usage

Add into your composer.json:

{
  "require": {
    "nkt/yandex-translate": "~1.0"
  }
}
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