eko / GoogleTranslateBundle

A Symfony bundle to deals with Google Translate API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Key in config.yml

anneachey opened this issue · comments

So I should just do a composer update right? The error still occurs.

My config.yml entry is like this:
eko_google_translate:
api_key: server_public_api_key_generated_in_google_developers_console

My controller code is:

$translator = $this->get('eko.google_translate.translator');
$value = $translator->translate($entity->getContent(), $language->getIsoCode(), 'en');

@anneachey,

I confirm than a simple composer update should fix the issue for Languages method. You should have:

▶ composer update eko/googletranslatebundle
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating eko/googletranslatebundle dev-master (ac90d27 => dfd84c9)
    Checking out dfd84c95150f5e917078f93cbb5e857868380ec0

I just tested your code (with hardcoded values) here:

        $translator = $this->get('eko.google_translate.translator');
        $value = $translator->translate('test', 'fr', 'en');

and here is the result (because I do not have an API key actually, so it's normal):

Client error response [url] https://www.googleapis.com/language/translate/v2?key=fake-api-key&q=test&source=en&target=fr [status code] 400 [reason phrase] Bad Request

However, I cannot reproduce your issue.

Can you please paste me the result of the following command: composer show eko/googletranslatebundle?

Thank you

The composer show result is:


name : eko/googletranslatebundle
descrip. : A Symfony bundle to deals with Google Translate API
keywords : api, bundle, detect, google, language, translate
versions : dev-master, * 1.1.0, 1.0.x-dev, 1.0.0
type : library
license : MIT
source : [git] https://github.com/eko/GoogleTranslateBundle.git dedd3f2
dist : [zip] https://api.github.com/repos/eko/GoogleTranslateBundle/zipball/dedd3f21c0651a1751572e7b582bf03291e7cdbc dedd3f2
names : eko/googletranslatebundle

autoload
psr-4
Eko\GoogleTranslateBundle\ => .

requires
guzzlehttp/guzzle 5.0.*@dev
php >=5.3.2
symfony/framework-bundle ~2.0


If it helps below is the stack trace:

Stack Trace

  1. in /var/www/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php at line 364 -
    continue;
    }
    throw new Iae("No method can handle the {$key} config key");
    }
    }
    }
  2. at MessageFactory ->applyOptions (object(Request), array('allow_redirects' => true, 'exceptions' => true, 'decode_content' => true, 'verify' => true, 'headers' => array('User-Agent' => 'Guzzle/5.0.3 curl/7.26.0 PHP/5.5.18-1~dotdeb.1'), 'key' => 'server_public_api_key_generated_in_google_developers_console', 'query' => '

    testing all good things

    ', 'source' => 'en', 'target' => 'es'))
    in /var/www/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php at line 97 +

@anneachey,

You're not up-to-date with latest tag commits.

Can you please run the following command and paste me the result?

composer update eko/googletranslatebundle --prefer-source

Thank you

$ composer update eko/googletranslatebundle --prefer-source
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Updating the "app/config/parameters.yml" file
Clearing the cache for the dev environment with debug true
Installing assets using the hard copy option
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
...
...
...

In the composer.json I have the require on the bundle as:
"require": {
"eko/googletranslatebundle": "1.1.*"
}

@anneachey,

Alright, I just released a tag 1.1.1, can you try it again please?

awesome! that worked perfectly! thank you so much :)

@anneachey,

Great, you're welcome, sorry for this issue and happy translating ;)

Do not hesitate if you have other issues.

Thank you