webcook / translator
Wrapper for various translator API services.
Installs: 3 407
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Language:JavaScript
pkg:composer/webcook/translator
Requires
- php: >=5.3.0
 
This package is not auto-updated.
Last update: 2025-11-04 07:04:07 UTC
README
This is a wrapper for various translate API's.
Installation
Add this line into your composer file.
require: "webcook/translator": "0.*@dev"
Implemented translate services
- Yandex
 - Google - not tested
 - Bing
 
Usage
$factory = new Webcook\Translator\ServiceFactory();
$service = $factory->build(
		Webcook\Translator\ServiceFactory::YANDEX,
		array(
			'key' => 'YOUR API KEY'
		)
	);
// returns list of available languages
$languages = $service->getLanguages();
// translate text
$translation = $service->translate('Hi, how are you?', 'en', 'cs');
Or you can use multiple settings in service factory.
$serviceFactory = new Webcook\Translator\ServiceFactory();
$serviceFactory->setSettings(array(
		\Webcook\Translator\ServiceFactory::YANDEX => array(
		    'key' => 'Yandex API key'
		),
		\Webcook\Translator\ServiceFactory::GOOGLE => array(
		    'key' => 'Google API key'
		),
		\Webcook\Translator\ServiceFactory::BING => array(
		    'clientId' => 'Bing client id',
		    'clientSecret' => 'Bing client secret'
		)
	    ));
$serviceYandex = $this->serviceFactory->build(\Webcook\Translator\ServiceFactory::YANDEX);
$serviceGoogle = $this->serviceFactory->build(\Webcook\Translator\ServiceFactory::GOOGLE);
$serviceBing = $this->serviceFactory->build(\Webcook\Translator\ServiceFactory::BING);
            
LICENSE
See LICENSE file.