暫無描述

Translate.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. /**
  18. * Service definition for Translate (v2).
  19. *
  20. * <p>
  21. * The Google Cloud Translation API lets websites and programs integrate with
  22. * Google Translate programmatically.</p>
  23. *
  24. * <p>
  25. * For more information about this service, see the API
  26. * <a href="https://code.google.com/apis/language/translate/v2/getting_started.html" target="_blank">Documentation</a>
  27. * </p>
  28. *
  29. * @author Google, Inc.
  30. */
  31. class Google_Service_Translate extends Google_Service
  32. {
  33. /** View and manage your data across Google Cloud Platform services. */
  34. const CLOUD_PLATFORM =
  35. "https://www.googleapis.com/auth/cloud-platform";
  36. /** Translate text from one language to another using Google Translate. */
  37. const CLOUD_TRANSLATION =
  38. "https://www.googleapis.com/auth/cloud-translation";
  39. public $detections;
  40. public $languages;
  41. public $translations;
  42. /**
  43. * Constructs the internal representation of the Translate service.
  44. *
  45. * @param Google_Client $client
  46. */
  47. public function __construct(Google_Client $client)
  48. {
  49. parent::__construct($client);
  50. $this->rootUrl = 'https://translation.googleapis.com/';
  51. $this->servicePath = 'language/translate/';
  52. $this->version = 'v2';
  53. $this->serviceName = 'translate';
  54. $this->detections = new Google_Service_Translate_Resource_Detections(
  55. $this,
  56. $this->serviceName,
  57. 'detections',
  58. array(
  59. 'methods' => array(
  60. 'detect' => array(
  61. 'path' => 'v2/detect',
  62. 'httpMethod' => 'POST',
  63. 'parameters' => array(),
  64. ),'list' => array(
  65. 'path' => 'v2/detect',
  66. 'httpMethod' => 'GET',
  67. 'parameters' => array(
  68. 'q' => array(
  69. 'location' => 'query',
  70. 'type' => 'string',
  71. 'repeated' => true,
  72. 'required' => true,
  73. ),
  74. ),
  75. ),
  76. )
  77. )
  78. );
  79. $this->languages = new Google_Service_Translate_Resource_Languages(
  80. $this,
  81. $this->serviceName,
  82. 'languages',
  83. array(
  84. 'methods' => array(
  85. 'list' => array(
  86. 'path' => 'v2/languages',
  87. 'httpMethod' => 'GET',
  88. 'parameters' => array(
  89. 'target' => array(
  90. 'location' => 'query',
  91. 'type' => 'string',
  92. ),
  93. 'model' => array(
  94. 'location' => 'query',
  95. 'type' => 'string',
  96. ),
  97. ),
  98. ),
  99. )
  100. )
  101. );
  102. $this->translations = new Google_Service_Translate_Resource_Translations(
  103. $this,
  104. $this->serviceName,
  105. 'translations',
  106. array(
  107. 'methods' => array(
  108. 'list' => array(
  109. 'path' => 'v2',
  110. 'httpMethod' => 'GET',
  111. 'parameters' => array(
  112. 'q' => array(
  113. 'location' => 'query',
  114. 'type' => 'string',
  115. 'repeated' => true,
  116. 'required' => true,
  117. ),
  118. 'target' => array(
  119. 'location' => 'query',
  120. 'type' => 'string',
  121. 'required' => true,
  122. ),
  123. 'model' => array(
  124. 'location' => 'query',
  125. 'type' => 'string',
  126. ),
  127. 'source' => array(
  128. 'location' => 'query',
  129. 'type' => 'string',
  130. ),
  131. 'cid' => array(
  132. 'location' => 'query',
  133. 'type' => 'string',
  134. 'repeated' => true,
  135. ),
  136. 'format' => array(
  137. 'location' => 'query',
  138. 'type' => 'string',
  139. ),
  140. ),
  141. ),'translate' => array(
  142. 'path' => 'v2',
  143. 'httpMethod' => 'POST',
  144. 'parameters' => array(),
  145. ),
  146. )
  147. )
  148. );
  149. }
  150. }