Module: EasyTranslate::Translation

Includes:
Threadable
Included in:
EasyTranslate
Defined in:
lib/easy_translate/translation.rb

Defined Under Namespace

Classes: TranslationRequest

Instance Method Summary collapse

Methods included from Threadable

#threaded_process

Instance Method Details

#translate(texts, options = {}, http_options = {}) ⇒ String, Array

Translate text

Parameters:

  • texts (String, Array)
    • A single string or set of strings to translate

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :batch_size (Fixnum)
    • Maximum keys per request (optional, default 100)

  • :concurrency (Fixnum)
    • Maximum concurrent requests (optional, default 4)

  • :source (String, Symbol)
    • The source language (optional)

  • :target (String, Symbol)
    • The target language (required)

  • :html (Boolean)
    • Whether or not the supplied string is HTML (optional)

Returns:

  • (String, Array)

    Translated text or texts



19
20
21
# File 'lib/easy_translate/translation.rb', line 19

def translate(texts, options = {}, http_options = {})
  threaded_process(:request_translations, texts, options, http_options)
end