haotx / translate-api
Support translate text
1.0.0
2016-06-08 04:55 UTC
Requires
- php: >=5.5.9
This package is not auto-updated.
Last update: 2024-11-09 20:17:44 UTC
README
TranslateApi
Translate 1.0.0 for PHP
This package is a wrapper of Translate Yandex adapted to work with PHP.
Installation
composer require "haotx/translate-api:1.*"
Usage translate Yandex
[Get your api key of Yandex] (https://tech.yandex.com/keys/get/?service=trnsl)
Translate the text (Don't support translate multi text)
use TranslateApi\Translate; use TranslateApi\TranslateYandex; $provider = new TranslateYandex($yourKeyApi); $translate = new Translate($provider); $result = $translate->translate('Hello world', 'en', 'vi');
Detect language the text
use TranslateApi\Translate; use TranslateApi\TranslateYandex; $provider = new TranslateYandex($yourKeyApi); $translate = new Translate($provider); $result = $translate->detect('Hello world');
Get supported languages
use TranslateApi\Translate; use TranslateApi\TranslateYandex; $provider = new TranslateYandex($yourKeyApi); $translate = new Translate($provider); $result = $translate->getSupportedLanguages(['ui' => 'en']);
Translate Yandex
See more api of Yandex look here.