[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/google/Google/Service/ -> Translate.php (source)

   1  <?php
   2  /*
   3   * Copyright 2010 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  
  18  /**
  19   * Service definition for Translate (v2).
  20   *
  21   * <p>
  22   * Lets you translate text from one language to another
  23   * </p>
  24   *
  25   * <p>
  26   * For more information about this service, see the API
  27   * <a href="https://developers.google.com/translate/v2/using_rest" target="_blank">Documentation</a>
  28   * </p>
  29   *
  30   * @author Google, Inc.
  31   */
  32  class Google_Service_Translate extends Google_Service
  33  {
  34  
  35  
  36    public $detections;
  37    public $languages;
  38    public $translations;
  39    
  40  
  41    /**
  42     * Constructs the internal representation of the Translate service.
  43     *
  44     * @param Google_Client $client
  45     */
  46    public function __construct(Google_Client $client)
  47    {
  48      parent::__construct($client);
  49      $this->servicePath = 'language/translate/';
  50      $this->version = 'v2';
  51      $this->serviceName = 'translate';
  52  
  53      $this->detections = new Google_Service_Translate_Detections_Resource(
  54          $this,
  55          $this->serviceName,
  56          'detections',
  57          array(
  58            'methods' => array(
  59              'list' => array(
  60                'path' => 'v2/detect',
  61                'httpMethod' => 'GET',
  62                'parameters' => array(
  63                  'q' => array(
  64                    'location' => 'query',
  65                    'type' => 'string',
  66                    'repeated' => true,
  67                    'required' => true,
  68                  ),
  69                ),
  70              ),
  71            )
  72          )
  73      );
  74      $this->languages = new Google_Service_Translate_Languages_Resource(
  75          $this,
  76          $this->serviceName,
  77          'languages',
  78          array(
  79            'methods' => array(
  80              'list' => array(
  81                'path' => 'v2/languages',
  82                'httpMethod' => 'GET',
  83                'parameters' => array(
  84                  'target' => array(
  85                    'location' => 'query',
  86                    'type' => 'string',
  87                  ),
  88                ),
  89              ),
  90            )
  91          )
  92      );
  93      $this->translations = new Google_Service_Translate_Translations_Resource(
  94          $this,
  95          $this->serviceName,
  96          'translations',
  97          array(
  98            'methods' => array(
  99              'list' => array(
 100                'path' => 'v2',
 101                'httpMethod' => 'GET',
 102                'parameters' => array(
 103                  'q' => array(
 104                    'location' => 'query',
 105                    'type' => 'string',
 106                    'repeated' => true,
 107                    'required' => true,
 108                  ),
 109                  'target' => array(
 110                    'location' => 'query',
 111                    'type' => 'string',
 112                    'required' => true,
 113                  ),
 114                  'source' => array(
 115                    'location' => 'query',
 116                    'type' => 'string',
 117                  ),
 118                  'format' => array(
 119                    'location' => 'query',
 120                    'type' => 'string',
 121                  ),
 122                  'cid' => array(
 123                    'location' => 'query',
 124                    'type' => 'string',
 125                    'repeated' => true,
 126                  ),
 127                ),
 128              ),
 129            )
 130          )
 131      );
 132    }
 133  }
 134  
 135  
 136  /**
 137   * The "detections" collection of methods.
 138   * Typical usage is:
 139   *  <code>
 140   *   $translateService = new Google_Service_Translate(...);
 141   *   $detections = $translateService->detections;
 142   *  </code>
 143   */
 144  class Google_Service_Translate_Detections_Resource extends Google_Service_Resource
 145  {
 146  
 147    /**
 148     * Detect the language of text. (detections.listDetections)
 149     *
 150     * @param string $q
 151     * The text to detect
 152     * @param array $optParams Optional parameters.
 153     * @return Google_Service_Translate_DetectionsListResponse
 154     */
 155    public function listDetections($q, $optParams = array())
 156    {
 157      $params = array('q' => $q);
 158      $params = array_merge($params, $optParams);
 159      return $this->call('list', array($params), "Google_Service_Translate_DetectionsListResponse");
 160    }
 161  }
 162  
 163  /**
 164   * The "languages" collection of methods.
 165   * Typical usage is:
 166   *  <code>
 167   *   $translateService = new Google_Service_Translate(...);
 168   *   $languages = $translateService->languages;
 169   *  </code>
 170   */
 171  class Google_Service_Translate_Languages_Resource extends Google_Service_Resource
 172  {
 173  
 174    /**
 175     * List the source/target languages supported by the API
 176     * (languages.listLanguages)
 177     *
 178     * @param array $optParams Optional parameters.
 179     *
 180     * @opt_param string target
 181     * the language and collation in which the localized results should be returned
 182     * @return Google_Service_Translate_LanguagesListResponse
 183     */
 184    public function listLanguages($optParams = array())
 185    {
 186      $params = array();
 187      $params = array_merge($params, $optParams);
 188      return $this->call('list', array($params), "Google_Service_Translate_LanguagesListResponse");
 189    }
 190  }
 191  
 192  /**
 193   * The "translations" collection of methods.
 194   * Typical usage is:
 195   *  <code>
 196   *   $translateService = new Google_Service_Translate(...);
 197   *   $translations = $translateService->translations;
 198   *  </code>
 199   */
 200  class Google_Service_Translate_Translations_Resource extends Google_Service_Resource
 201  {
 202  
 203    /**
 204     * Returns text translations from one language to another.
 205     * (translations.listTranslations)
 206     *
 207     * @param string $q
 208     * The text to translate
 209     * @param string $target
 210     * The target language into which the text should be translated
 211     * @param array $optParams Optional parameters.
 212     *
 213     * @opt_param string source
 214     * The source language of the text
 215     * @opt_param string format
 216     * The format of the text
 217     * @opt_param string cid
 218     * The customization id for translate
 219     * @return Google_Service_Translate_TranslationsListResponse
 220     */
 221    public function listTranslations($q, $target, $optParams = array())
 222    {
 223      $params = array('q' => $q, 'target' => $target);
 224      $params = array_merge($params, $optParams);
 225      return $this->call('list', array($params), "Google_Service_Translate_TranslationsListResponse");
 226    }
 227  }
 228  
 229  
 230  
 231  
 232  class Google_Service_Translate_DetectionsListResponse extends Google_Collection
 233  {
 234    protected $collection_key = 'detections';
 235    protected $detectionsType = 'Google_Service_Translate_DetectionsResourceItems';
 236    protected $detectionsDataType = 'array';
 237  
 238    public function setDetections($detections)
 239    {
 240      $this->detections = $detections;
 241    }
 242  
 243    public function getDetections()
 244    {
 245      return $this->detections;
 246    }
 247  }
 248  
 249  class Google_Service_Translate_DetectionsResourceItems extends Google_Model
 250  {
 251    public $confidence;
 252    public $isReliable;
 253    public $language;
 254  
 255    public function setConfidence($confidence)
 256    {
 257      $this->confidence = $confidence;
 258    }
 259  
 260    public function getConfidence()
 261    {
 262      return $this->confidence;
 263    }
 264  
 265    public function setIsReliable($isReliable)
 266    {
 267      $this->isReliable = $isReliable;
 268    }
 269  
 270    public function getIsReliable()
 271    {
 272      return $this->isReliable;
 273    }
 274  
 275    public function setLanguage($language)
 276    {
 277      $this->language = $language;
 278    }
 279  
 280    public function getLanguage()
 281    {
 282      return $this->language;
 283    }
 284  }
 285  
 286  class Google_Service_Translate_LanguagesListResponse extends Google_Collection
 287  {
 288    protected $collection_key = 'languages';
 289    protected $languagesType = 'Google_Service_Translate_LanguagesResource';
 290    protected $languagesDataType = 'array';
 291  
 292    public function setLanguages($languages)
 293    {
 294      $this->languages = $languages;
 295    }
 296  
 297    public function getLanguages()
 298    {
 299      return $this->languages;
 300    }
 301  }
 302  
 303  class Google_Service_Translate_LanguagesResource extends Google_Model
 304  {
 305    public $language;
 306    public $name;
 307  
 308    public function setLanguage($language)
 309    {
 310      $this->language = $language;
 311    }
 312  
 313    public function getLanguage()
 314    {
 315      return $this->language;
 316    }
 317  
 318    public function setName($name)
 319    {
 320      $this->name = $name;
 321    }
 322  
 323    public function getName()
 324    {
 325      return $this->name;
 326    }
 327  }
 328  
 329  class Google_Service_Translate_TranslationsListResponse extends Google_Collection
 330  {
 331    protected $collection_key = 'translations';
 332    protected $translationsType = 'Google_Service_Translate_TranslationsResource';
 333    protected $translationsDataType = 'array';
 334  
 335    public function setTranslations($translations)
 336    {
 337      $this->translations = $translations;
 338    }
 339  
 340    public function getTranslations()
 341    {
 342      return $this->translations;
 343    }
 344  }
 345  
 346  class Google_Service_Translate_TranslationsResource extends Google_Model
 347  {
 348    public $detectedSourceLanguage;
 349    public $translatedText;
 350  
 351    public function setDetectedSourceLanguage($detectedSourceLanguage)
 352    {
 353      $this->detectedSourceLanguage = $detectedSourceLanguage;
 354    }
 355  
 356    public function getDetectedSourceLanguage()
 357    {
 358      return $this->detectedSourceLanguage;
 359    }
 360  
 361    public function setTranslatedText($translatedText)
 362    {
 363      $this->translatedText = $translatedText;
 364    }
 365  
 366    public function getTranslatedText()
 367    {
 368      return $this->translatedText;
 369    }
 370  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1