google/cloud-translate

Cloud Translation Client for PHP

Package info

github.com/googleapis/google-cloud-php-translate

pkg:composer/google/cloud-translate

Statistics

Installs: 17 159 524

Dependents: 85

Suggesters: 7

Stars: 203

v2.3.1 2026-06-17 23:07 UTC

Requires

Suggests

  • 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.

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 4ccfb8fe24a6efa4472e619360e15eeb60f19f1b


README

Idiomatic PHP client for Translation.

👁 Latest Stable Version
👁 Packagist

NOTE: This repository is part of Google Cloud PHP. Any support requests, bug reports, or development contributions should be directed to that project.

Dynamically translates text between thousands of language pairs. The Cloud Translation API lets websites and programs integrate with the translation service programmatically. The Google Translation API is part of the larger Cloud Machine Learning API family.

Installation

To begin, install the preferred dependency manager for PHP, Composer.

Now install this component:

$ composer require google/cloud-translate

Authentication

Please see our Authentication guide for more information on authenticating your client. Once authenticated, you'll be ready to start making requests.

Sample

use Google\ApiCore\ApiException;
use Google\Cloud\Translate\V3\AdaptiveMtDataset;
use Google\Cloud\Translate\V3\Client\TranslationServiceClient;
use Google\Cloud\Translate\V3\GetAdaptiveMtDatasetRequest;

// Create a client.
$translationServiceClient = new TranslationServiceClient();

// Prepare the request message.
$request = (new GetAdaptiveMtDatasetRequest())
 ->setName($formattedName);

// Call the API and handle any network failures.
try {
 /** @var AdaptiveMtDataset $response */
 $response = $translationServiceClient->getAdaptiveMtDataset($request);
 printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
 printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}

Debugging

Please see our Debugging guide for more information about the debugging tools.

Version

This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority.

Next Steps

  1. Understand the official documentation.
  2. Take a look at in-depth usage samples.