Download the PHP package zeliard91/google-translator-bundle without Composer
On this page you can find all versions of the php package zeliard91/google-translator-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package google-translator-bundle
PryonGoogleTranslatorBundle
This bundle provides a symfony service to interact with Google Translate API. https://developers.google.com/translate/v2/getting_started
To be able to translate sentences, you have to enable billing on your Google Cloud Console https://developers.google.com/translate/v2/pricing
Installation
Installation is a quick 3 step process:
- Download PryonGoogleTranslatorBundle using composer
- Enable the Bundle
- Configure your application's config.yml
Step 1: Download PryonGoogleTranslatorBundle using composer
Step 2: Enable the bundle
Enable the bundle in the kernel:
Step 3: Add your Google API Key in configuration
Usage
The bundle provides a service to your app in order to call the Google Translate API in REST.
Exemples
Get supported languages
Translate sentences
Be aware that Google restricts the use of this service by limiting the size of the query at 5K caracteres with the POST method (and 2K in GET). The number of queries is also limited to 128 if you pass an array for the third argument of the translate method.
The translate method detects if these limits are reached and call the API as many times as necessary which may result a long processing.
Form Type
A "translatorlanguage" Form Type is also present in this bundle. It is basically the same as the core "language" Form Type except from the choices list which is filled by the API.
Cache
You can cache the responses of the API with one of the subclasses of Doctrine\Common\Cache\CacheProvider
This can be done by specifying what you want to cache and with what in the configuration file. This is the default configuration :
HTTP Client Options
You can define default HTTP headesr for the REST client hitting the Google API :
See Guzzle doc for more information.
All versions of google-translator-bundle with dependencies
doctrine/cache Version ^1.0
guzzlehttp/guzzle Version ^6.2
symfony/form Version ^4.4|^5.2
symfony/config Version ^4.4|^5.2