Repository navigation
feat(translate): upgrade google/cloud-translate to ^2.0 - #2345
Conversation
|
Here is the summary of changes. You are about to delete 5 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request upgrades the Google Cloud Translate PHP samples from V2 to V3. Key changes include updating dependencies in composer.json to ^2.0, refactoring quickstart.php to use TranslationServiceClient and TranslateTextRequest, deleting legacy V2 sample files, and updating the corresponding tests and documentation. Feedback was provided on quickstart.php to improve output formatting readability by replacing the multiline string literal with printf and PHP_EOL.
| foreach ($response->getTranslations() as $translation) { | ||
| echo 'Text: ' . $text . ' | ||
| Translation: ' . $translation->getTranslatedText(); | ||
| } |
There was a problem hiding this comment.
The current output formatting uses a multiline string literal that lacks a trailing newline and can be difficult to read or maintain due to indentation. Using printf with PHP_EOL improves readability, ensures consistent newlines, and avoids formatting issues.
foreach ($response->getTranslations() as $translation) {
printf('Text: %s' . PHP_EOL, $text);
printf('Translation: %s' . PHP_EOL, $translation->getTranslatedText());
}
Upgrade our Translate samples to
google/cloud-translatev2:google/cloud-translateandgoogle/cloud-storageto^2.0translate/quickstart.phpfrom the removed V2TranslateClientto V3