Skip to content

Commit

Permalink
feat: Introduce Cloud Translation V3 client (#2366)
Browse files Browse the repository at this point in the history
* add synth script

* generate translate v3 client

* update README

* update composer files

* update docs site

* update test group name

* add to the README
  • Loading branch information
dwsupplee authored Oct 4, 2019
1 parent 0fb3d2f commit e6a4f17
Show file tree
Hide file tree
Showing 54 changed files with 8,029 additions and 4 deletions.
37 changes: 36 additions & 1 deletion Translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ composer require google/cloud
Please see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/master/AUTHENTICATION.md) for more information
on authenticating your client. Once authenticated, you'll be ready to start making requests.

### Sample
### Sample Using the Handwritten Client (Interacts with the V2 API)

```php
require 'vendor/autoload.php';
Expand Down Expand Up @@ -77,6 +77,41 @@ foreach ($languages as $language) {
}
```

### Sample Using the Generated Client (Interacts with the V3 API)

```php
require 'vendor/autoload.php';

use Google\Cloud\Translate\V3\TranslationServiceClient;

$translationClient = new TranslationServiceClient();
$content = ['one', 'two', 'three'];
$targetLanguage = 'es';
$response = $translationClient->translateText(
$content,
$targetLanguage,
TranslationServiceClient::locationName('[PROJECT_ID]', 'global')
);

foreach ($response->getTranslations() as $key => $translation) {
$separator = $key === 2
? '!'
: ', ';
echo $translation->getTranslatedText() . $separator;
}
```

### Choosing the Right Client for You

This component offers both a handwritten and generated client, used to access the V2 and V3 translation APIs, respectively.
Both clients will receive on-going support and feature additions, however, it is worth noting the streamlined nature of
the generated client means it will receive updates more frequently. Additionally, the generated client is capable of
utilizing gRPC for its transport (by installing the gRPC extension) while the handwritten client interacts over
REST & HTTP/1.1 only.

The handwritten client can be found under `Google\Cloud\Translate\TranslateClient`, whereas the generated client is
found under `Google\Cloud\Translate\V3\TranslationServiceClient`.

### Version

This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in
Expand Down
10 changes: 8 additions & 2 deletions Translate/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
"license": "Apache-2.0",
"minimum-stability": "stable",
"require": {
"google/cloud-core": "^1.32"
"google/cloud-core": "^1.32",
"google/gax": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0",
"squizlabs/php_codesniffer": "2.*",
"phpdocumentor/reflection": "^3.0",
"erusev/parsedown": "^1.6"
},
"suggest": {
"ext-grpc": "The gRPC extension enables use of the performant gRPC transport",
"ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions."
},
"extra": {
"component": {
"id": "cloud-translate",
Expand All @@ -22,7 +27,8 @@
},
"autoload": {
"psr-4": {
"Google\\Cloud\\Translate\\": "src"
"Google\\Cloud\\Translate\\": "src",
"GPBMetadata\\Google\\Cloud\\Translate\\": "metadata"
}
},
"autoload-dev": {
Expand Down
288 changes: 288 additions & 0 deletions Translate/metadata/V3/TranslationService.php

Large diffs are not rendered by default.

215 changes: 215 additions & 0 deletions Translate/src/V3/BatchTranslateMetadata.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions Translate/src/V3/BatchTranslateMetadata/State.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e6a4f17

Please sign in to comment.