Class: Google::Apis::TranslateV2::TranslateService

Inherits:
Core::BaseService show all
Defined in:
generated/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.

Examples:

require 'google/apis/translate_v2'

Translate = Google::Apis::TranslateV2 # Alias the module
service = Translate::TranslateService.new

See Also:

Instance Attribute Summary collapse

Attributes inherited from Core::BaseService

#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path

Instance Method Summary collapse

Methods inherited from Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Methods included from Core::Logging

#logger

Constructor Details

#initializeTranslateService


47
48
49
50
# File 'generated/google/apis/translate_v2/service.rb', line 47

def initialize
  super('https://translation.googleapis.com/', 'language/translate/')
  @batch_path = 'batch/translate'
end

Instance Attribute Details

#keyString


39
40
41
# File 'generated/google/apis/translate_v2/service.rb', line 39

def key
  @key
end

#quota_userString


45
46
47
# File 'generated/google/apis/translate_v2/service.rb', line 45

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.

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Raises:


72
73
74
75
76
77
78
79
80
81
# File 'generated/google/apis/translate_v2/service.rb', line 72

def detect_detection_language(detect_language_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v2/detect', options)
  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.

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Raises:


105
106
107
108
109
110
111
112
113
# File 'generated/google/apis/translate_v2/service.rb', line 105

def list_detections(q, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:get, 'v2/detect', options)
  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.

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Raises:


139
140
141
142
143
144
145
146
147
148
# File 'generated/google/apis/translate_v2/service.rb', line 139

def list_languages(model: nil, target: nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:get, 'v2/languages', options)
  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.

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Raises:


188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'generated/google/apis/translate_v2/service.rb', line 188

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', options)
  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.

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Raises:


223
224
225
226
227
228
229
230
231
232
# File 'generated/google/apis/translate_v2/service.rb', line 223

def translate_translation_text(translate_text_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command =  make_simple_command(:post, 'v2', options)
  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