google/cloud-translate
Cloud Translation Client for PHP
Maintainers
Requires
- php: ^8.1
- google/cloud-core: ^1.57
- google/gax: ^1.38.0
Requires (Dev)
- erusev/parsedown: ^1.6
- phpdocumentor/reflection: ^5.3.3||^6.0
- phpdocumentor/reflection-docblock: ^5.3.3||^6.0
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: 2.*
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
This package is auto-updated.
Last update: 2026-06-17 23:18:22 UTC
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
- Understand the official documentation.
- Take a look at in-depth usage samples.
