Skip to content

Remiii/GoogleTranslateBundle

 
 

Repository files navigation

GoogleTranslateBundle Build Status

About Bundle

This bundle include service for translate with Google Translate and command which translate messages in your Bundles

Install

A) Add GoogleTranslateBundle to your composer.json

{
    "require": {
        "exercise/google-translate-bundle": "*"
    }
}

B) Enable the bundle

Enable the bundle in the your kernel:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Exercise\GoogleTranslateBundle\ExerciseGoogleTranslateBundle(),
    );
}

C) Configuration

Enter your private api key in configuration

# app/config/config.yml
exercise_google_translate:
    api_key: your_api_key

Usage

You can it use as a service

// Acme/DemoBundle/Controller/WelcomeController.php

public function indexAction() {

    ...

    $translator = $this->get('exercise_google_translate.translator');
    $translatedString = $translator->translate('Hello World!', 'en', 'fr');

    // Bonjour tout le monde!
    return new Response($translatedString);
}

Or you can use console command to translate messages

app/console gtranslate:translate [--override] [-d|--domains[="..."]] localeFrom localeTo [bundles]

Command arguments:

  • localeFrom: Locale from
  • localeTo: Locale to
  • bundles: Import translation for this specific bundles (comma separted) [optional]

Command options:

  • --override: Override existing translation [optional]
  • --domains (or -d): Only imports files for given domains (comma separated) [optional]

Example:

$ app/console gtranslate:translate en fr AcmeFooBundle
$ app/console gtranslate:translate en it --domains=messages,foo,bar
$ app/console gtranslate:translate en es AcmeFooBundle,AcmeBarBundle --domains=messages,foo,bar

Bug tracking

GoogleTranslateBundle uses GitHub issues. If you have found bug, please create an issue.

License

This bundle is under the MIT license. See the complete license in LICENSE.md

License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%