develoid / translator-bundle
Translator bundle for symfony2 - Translate any text via google, microsoft, yandex translate api
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 142
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 3
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=5.4
- guzzlehttp/guzzle: ~6.0
- symfony/framework-bundle: ~2.3|~3.0
- yandex/translate-api: 1.5.*
This package is not auto-updated.
Last update: 2020-05-29 18:39:22 UTC
README
Translate any text via google, microsoft and yandex translate api.
Installation
Add to composer.json
:
"develoid/translator-bundle": "dev-master"
Add bundle to app/AppKernel.php
:
<?php // ... $bundles = array( //... new Develoid\TranslatorBundle\DeveloidTranslatorBundle() );
Setup to app/config/config.yml
develoid_translator: default: google google: api_key: %google_translator_api_key% yandex: api_key: %yandex_translator_api_key% microsoft: api_key: %microsoft_api_key%
Usage
Translate text
<?php // Symfony Controller // ... // Translate text via Google $translation = $this->get('develoid_translator.google_translator')->translate('text', 'en', 'fr'); // Translate text via Microfost $translation = $this->get('develoid_translator.microsoft_translator')->translate('text', 'en', 'fr'); // Translate text via Yandex $translation = $this->get('develoid_translator.yandex_translator')->translate('text', 'en', 'fr');
Get voice of text
Google and Yandex doesn't support speak method
Get voice via Microsoft translator:
<?php // raw voice $voice = $this->get('develoid_translator.microsoft_translator')->speak('text', 'en'); file_put_contents('voice.mp3', $voice);
Detect language
<?php // Detect language via Google $language = $this->get('develoid_translator.google_translator')->detect('text'); // Detect language via Microfost $language = $this->get('develoid_translator.microsoft_translator')->detect('text'); // Detect language via Yandex $language = $this->get('develoid_translator.yandex_translator')->detect('text');