Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cloud Translate Laravel Package

google/cloud-translate

Idiomatic PHP client for Google Cloud Translation. Supports V2 (handwritten) and V3 (generated) APIs to translate text, detect language, and manage datasets/models. Auth via Google Cloud credentials; install with Composer for easy integration.

View on GitHub
Deep Wiki
Context7

Google Cloud Translation for PHP

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());
}

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.

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

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport