1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\Translate\Resource; 19 20use Google\Service\Translate\DetectLanguageRequest; 21use Google\Service\Translate\DetectLanguageResponse; 22use Google\Service\Translate\SupportedLanguages; 23use Google\Service\Translate\TranslateTextRequest; 24use Google\Service\Translate\TranslateTextResponse; 25 26/** 27 * The "projects" collection of methods. 28 * Typical usage is: 29 * <code> 30 * $translateService = new Google\Service\Translate(...); 31 * $projects = $translateService->projects; 32 * </code> 33 */ 34class Projects extends \Google\Service\Resource 35{ 36 /** 37 * Detects the language of text within a request. (projects.detectLanguage) 38 * 39 * @param string $parent Required. Project or location to make a call. Must 40 * refer to a caller's project. Format: `projects/{project-number-or- 41 * id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global 42 * calls, use `projects/{project-number-or-id}/locations/global` or `projects 43 * /{project-number-or-id}`. Only models within the same region (has same 44 * location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is 45 * returned. 46 * @param DetectLanguageRequest $postBody 47 * @param array $optParams Optional parameters. 48 * @return DetectLanguageResponse 49 */ 50 public function detectLanguage($parent, DetectLanguageRequest $postBody, $optParams = []) 51 { 52 $params = ['parent' => $parent, 'postBody' => $postBody]; 53 $params = array_merge($params, $optParams); 54 return $this->call('detectLanguage', [$params], DetectLanguageResponse::class); 55 } 56 /** 57 * Returns a list of supported languages for translation. 58 * (projects.getSupportedLanguages) 59 * 60 * @param string $parent Required. Project or location to make a call. Must 61 * refer to a caller's project. Format: `projects/{project-number-or-id}` or 62 * `projects/{project-number-or-id}/locations/{location-id}`. For global calls, 63 * use `projects/{project-number-or-id}/locations/global` or `projects/{project- 64 * number-or-id}`. Non-global location is required for AutoML models. Only 65 * models within the same region (have same location-id) can be used, otherwise 66 * an INVALID_ARGUMENT (400) error is returned. 67 * @param array $optParams Optional parameters. 68 * 69 * @opt_param string displayLanguageCode Optional. The language to use to return 70 * localized, human readable names of supported languages. If missing, then 71 * display names are not returned in a response. 72 * @opt_param string model Optional. Get supported languages of this model. The 73 * format depends on model type: - AutoML Translation models: `projects 74 * /{project-number-or-id}/locations/{location-id}/models/{model-id}` - General 75 * (built-in) models: `projects/{project-number-or-id}/locations/{location- 76 * id}/models/general/nmt`, Returns languages supported by the specified model. 77 * If missing, we get supported languages of Google general NMT model. 78 * @return SupportedLanguages 79 */ 80 public function getSupportedLanguages($parent, $optParams = []) 81 { 82 $params = ['parent' => $parent]; 83 $params = array_merge($params, $optParams); 84 return $this->call('getSupportedLanguages', [$params], SupportedLanguages::class); 85 } 86 /** 87 * Translates input text and returns translated text. (projects.translateText) 88 * 89 * @param string $parent Required. Project or location to make a call. Must 90 * refer to a caller's project. Format: `projects/{project-number-or-id}` or 91 * `projects/{project-number-or-id}/locations/{location-id}`. For global calls, 92 * use `projects/{project-number-or-id}/locations/global` or `projects/{project- 93 * number-or-id}`. Non-global location is required for requests using AutoML 94 * models or custom glossaries. Models and glossaries must be within the same 95 * region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is 96 * returned. 97 * @param TranslateTextRequest $postBody 98 * @param array $optParams Optional parameters. 99 * @return TranslateTextResponse 100 */ 101 public function translateText($parent, TranslateTextRequest $postBody, $optParams = []) 102 { 103 $params = ['parent' => $parent, 'postBody' => $postBody]; 104 $params = array_merge($params, $optParams); 105 return $this->call('translateText', [$params], TranslateTextResponse::class); 106 } 107} 108 109// Adding a class alias for backwards compatibility with the previous class name. 110class_alias(Projects::class, 'Google_Service_Translate_Resource_Projects'); 111