Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

   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</p>
  23   *
  24   * <p>
  25   * For more information about this service, see the API
  26   * <a href="https://developers.google.com/translate/v2/using_rest" target="_blank">Documentation</a>
  27   * </p>
  28   *
  29   * @author Google, Inc.
  30   */
  31  class Google_Service_Translate extends Google_Service
  32  {
  33  
  34  
  35    public $detections;
  36    public $languages;
  37    public $translations;
  38    
  39  
  40    /**
  41     * Constructs the internal representation of the Translate service.
  42     *
  43     * @param Google_Client $client
  44     */
  45    public function __construct(Google_Client $client)
  46    {
  47      parent::__construct($client);
  48      $this->rootUrl = 'https://www.googleapis.com/';
  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 The text to detect
 151     * @param array $optParams Optional parameters.
 152     * @return Google_Service_Translate_DetectionsListResponse
 153     */
 154    public function listDetections($q, $optParams = array())
 155    {
 156      $params = array('q' => $q);
 157      $params = array_merge($params, $optParams);
 158      return $this->call('list', array($params), "Google_Service_Translate_DetectionsListResponse");
 159    }
 160  }
 161  
 162  /**
 163   * The "languages" collection of methods.
 164   * Typical usage is:
 165   *  <code>
 166   *   $translateService = new Google_Service_Translate(...);
 167   *   $languages = $translateService->languages;
 168   *  </code>
 169   */
 170  class Google_Service_Translate_Languages_Resource extends Google_Service_Resource
 171  {
 172  
 173    /**
 174     * List the source/target languages supported by the API
 175     * (languages.listLanguages)
 176     *
 177     * @param array $optParams Optional parameters.
 178     *
 179     * @opt_param string target the language and collation in which the localized
 180     * results should be returned
 181     * @return Google_Service_Translate_LanguagesListResponse
 182     */
 183    public function listLanguages($optParams = array())
 184    {
 185      $params = array();
 186      $params = array_merge($params, $optParams);
 187      return $this->call('list', array($params), "Google_Service_Translate_LanguagesListResponse");
 188    }
 189  }
 190  
 191  /**
 192   * The "translations" collection of methods.
 193   * Typical usage is:
 194   *  <code>
 195   *   $translateService = new Google_Service_Translate(...);
 196   *   $translations = $translateService->translations;
 197   *  </code>
 198   */
 199  class Google_Service_Translate_Translations_Resource extends Google_Service_Resource
 200  {
 201  
 202    /**
 203     * Returns text translations from one language to another.
 204     * (translations.listTranslations)
 205     *
 206     * @param string $q The text to translate
 207     * @param string $target The target language into which the text should be
 208     * translated
 209     * @param array $optParams Optional parameters.
 210     *
 211     * @opt_param string source The source language of the text
 212     * @opt_param string format The format of the text
 213     * @opt_param string cid The customization id for translate
 214     * @return Google_Service_Translate_TranslationsListResponse
 215     */
 216    public function listTranslations($q, $target, $optParams = array())
 217    {
 218      $params = array('q' => $q, 'target' => $target);
 219      $params = array_merge($params, $optParams);
 220      return $this->call('list', array($params), "Google_Service_Translate_TranslationsListResponse");
 221    }
 222  }
 223  
 224  
 225  
 226  
 227  class Google_Service_Translate_DetectionsListResponse extends Google_Collection
 228  {
 229    protected $collection_key = 'detections';
 230    protected $internal_gapi_mappings = array(
 231    );
 232    protected $detectionsType = 'Google_Service_Translate_DetectionsResourceItems';
 233    protected $detectionsDataType = 'array';
 234  
 235  
 236    public function setDetections($detections)
 237    {
 238      $this->detections = $detections;
 239    }
 240    public function getDetections()
 241    {
 242      return $this->detections;
 243    }
 244  }
 245  
 246  class Google_Service_Translate_DetectionsResourceItems extends Google_Model
 247  {
 248    protected $internal_gapi_mappings = array(
 249    );
 250    public $confidence;
 251    public $isReliable;
 252    public $language;
 253  
 254  
 255    public function setConfidence($confidence)
 256    {
 257      $this->confidence = $confidence;
 258    }
 259    public function getConfidence()
 260    {
 261      return $this->confidence;
 262    }
 263    public function setIsReliable($isReliable)
 264    {
 265      $this->isReliable = $isReliable;
 266    }
 267    public function getIsReliable()
 268    {
 269      return $this->isReliable;
 270    }
 271    public function setLanguage($language)
 272    {
 273      $this->language = $language;
 274    }
 275    public function getLanguage()
 276    {
 277      return $this->language;
 278    }
 279  }
 280  
 281  class Google_Service_Translate_LanguagesListResponse extends Google_Collection
 282  {
 283    protected $collection_key = 'languages';
 284    protected $internal_gapi_mappings = array(
 285    );
 286    protected $languagesType = 'Google_Service_Translate_LanguagesResource';
 287    protected $languagesDataType = 'array';
 288  
 289  
 290    public function setLanguages($languages)
 291    {
 292      $this->languages = $languages;
 293    }
 294    public function getLanguages()
 295    {
 296      return $this->languages;
 297    }
 298  }
 299  
 300  class Google_Service_Translate_LanguagesResource extends Google_Model
 301  {
 302    protected $internal_gapi_mappings = array(
 303    );
 304    public $language;
 305    public $name;
 306  
 307  
 308    public function setLanguage($language)
 309    {
 310      $this->language = $language;
 311    }
 312    public function getLanguage()
 313    {
 314      return $this->language;
 315    }
 316    public function setName($name)
 317    {
 318      $this->name = $name;
 319    }
 320    public function getName()
 321    {
 322      return $this->name;
 323    }
 324  }
 325  
 326  class Google_Service_Translate_TranslationsListResponse extends Google_Collection
 327  {
 328    protected $collection_key = 'translations';
 329    protected $internal_gapi_mappings = array(
 330    );
 331    protected $translationsType = 'Google_Service_Translate_TranslationsResource';
 332    protected $translationsDataType = 'array';
 333  
 334  
 335    public function setTranslations($translations)
 336    {
 337      $this->translations = $translations;
 338    }
 339    public function getTranslations()
 340    {
 341      return $this->translations;
 342    }
 343  }
 344  
 345  class Google_Service_Translate_TranslationsResource extends Google_Model
 346  {
 347    protected $internal_gapi_mappings = array(
 348    );
 349    public $detectedSourceLanguage;
 350    public $translatedText;
 351  
 352  
 353    public function setDetectedSourceLanguage($detectedSourceLanguage)
 354    {
 355      $this->detectedSourceLanguage = $detectedSourceLanguage;
 356    }
 357    public function getDetectedSourceLanguage()
 358    {
 359      return $this->detectedSourceLanguage;
 360    }
 361    public function setTranslatedText($translatedText)
 362    {
 363      $this->translatedText = $translatedText;
 364    }
 365    public function getTranslatedText()
 366    {
 367      return $this->translatedText;
 368    }
 369  }