-
Notifications
You must be signed in to change notification settings - Fork 438
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
Update Translate API Client #240
Conversation
* Support service account and application default credentials in Translate * Add support for the new `model` field.
LGTM, let others take a look also. |
@@ -50,7 +56,8 @@ public function testTranslate() | |||
$options = [ | |||
'source' => $expected['source'], | |||
'target' => 'de', | |||
'format' => 'text' | |||
'format' => 'text', | |||
'model' => 'base' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -134,6 +134,8 @@ public function __construct(array $config = []) | |||
* @type string $format Indicates whether the string to be translated is | |||
* either plain-text or HTML. Acceptable values are `html` or | |||
* `text`. **Defaults to** `"html"`. | |||
* @type string $model The model to use for the translation request. May | |||
* be `nmt` or `base`. **Defaults to** an empty string. | |||
* } | |||
* @return array A translation result including a `source` key containing |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides otherwise noted
* Please note that unlike most other Cloud Platform services Google Translate | ||
* requires a public API access key and cannot currently be accessed with a | ||
* service account or application default credentials. Follow the | ||
* Please note that while Google Translate supports authentication via service |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -92,20 +90,22 @@ class TranslateClient | |||
*/ | |||
public function __construct(array $config = []) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
$response = $this->connection->listTranslations($options + [ | ||
'q' => $strings, | ||
'key' => $this->key, | ||
'target' => $this->targetLanguage | ||
'target' => $this->targetLanguage, | ||
'model' => $options['model'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
'source' => $source, | ||
'input' => $strings[$key], | ||
'text' => $translation['translatedText'], | ||
'model' => (isset($translation['model'])) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Updated! PTAL @tmatsuo @dwsupplee @akeran |
Please hold this until 11/15.
model
field.Note that this change does not switch the operation from GET to POST.