Class: Google::Apis::TranslateV2::TranslateService
- Inherits:
-
Core::BaseService
- Object
- Core::BaseService
- Google::Apis::TranslateV2::TranslateService
- Defined in:
- generated/google/apis/translate_v2/service.rb
Overview
Translate API
Translates text from one language to another.
Instance Attribute Summary collapse
-
#key ⇒ String
API key.
-
#quota_user ⇒ String
Available to use for quota purposes for server-side applications.
-
#user_ip ⇒ String
IP address of the site where the request originates.
Attributes inherited from Core::BaseService
#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path
Instance Method Summary collapse
-
#initialize ⇒ TranslateService
constructor
A new instance of TranslateService.
-
#list_detections(q, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::TranslateV2::ListDetectionsResponse
Detect the language of text.
-
#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.
-
#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.
Methods inherited from Core::BaseService
#batch, #batch_upload, #fetch_all, #http
Constructor Details
#initialize ⇒ TranslateService
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
#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.
38 39 40 |
# File 'generated/google/apis/translate_v2/service.rb', line 38 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.
44 45 46 |
# File 'generated/google/apis/translate_v2/service.rb', line 44 def quota_user @quota_user end |
#user_ip ⇒ String
Returns 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.
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', ) 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
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', ) 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.
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', ) 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 |