2017 © Pedro Peláez
 

symfony-bundle translate-bundle

Translate bundle

image

knone/translate-bundle

Translate bundle

  • Saturday, July 25, 2015
  • by KNone
  • Repository
  • 2 Watchers
  • 3 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

KNoneTranslateBundle

This bundle for Symfony2 applications, which translate some text in your application using different translator-services, (*1)

Latest Stable Version Total Downloads License, (*2)

Build Status Scrutinizer Code Quality, (*3)

Installation

Download using composer:, (*4)

``` bash php composer.phar require knone/translate-bundle '1.0.*', (*5)


Enable the bundle in the kernel: ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new KNone\TranslateBundle\KNoneTranslateBundle(), ); }

Configure the KNoneTranslateBundle

KNoneTranslateBundle have two translator-providers:, (*6)

  1. google_web (use http://translate.google.com)
  2. yandex_api (http://api.yandex.com/translate/)

You need to set default provider in config.yml:, (*7)

``` yml //app/config/config.yml k_none_translate: default_provider: google_web, (*8)


If you want to use Yandex Api you need set api key ([get api key](http://api.yandex.com/key/form.xml?service=trnsl)): ``` yml //app/config/config.yml k_none_translate: default_provider: yandex_api providers: yandex_api: key: <api_key>

Using the KNoneTranslateBundle

You just can use service k_none_translate.translator. Example:, (*9)

``` php <?php ... // Some action in controller public function someAction() { /** @var KNone\TranslateBundle\Provider\ProviderInterface $translator */ $translator = $this->get('k_none_translate.translator'); $translation = $translator->translate('hello world', 'en', 'fr'); // you can set 'auto' as source language and translator will detect it //$translation = $translator->translate('hello world', 'auto', 'fr');, (*10)

$result = (string)$translation; // $result contains 'bonjour tout le monde'
$result = $translation->getResult(); // $result contains 'bonjour tout le monde'
$source = $translation->getSource(); // $source contains 'hello world'
$sourceLanguage = $translation->getSourceLanguage() // $sourceLanguage contains 'en'
$resultLanguage = $translation->getResultLanguage() // $resultLanguage contains 'fr'

} ```, (*11)

The Versions

25/07 2015

dev-master

9999999-dev http://i.knone.ru

Translate bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Krasnoyartsev

google translate yandex

29/06 2014

v1.0.0

1.0.0.0 http://i.knone.ru

Translate bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Krasnoyartsev

google translate yandex