Wrapper for Yandex.Translate API
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
}
MIT