Skip to content

fix(deps): update dependency google/cloud-translate to v2 #2130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion translate/composer.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "google/translate-sample",
"type": "project",
"require": {
"google/cloud-translate": "^1.17"
"google/cloud-translate": "^2.0"
},
"require-dev": {
"google/cloud-storage": "^1.36"

Unchanged files with check annotations Beta

function translate_with_model(string $text, string $targetLanguage): void
{
$model = 'nmt'; // "base" for standard edition, "nmt" for premium
$translate = new TranslateClient();

Check failure on line 36 in translate/src/translate_with_model.php

GitHub Actions / staticanalysis

Instantiated class Google\Cloud\Translate\TranslateClient not found.
$result = $translate->translate($text, [

Check failure on line 37 in translate/src/translate_with_model.php

GitHub Actions / staticanalysis

Call to method translate() on an unknown class Google\Cloud\Translate\TranslateClient.
'target' => $targetLanguage,
'model' => $model,
]);
// $text = 'The text to translate.';
// $targetLanguage = 'ja'; // Language to translate to
$translate = new TranslateClient();

Check failure on line 39 in translate/src/translate.php

GitHub Actions / staticanalysis

Instantiated class Google\Cloud\Translate\TranslateClient not found.
$result = $translate->translate($text, [

Check failure on line 40 in translate/src/translate.php

GitHub Actions / staticanalysis

Call to method translate() on an unknown class Google\Cloud\Translate\TranslateClient.
'target' => $targetLanguage,
]);
print("Source language: $result[source]\n");
*/
function list_languages(string $targetLanguage = 'en'): void
{
$translate = new TranslateClient();

Check failure on line 34 in translate/src/list_languages.php

GitHub Actions / staticanalysis

Instantiated class Google\Cloud\Translate\TranslateClient not found.
$result = $translate->localizedLanguages([

Check failure on line 35 in translate/src/list_languages.php

GitHub Actions / staticanalysis

Call to method localizedLanguages() on an unknown class Google\Cloud\Translate\TranslateClient.
'target' => $targetLanguage,
]);
foreach ($result as $lang) {
function list_codes(): void
{
$translate = new TranslateClient();

Check failure on line 31 in translate/src/list_codes.php

GitHub Actions / staticanalysis

Instantiated class Google\Cloud\Translate\TranslateClient not found.
foreach ($translate->languages() as $code) {

Check failure on line 32 in translate/src/list_codes.php

GitHub Actions / staticanalysis

Call to method languages() on an unknown class Google\Cloud\Translate\TranslateClient.
print("$code\n");
}
}
*/
function detect_language(string $text): void
{
$translate = new TranslateClient();

Check failure on line 34 in translate/src/detect_language.php

GitHub Actions / staticanalysis

Instantiated class Google\Cloud\Translate\TranslateClient not found.
$result = $translate->detectLanguage($text);

Check failure on line 35 in translate/src/detect_language.php

GitHub Actions / staticanalysis

Call to method detectLanguage() on an unknown class Google\Cloud\Translate\TranslateClient.
print("Language code: $result[languageCode]\n");
print("Confidence: $result[confidence]\n");
}