Module: Unbabel::Translation
- Included in:
- Client
- Defined in:
- lib/unbabel/translation.rb
Instance Method Summary collapse
-
#find(uid) ⇒ Object
finds a translation by it’s unique id.
-
#request_translation(params = {}) ⇒ Object
text (required) - the text to be translated.
-
#translations(status = nil) ⇒ Object
status are ‘new’ - The translation has been created and is being pre-processed ‘ready’ - The translation is ready to be processed in the unbabel platform.
Instance Method Details
#find(uid) ⇒ Object
finds a translation by it’s unique id
5 6 7 8 |
# File 'lib/unbabel/translation.rb', line 5 def find(uid) response = Unirest.get("#{Unbabel::Client::ENDPOINT}/translation/#{uid}") response.body end |
#request_translation(params = {}) ⇒ Object
text (required) - the text to be translated. target_language (required) - the language to translate the text to. source_language - the language of text. If not supplemented it will be auto detected from the text. text_format - The format of the text to be translated [one of text,html]. target_text - initial version of the text to be post-edited. uid - A unique identifier for the job. If one is not supplied the system will provide one. callback_url - Once the job is done the result will be posted to this endpoint. formality (optional) - The tone that should be used in the translation. instructions (optional) - Client instructions for the translator. topics (optional) - List of the topics of text.
20 21 22 23 24 |
# File 'lib/unbabel/translation.rb', line 20 def request_translation(params = {}) response = Unirest.post("#{Unbabel::Client::ENDPOINT}/translation/", parameters: params.to_json) response.body end |
#translations(status = nil) ⇒ Object
status are ‘new’ - The translation has been created and is being pre-processed ‘ready’ - The translation is ready to be processed in the unbabel platform. ‘in_progress’ - The translation is being executed ‘delivered’ - The translation has already been returned to the client (either using the endpoint or query for a translation)
31 32 33 34 35 36 |
# File 'lib/unbabel/translation.rb', line 31 def translations(status = nil) status = "?status=#{status}" if status response = Unirest.get("#{Unbabel::Client::ENDPOINT}/translation/#{status}") response.body['objects'] end |