PHP code example of zeliard91 / google-translator-bundle

1. Go to this page and download the library: Download zeliard91/google-translator-bundle 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/ */

    

zeliard91 / google-translator-bundle example snippets

 bash
php composer.phar 
 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Pryon\GoogleTranslatorBundle\PryonGoogleTranslatorBundle(),
    );
}
 php


$languages = $this->get('pryon.google.translator')->getSupportedLanguages();
//->['en','fr','de','it',...]
 php


$translation = $this->get('pryon.google.translator')->translate('en','fr','I love Symfony');
//->"J'adore Symfony"

$translations = $this->get('pryon.google.translator')->translate('en','fr', array('I love Symfony', 'I like PHP'));
//->["J'adore Symfony", "J'aime PHP"]
 php


use Pryon\GoogleTranslatorBundle\Form\Type\LanguageType;
use Symfony\Component\Form\FormBuilderInterface;

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        // ...
        ->add('source', LanguageType::class, array(
            '