Package version corresponds to the version of the API.
Add into your composer.json
:
{
"require": {
"yandex/translate-api": "~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
}
MIT