google-cloud-translate-v2 - Class Google::Cloud::Translate::V2::Translation (v0.3.1)

Reference documentation and code samples for the google-cloud-translate-v2 class Google::Cloud::Translate::V2::Translation.

Translation

Represents a translation query result. Returned by Api#translate.

Inherits

  • Object

Example

require "google/cloud/translate/v2"

translate = Google::Cloud::Translate::V2.new

translation = translate.translate "Hello world!", to: "la"

translation.to_s #=> "Salve mundi!"

translation.from #=> "en"
translation.origin #=> "Hello world!"
translation.to #=> "la"
translation.text #=> "Salve mundi!"

Methods

#detected?

def detected?() -> Boolean

Determines if the source language was detected by the Google Cloud Cloud Translation API.

Returns
  • (Boolean) — true if the source language was detected by the Cloud Translation API, false if the source language was provided in the request

#from

def from() -> String
Aliases

The source language from which the text was translated.

Returns
  • (String)

#language

def language() -> String
Alias Of: #to

The target language into which the text was translated.

Returns
  • (String)

#model

def model() -> String

The translation model. Can be either base for the Phrase-Based Machine Translation (PBMT) model, or nmt for the Neural Machine Translation (NMT) model. If you did not include a model parameter with your request, then this field is not included in the response.

Returns
  • (String)

#origin

def origin() -> String

The original query text that was translated.

Returns
  • (String)

#source

def source() -> String
Alias Of: #from

The source language from which the text was translated.

Returns
  • (String)

#target

def target() -> String
Alias Of: #to

The target language into which the text was translated.

Returns
  • (String)

#text

def text() -> String
Aliases

The translated result.

Returns
  • (String)

#to

def to() -> String
Aliases

The target language into which the text was translated.

Returns
  • (String)

#to_s

def to_s() -> String
Alias Of: #text

The translated result.

Returns
  • (String)

#to_str

def to_str() -> String
Alias Of: #text

The translated result.

Returns
  • (String)