Class: Google::Apis::TranslateV2::TranslateService
- Inherits:
-
Core::BaseService
- Object
- Core::BaseService
- Google::Apis::TranslateV2::TranslateService
- Defined in:
- lib/google/apis/translate_v2/service.rb
Overview
Google Cloud Translation API
The Google Cloud Translation API lets websites and programs integrate with Google Translate programmatically.
Constant Summary collapse
- DEFAULT_ENDPOINT_TEMPLATE =
"https://translation.$UNIVERSE_DOMAIN$/"
Instance Attribute Summary collapse
-
#key ⇒ String
API key.
-
#quota_user ⇒ String
Available to use for quota purposes for server-side applications.
Instance Method Summary collapse
-
#detect_detection_language(detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse
Detects the language of text within a request.
-
#initialize ⇒ TranslateService
constructor
A new instance of TranslateService.
-
#list_detections(q, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse
Detects the language of text within a request.
-
#list_languages(model: nil, target: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListLanguagesResponse
Returns a list of supported languages for translation.
-
#list_translations(q, target, cid: nil, format: nil, model: nil, source: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListTranslationsResponse
Translates input text, returning translated text.
-
#translate_translation_text(translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListTranslationsResponse
Translates input text, returning translated text.
Constructor Details
#initialize ⇒ TranslateService
Returns a new instance of TranslateService.
49 50 51 52 53 54 |
# File 'lib/google/apis/translate_v2/service.rb', line 49 def initialize super(DEFAULT_ENDPOINT_TEMPLATE, 'language/translate/', client_name: 'google-apis-translate_v2', client_version: Google::Apis::TranslateV2::GEM_VERSION) @batch_path = 'batch/translate' end |
Instance Attribute Details
#key ⇒ String
Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
41 42 43 |
# File 'lib/google/apis/translate_v2/service.rb', line 41 def key @key end |
#quota_user ⇒ String
Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
47 48 49 |
# File 'lib/google/apis/translate_v2/service.rb', line 47 def quota_user @quota_user end |
Instance Method Details
#detect_detection_language(detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse
Detects the language of text within a request.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/google/apis/translate_v2/service.rb', line 76 def detect_detection_language(detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'v2/detect', ) command.request_representation = Google::Apis::TranslateV2::DetectLanguageRequest::Representation command.request_object = detect_language_request_object command.response_representation = Google::Apis::TranslateV2::ListDetectionsResponse::Representation command.response_class = Google::Apis::TranslateV2::ListDetectionsResponse command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#list_detections(q, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse
Detects the language of text within a request.
109 110 111 112 113 114 115 116 117 |
# File 'lib/google/apis/translate_v2/service.rb', line 109 def list_detections(q, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/detect', ) command.response_representation = Google::Apis::TranslateV2::ListDetectionsResponse::Representation command.response_class = Google::Apis::TranslateV2::ListDetectionsResponse command.query['q'] = q unless q.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#list_languages(model: nil, target: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListLanguagesResponse
Returns a list of supported languages for translation.
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/google/apis/translate_v2/service.rb', line 143 def list_languages(model: nil, target: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/languages', ) command.response_representation = Google::Apis::TranslateV2::ListLanguagesResponse::Representation command.response_class = Google::Apis::TranslateV2::ListLanguagesResponse command.query['model'] = model unless model.nil? command.query['target'] = target unless target.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#list_translations(q, target, cid: nil, format: nil, model: nil, source: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListTranslationsResponse
Translates input text, returning translated text.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/google/apis/translate_v2/service.rb', line 192 def list_translations(q, target, cid: nil, format: nil, model: nil, source: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2', ) command.response_representation = Google::Apis::TranslateV2::ListTranslationsResponse::Representation command.response_class = Google::Apis::TranslateV2::ListTranslationsResponse command.query['cid'] = cid unless cid.nil? command.query['format'] = format unless format.nil? command.query['model'] = model unless model.nil? command.query['q'] = q unless q.nil? command.query['source'] = source unless source.nil? command.query['target'] = target unless target.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |
#translate_translation_text(translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListTranslationsResponse
Translates input text, returning translated text.
227 228 229 230 231 232 233 234 235 236 |
# File 'lib/google/apis/translate_v2/service.rb', line 227 def translate_translation_text(translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'v2', ) command.request_representation = Google::Apis::TranslateV2::TranslateTextRequest::Representation command.request_object = translate_text_request_object command.response_representation = Google::Apis::TranslateV2::ListTranslationsResponse::Representation command.response_class = Google::Apis::TranslateV2::ListTranslationsResponse command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end |