Download the PHP package topaz2/translator without Composer
On this page you can find all versions of the php package topaz2/translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download topaz2/translator
More information about topaz2/translator
Files in topaz2/translator
Package translator
Short Description Library for making calls to the Microsoft Translator V2 API
License MIT
Homepage http://github.com/matthiasnoback/microsoft-translator
Informations about the package translator
PHP library for the Microsoft Translator V2 API
By Matthias Noback
Installation
Using Composer, add to composer.json
:
{
"require": {
"matthiasnoback/microsoft-translator": "dev-master"
}
}
Then using the Composer binary:
php composer.phar install
Usage
This library uses the Buzz browser to make calls to the Microsoft Translator V2 API.
You need to register your application at the Azure DataMarket and
thereby retrieve a "client id" and a "client secret". These kan be used to instantiate the AccessTokenProvider
on which
the MicrosoftTranslator
depends:
Optional: enable the access token cache
Each call to the translator service is preceded by a call to Microsoft's OAuth server. Each access token however, may be
cached for 10 minutes, so you should also use the built-in AccessTokenCache
:
The actual cache provider can be anything, as long as it implements the Cache
interface from the Doctrine Common library.
Making calls
Translate a string
Translate a string and get multiple translations
Detect the language of a string
Get a spoken version of a string
Tests
Take a look at the tests to find out what else you can do with the API.
To fully enable the test suite, you need to copy phpunit.xml.dist
to phpunit.xml
and replace the placeholder
values with their real values (i.e. client id, client secret and a location for storing spoken text files).
Related projects
There is a MicrosoftTranslatorBundle which makes the Microsoft translator available in a Symfony2 project.
There is also a MicrosoftTranslatorServiceProvider which registers the Microsoft translator and related services to a Silex application.
TODO
There are some more calls to be implemented, and also some more tests to be added.