-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Fixes a typo in docs PiperOrigin-RevId: 591019768 Source-Link: googleapis/googleapis@cf5b5fc Source-Link: googleapis/googleapis-gen@53c2d23 Copy-Tag: eyJwIjoiVHJhbnNsYXRlLy5Pd2xCb3QueWFtbCIsImgiOiI1M2MyZDIzNmExYjZhYWFlNDBhNDE0ZWZjZWExMTlkOTI1NTE4MzM1In0=
- Loading branch information
1 parent
0c1cbf9
commit cf2a0b7
Showing
44 changed files
with
6,509 additions
and
173 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
89 changes: 89 additions & 0 deletions
89
Translate/samples/V3/TranslationServiceClient/adaptive_mt_translate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START translate_v3_generated_TranslationService_AdaptiveMtTranslate_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Translate\V3\AdaptiveMtTranslateResponse; | ||
use Google\Cloud\Translate\V3\TranslationServiceClient; | ||
|
||
/** | ||
* Translate text using Adaptive MT. | ||
* | ||
* @param string $formattedParent Location to make a regional call. | ||
* | ||
* Format: `projects/{project-number-or-id}/locations/{location-id}`. Please see | ||
* {@see TranslationServiceClient::locationName()} for help formatting this field. | ||
* @param string $formattedDataset The resource name for the dataset to use for adaptive MT. | ||
* `projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}` | ||
* Please see {@see TranslationServiceClient::adaptiveMtDatasetName()} for help formatting this field. | ||
* @param string $contentElement The content of the input in string format. | ||
* For now only one sentence per request is supported. | ||
*/ | ||
function adaptive_mt_translate_sample( | ||
string $formattedParent, | ||
string $formattedDataset, | ||
string $contentElement | ||
): void { | ||
// Create a client. | ||
$translationServiceClient = new TranslationServiceClient(); | ||
|
||
// Prepare any non-scalar elements to be passed along with the request. | ||
$content = [$contentElement,]; | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var AdaptiveMtTranslateResponse $response */ | ||
$response = $translationServiceClient->adaptiveMtTranslate( | ||
$formattedParent, | ||
$formattedDataset, | ||
$content | ||
); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = TranslationServiceClient::locationName('[PROJECT]', '[LOCATION]'); | ||
$formattedDataset = TranslationServiceClient::adaptiveMtDatasetName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DATASET]' | ||
); | ||
$contentElement = '[CONTENT]'; | ||
|
||
adaptive_mt_translate_sample($formattedParent, $formattedDataset, $contentElement); | ||
} | ||
// [END translate_v3_generated_TranslationService_AdaptiveMtTranslate_sync] |
84 changes: 84 additions & 0 deletions
84
Translate/samples/V3/TranslationServiceClient/create_adaptive_mt_dataset.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START translate_v3_generated_TranslationService_CreateAdaptiveMtDataset_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Translate\V3\AdaptiveMtDataset; | ||
use Google\Cloud\Translate\V3\TranslationServiceClient; | ||
|
||
/** | ||
* Creates an Adaptive MT dataset. | ||
* | ||
* @param string $formattedParent Name of the parent project. In form of | ||
* `projects/{project-number-or-id}/locations/{location-id}` | ||
* Please see {@see TranslationServiceClient::locationName()} for help formatting this field. | ||
* @param string $formattedAdaptiveMtDatasetName The resource name of the dataset, in form of | ||
* `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset_id}` | ||
* Please see {@see TranslationServiceClient::adaptiveMtDatasetName()} for help formatting this field. | ||
*/ | ||
function create_adaptive_mt_dataset_sample( | ||
string $formattedParent, | ||
string $formattedAdaptiveMtDatasetName | ||
): void { | ||
// Create a client. | ||
$translationServiceClient = new TranslationServiceClient(); | ||
|
||
// Prepare any non-scalar elements to be passed along with the request. | ||
$adaptiveMtDataset = (new AdaptiveMtDataset()) | ||
->setName($formattedAdaptiveMtDatasetName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var AdaptiveMtDataset $response */ | ||
$response = $translationServiceClient->createAdaptiveMtDataset( | ||
$formattedParent, | ||
$adaptiveMtDataset | ||
); | ||
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedParent = TranslationServiceClient::locationName('[PROJECT]', '[LOCATION]'); | ||
$formattedAdaptiveMtDatasetName = TranslationServiceClient::adaptiveMtDatasetName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DATASET]' | ||
); | ||
|
||
create_adaptive_mt_dataset_sample($formattedParent, $formattedAdaptiveMtDatasetName); | ||
} | ||
// [END translate_v3_generated_TranslationService_CreateAdaptiveMtDataset_sync] |
70 changes: 70 additions & 0 deletions
70
Translate/samples/V3/TranslationServiceClient/delete_adaptive_mt_dataset.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START translate_v3_generated_TranslationService_DeleteAdaptiveMtDataset_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Translate\V3\TranslationServiceClient; | ||
|
||
/** | ||
* Deletes an Adaptive MT dataset, including all its entries and associated | ||
* metadata. | ||
* | ||
* @param string $formattedName Name of the dataset. In the form of | ||
* `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}` | ||
* Please see {@see TranslationServiceClient::adaptiveMtDatasetName()} for help formatting this field. | ||
*/ | ||
function delete_adaptive_mt_dataset_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$translationServiceClient = new TranslationServiceClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
$translationServiceClient->deleteAdaptiveMtDataset($formattedName); | ||
printf('Call completed successfully.' . PHP_EOL); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = TranslationServiceClient::adaptiveMtDatasetName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DATASET]' | ||
); | ||
|
||
delete_adaptive_mt_dataset_sample($formattedName); | ||
} | ||
// [END translate_v3_generated_TranslationService_DeleteAdaptiveMtDataset_sync] |
70 changes: 70 additions & 0 deletions
70
Translate/samples/V3/TranslationServiceClient/delete_adaptive_mt_file.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* GENERATED CODE WARNING | ||
* This file was automatically generated - do not edit! | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../vendor/autoload.php'; | ||
|
||
// [START translate_v3_generated_TranslationService_DeleteAdaptiveMtFile_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Translate\V3\TranslationServiceClient; | ||
|
||
/** | ||
* Deletes an AdaptiveMtFile along with its sentences. | ||
* | ||
* @param string $formattedName The resource name of the file to delete, in form of | ||
* `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}` | ||
* Please see {@see TranslationServiceClient::adaptiveMtFileName()} for help formatting this field. | ||
*/ | ||
function delete_adaptive_mt_file_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$translationServiceClient = new TranslationServiceClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
$translationServiceClient->deleteAdaptiveMtFile($formattedName); | ||
printf('Call completed successfully.' . PHP_EOL); | ||
} catch (ApiException $ex) { | ||
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Helper to execute the sample. | ||
* | ||
* This sample has been automatically generated and should be regarded as a code | ||
* template only. It will require modifications to work: | ||
* - It may require correct/in-range values for request initialization. | ||
* - It may require specifying regional endpoints when creating the service client, | ||
* please see the apiEndpoint client configuration option for more details. | ||
*/ | ||
function callSample(): void | ||
{ | ||
$formattedName = TranslationServiceClient::adaptiveMtFileName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DATASET]', | ||
'[FILE]' | ||
); | ||
|
||
delete_adaptive_mt_file_sample($formattedName); | ||
} | ||
// [END translate_v3_generated_TranslationService_DeleteAdaptiveMtFile_sync] |
Oops, something went wrong.