Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Key in config.yml #7

Closed
anneachey opened this issue Dec 10, 2014 · 7 comments
Closed

API Key in config.yml #7

anneachey opened this issue Dec 10, 2014 · 7 comments

Comments

@anneachey
Copy link

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');
@eko
Copy link
Owner

eko commented Dec 10, 2014

@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

@anneachey
Copy link
Author

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 +

@eko
Copy link
Owner

eko commented Dec 10, 2014

@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

@anneachey
Copy link
Author

$ 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.*"
}

@eko
Copy link
Owner

eko commented Dec 10, 2014

@anneachey,

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

@anneachey
Copy link
Author

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

@eko
Copy link
Owner

eko commented Dec 10, 2014

@anneachey,

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

Do not hesitate if you have other issues.

Thank you

@eko eko closed this as completed Dec 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants