1<?php 2/* 3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 * use this file except in compliance with the License. You may obtain a copy of 5 * the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 * License for the specific language governing permissions and limitations under 13 * the License. 14 */ 15 16 17 /** 18 * The "detections" collection of methods. 19 * Typical usage is: 20 * <code> 21 * $translateService = new Google_TranslateService(...); 22 * $detections = $translateService->detections; 23 * </code> 24 */ 25 class Google_DetectionsServiceResource extends Google_ServiceResource { 26 27 /** 28 * Detect the language of text. (detections.list) 29 * 30 * @param string $q The text to detect 31 * @param array $optParams Optional parameters. 32 * @return Google_DetectionsListResponse 33 */ 34 public function listDetections($q, $optParams = array()) { 35 $params = array('q' => $q); 36 $params = array_merge($params, $optParams); 37 $data = $this->__call('list', array($params)); 38 if ($this->useObjects()) { 39 return new Google_DetectionsListResponse($data); 40 } else { 41 return $data; 42 } 43 } 44 } 45 46 /** 47 * The "languages" collection of methods. 48 * Typical usage is: 49 * <code> 50 * $translateService = new Google_TranslateService(...); 51 * $languages = $translateService->languages; 52 * </code> 53 */ 54 class Google_LanguagesServiceResource extends Google_ServiceResource { 55 56 /** 57 * List the source/target languages supported by the API (languages.list) 58 * 59 * @param array $optParams Optional parameters. 60 * 61 * @opt_param string target the language and collation in which the localized results should be returned 62 * @return Google_LanguagesListResponse 63 */ 64 public function listLanguages($optParams = array()) { 65 $params = array(); 66 $params = array_merge($params, $optParams); 67 $data = $this->__call('list', array($params)); 68 if ($this->useObjects()) { 69 return new Google_LanguagesListResponse($data); 70 } else { 71 return $data; 72 } 73 } 74 } 75 76 /** 77 * The "translations" collection of methods. 78 * Typical usage is: 79 * <code> 80 * $translateService = new Google_TranslateService(...); 81 * $translations = $translateService->translations; 82 * </code> 83 */ 84 class Google_TranslationsServiceResource extends Google_ServiceResource { 85 86 /** 87 * Returns text translations from one language to another. (translations.list) 88 * 89 * @param string $q The text to translate 90 * @param string $target The target language into which the text should be translated 91 * @param array $optParams Optional parameters. 92 * 93 * @opt_param string cid The customization id for translate 94 * @opt_param string format The format of the text 95 * @opt_param string source The source language of the text 96 * @return Google_TranslationsListResponse 97 */ 98 public function listTranslations($q, $target, $optParams = array()) { 99 $params = array('q' => $q, 'target' => $target); 100 $params = array_merge($params, $optParams); 101 $data = $this->__call('list', array($params)); 102 if ($this->useObjects()) { 103 return new Google_TranslationsListResponse($data); 104 } else { 105 return $data; 106 } 107 } 108 } 109 110/** 111 * Service definition for Google_Translate (v2). 112 * 113 * <p> 114 * Lets you translate text from one language to another 115 * </p> 116 * 117 * <p> 118 * For more information about this service, see the 119 * <a href="https://developers.google.com/translate/v2/using_rest" target="_blank">API Documentation</a> 120 * </p> 121 * 122 * @author Google, Inc. 123 */ 124class Google_TranslateService extends Google_Service { 125 public $detections; 126 public $languages; 127 public $translations; 128 /** 129 * Constructs the internal representation of the Translate service. 130 * 131 * @param Google_Client $client 132 */ 133 public function __construct(Google_Client $client) { 134 $this->servicePath = 'language/translate/'; 135 $this->version = 'v2'; 136 $this->serviceName = 'translate'; 137 138 $client->addService($this->serviceName, $this->version); 139 $this->detections = new Google_DetectionsServiceResource($this, $this->serviceName, 'detections', json_decode('{"methods": {"list": {"id": "language.detections.list", "path": "v2/detect", "httpMethod": "GET", "parameters": {"q": {"type": "string", "required": true, "repeated": true, "location": "query"}}, "response": {"$ref": "DetectionsListResponse"}}}}', true)); 140 $this->languages = new Google_LanguagesServiceResource($this, $this->serviceName, 'languages', json_decode('{"methods": {"list": {"id": "language.languages.list", "path": "v2/languages", "httpMethod": "GET", "parameters": {"target": {"type": "string", "location": "query"}}, "response": {"$ref": "LanguagesListResponse"}}}}', true)); 141 $this->translations = new Google_TranslationsServiceResource($this, $this->serviceName, 'translations', json_decode('{"methods": {"list": {"id": "language.translations.list", "path": "v2", "httpMethod": "GET", "parameters": {"cid": {"type": "string", "repeated": true, "location": "query"}, "format": {"type": "string", "enum": ["html", "text"], "location": "query"}, "q": {"type": "string", "required": true, "repeated": true, "location": "query"}, "source": {"type": "string", "location": "query"}, "target": {"type": "string", "required": true, "location": "query"}}, "response": {"$ref": "TranslationsListResponse"}}}}', true)); 142 143 } 144} 145 146 147 148class Google_DetectionsListResponse extends Google_Model { 149 protected $__detectionsType = 'Google_DetectionsResourceItems'; 150 protected $__detectionsDataType = 'array'; 151 public $detections; 152 public function setDetections(/* array(Google_DetectionsResourceItems) */ $detections) { 153 $this->assertIsArray($detections, 'Google_DetectionsResourceItems', __METHOD__); 154 $this->detections = $detections; 155 } 156 public function getDetections() { 157 return $this->detections; 158 } 159} 160 161class Google_DetectionsResourceItems extends Google_Model { 162 public $confidence; 163 public $isReliable; 164 public $language; 165 public function setConfidence( $confidence) { 166 $this->confidence = $confidence; 167 } 168 public function getConfidence() { 169 return $this->confidence; 170 } 171 public function setIsReliable( $isReliable) { 172 $this->isReliable = $isReliable; 173 } 174 public function getIsReliable() { 175 return $this->isReliable; 176 } 177 public function setLanguage( $language) { 178 $this->language = $language; 179 } 180 public function getLanguage() { 181 return $this->language; 182 } 183} 184 185class Google_LanguagesListResponse extends Google_Model { 186 protected $__languagesType = 'Google_LanguagesResource'; 187 protected $__languagesDataType = 'array'; 188 public $languages; 189 public function setLanguages(/* array(Google_LanguagesResource) */ $languages) { 190 $this->assertIsArray($languages, 'Google_LanguagesResource', __METHOD__); 191 $this->languages = $languages; 192 } 193 public function getLanguages() { 194 return $this->languages; 195 } 196} 197 198class Google_LanguagesResource extends Google_Model { 199 public $language; 200 public $name; 201 public function setLanguage( $language) { 202 $this->language = $language; 203 } 204 public function getLanguage() { 205 return $this->language; 206 } 207 public function setName( $name) { 208 $this->name = $name; 209 } 210 public function getName() { 211 return $this->name; 212 } 213} 214 215class Google_TranslationsListResponse extends Google_Model { 216 protected $__translationsType = 'Google_TranslationsResource'; 217 protected $__translationsDataType = 'array'; 218 public $translations; 219 public function setTranslations(/* array(Google_TranslationsResource) */ $translations) { 220 $this->assertIsArray($translations, 'Google_TranslationsResource', __METHOD__); 221 $this->translations = $translations; 222 } 223 public function getTranslations() { 224 return $this->translations; 225 } 226} 227 228class Google_TranslationsResource extends Google_Model { 229 public $detectedSourceLanguage; 230 public $translatedText; 231 public function setDetectedSourceLanguage( $detectedSourceLanguage) { 232 $this->detectedSourceLanguage = $detectedSourceLanguage; 233 } 234 public function getDetectedSourceLanguage() { 235 return $this->detectedSourceLanguage; 236 } 237 public function setTranslatedText( $translatedText) { 238 $this->translatedText = $translatedText; 239 } 240 public function getTranslatedText() { 241 return $this->translatedText; 242 } 243} 244