1. Go to this page and download the library: Download eko/googletranslatebundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eko / googletranslatebundle example snippets
public function registerBundles()
{
$bundles = array(
...
new Eko\GoogleTranslateBundle\EkoGoogleTranslateBundle(),
);
...
return $bundles;
}
$detector = $this->get('eko.google_translate.detector');
$value = $detector->detect('Hi, this is my string to detect!');
// This will return 'en'
$translator = $this->get('eko.google_translate.translator');
$value = $translator->translate('Hi, this is my text to detect!', 'fr', 'en');
// This will return 'Salut, ceci est mon texte à détecter!'
$translator = $this->get('eko.google_translate.translator');
$value = $translator->translate('Hi, this is my text to detect!', 'fr');
// This will return 'Salut, ceci est mon texte à détecter!'
$translator = $this->get('eko.google_translate.translator');
$value = $translator->translate(array('Hi', 'This is my second text to detect!'), 'fr', 'en');
// This will return the following array:
// array(
// 0 => 'Salut',
// 1 => 'Ceci est mon second texte à détecter !',
// )
$translator = $this->get('eko.google_translate.translator');
$value = $translator->translate(array('Hi', 'This is my second text to detect!'), 'fr', 'en', true);
// This will return the following array:
// array(
// 0 => 'Salut',
// 1 => 'Ceci est mon second texte à détecter !',
// )