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

Inherits:
Core::BaseService show all
Defined in:
generated/google/apis/translate_v2/service.rb

Overview

Translate API

Translates text from one language to another.

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

Constructor Details

#initializeTranslateService

Returns a new instance of TranslateService.



51
52
53
# File 'generated/google/apis/translate_v2/service.rb', line 51

def initialize
  super('https://www.googleapis.com/', 'language/translate/')
end

Instance Attribute Details

#keyString

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.

Returns:

  • (String)

    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.



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

def key
  @key
end

#quota_userString

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.

Returns:

  • (String)

    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.



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

def quota_user
  @quota_user
end

#user_ipString

Returns IP address of the site where the request originates. Use this if you want to enforce per-user limits.

Returns:

  • (String)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.



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

def user_ip
  @user_ip
end

Instance Method Details

#list_detections(q, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse

Detect the language of text.

Parameters:

  • q (Array<String>, String)

    The text to detect

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



79
80
81
82
83
84
85
86
87
88
# File 'generated/google/apis/translate_v2/service.rb', line 79

def list_detections(q, fields: nil, quota_user: nil, user_ip: 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?
  command.query['userIp'] = user_ip unless user_ip.nil?
  execute_or_queue_command(command, &block)
end

#list_languages(target: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListLanguagesResponse

List the source/target languages supported by the API

Parameters:

  • target (String) (defaults to: nil)

    the language and collation in which the localized results should be returned

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



114
115
116
117
118
119
120
121
122
123
# File 'generated/google/apis/translate_v2/service.rb', line 114

def list_languages(target: nil, fields: nil, quota_user: nil, user_ip: 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['target'] = target unless target.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  command.query['userIp'] = user_ip unless user_ip.nil?
  execute_or_queue_command(command, &block)
end

#list_translations(q, target, cid: nil, format: nil, source: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListTranslationsResponse

Returns text translations from one language to another.

Parameters:

  • q (Array<String>, String)

    The text to translate

  • target (String)

    The target language into which the text should be translated

  • cid (Array<String>, String) (defaults to: nil)

    The customization id for translate

  • format (String) (defaults to: nil)

    The format of the text

  • source (String) (defaults to: nil)

    The source language of the text

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • user_ip (String) (defaults to: nil)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'generated/google/apis/translate_v2/service.rb', line 157

def list_translations(q, target, cid: nil, format: nil, source: nil, fields: nil, quota_user: nil, user_ip: 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['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?
  command.query['userIp'] = user_ip unless user_ip.nil?
  execute_or_queue_command(command, &block)
end