All Projects → eko → GoogleTranslateBundle

eko / GoogleTranslateBundle

Licence: MIT license
A Symfony bundle to deals with Google Translate API

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to GoogleTranslateBundle

facade-bundle
Support Facades for Symfony service
Stars: ✭ 17 (-61.36%)
Mutual labels:  symfony-bundle
SpBundle
SAML2 SP Symfony Bundle based on LightSAML
Stars: ✭ 62 (+40.91%)
Mutual labels:  symfony-bundle
SonataFormatterBundle
Symfony SonataFormatterBundle
Stars: ✭ 78 (+77.27%)
Mutual labels:  symfony-bundle
detectlanguage-java
Detect Language API Java Client
Stars: ✭ 23 (-47.73%)
Mutual labels:  detect-language
wordpress-bundle
Use Wordpress and Symfony together using a Symfony bundle
Stars: ✭ 30 (-31.82%)
Mutual labels:  symfony-bundle
TelegramBotBundle
Symfony Telegram Bot Bundle
Stars: ✭ 51 (+15.91%)
Mutual labels:  symfony-bundle
socketio
No description or website provided.
Stars: ✭ 23 (-47.73%)
Mutual labels:  symfony-bundle
DynamicParametersBundle
[UNMAINTAINED] Runtime retrieval of parameters from environment variables for Symfony
Stars: ✭ 42 (-4.55%)
Mutual labels:  symfony-bundle
ContentfulBundle
Symfony Bundle for the Contentful SDK.
Stars: ✭ 29 (-34.09%)
Mutual labels:  symfony-bundle
FkrCssURLRewriteBundle
A small assetic filter for symfony to fix all url paths at css documents to correct urls
Stars: ✭ 33 (-25%)
Mutual labels:  symfony-bundle
DroNet
DroNet: Efficient convolutional neural network detector for Real-Time UAV applications
Stars: ✭ 54 (+22.73%)
Mutual labels:  detector
OpcacheBundle
Displays the PHP OPcache status in the Symfony profiler toolbar.
Stars: ✭ 21 (-52.27%)
Mutual labels:  symfony-bundle
go-mnd
Magic number detector for Go.
Stars: ✭ 153 (+247.73%)
Mutual labels:  detector
queue-bundle
Symfony Queue Bundle
Stars: ✭ 31 (-29.55%)
Mutual labels:  symfony-bundle
cryptaddress.now
A minimal service to detect which cryptocurrency an address corresponds to.
Stars: ✭ 23 (-47.73%)
Mutual labels:  detector
phpfastcache-bundle
The symfony 3/Flex bundle for PhpFastCache integrating a phpfastcache service, a twig cache tag and a powerfull cache profiler integrated to the symfony profile
Stars: ✭ 19 (-56.82%)
Mutual labels:  symfony-bundle
workflower-bundle
A Symfony bundle for Workflower
Stars: ✭ 23 (-47.73%)
Mutual labels:  symfony-bundle
MsalsasVotingBundle
Provides voting/rating management for your Symfony project.
Stars: ✭ 14 (-68.18%)
Mutual labels:  symfony-bundle
bundle-dependency
Symfony Bundle Dependency Component
Stars: ✭ 18 (-59.09%)
Mutual labels:  symfony-bundle
LoginGateBundle
No description or website provided.
Stars: ✭ 57 (+29.55%)
Mutual labels:  symfony-bundle

GoogleTranslateBundle

SensioLabsInsight

Build Status Latest Stable Version Total Downloads

Features

  • Detect language used for a string
  • Translate a string from a source language to a target one
  • Translate a string into a target language by using language auto-detection (consume 1 more API call)
  • Retrieve all languages available on API and obtain language names in a given language
  • Profile detector / translate / languages list API calls in the Symfony profiler!

Installation

Add the bundle to your composer.json file:

{
    "require" :  {
        "eko/googletranslatebundle": "dev-master"
    }
}

Add this to app/AppKernel.php

<?php
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Eko\GoogleTranslateBundle\EkoGoogleTranslateBundle(),
        );

        ...

        return $bundles;
    }

Configuration

Edit app/config.yml

The following configuration lines are required:

eko_google_translate:
    api_key: <your key api string>

Usages

Detect a string language

Retrieve the detector service and call the detect() method:

$detector = $this->get('eko.google_translate.detector');
$value = $detector->detect('Hi, this is my string to detect!');
// This will return 'en'

Translate a string

Retrieve the translator service and call the translate() method:

$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!'

Translate a string from unknown language (use detector)

Retrieve the translator service and call the translate() method without the source (third) parameter:

$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!'

Translate multiple strings

Retrieve the translator service and call the translate() method with an array of your strings:

$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 !',
// )

Note that you can also use an "economic mode" to translate multiple strings in a single request which is better for your application performances.

Your translations will be concatenated in one single Google request. To use it, simply add true to the last argument:

$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 !',
// )

Obtain all languages codes available

Retrieve the languages service and call the get() method without any argument:

$languages = $this->get('eko.google_translate.languages')->get();
// This will return:
// array(
//     array('language' => 'en'),
//     array('language' => 'fr'),
//     ...
// )

Obtain all languages codes available with their names translated

Retrieve the languages service and call the get() method with a target language argument:

$languages = $this->get('eko.google_translate.languages')->get('fr');
// This will return:
// array(
//     array('language' => 'en', 'name' => 'Anglais'),
//     array('language' => 'fr', 'name' => 'Français'),
//     ...
// )

Notice: this will consume a detector API call.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].