Class: Translatomatic::Translator::Yandex

Inherits:
Base
  • Object
show all
Defined in:
lib/translatomatic/translator/yandex.rb

Instance Attribute Summary

Attributes inherited from Base

#listener

Instance Method Summary collapse

Methods inherited from Base

#name, #translate

Methods included from Util

#locale, #log, #string

Constructor Details

#initialize(options = {}) ⇒ Yandex

Create a new Yandex translator instance



13
14
15
16
17
18
# File 'lib/translatomatic/translator/yandex.rb', line 13

def initialize(options = {})
  super(options)
  key = options[:yandex_api_key] || ENV["YANDEX_API_KEY"]
  raise "yandex api key required" if key.nil?
  @impl = ::Yandex::Translator.new(key)
end

Instance Method Details

#languagesArray<String>

Returns A list of languages supported by this translator.

Returns:

  • (Array<String>)

    A list of languages supported by this translator.



21
22
23
# File 'lib/translatomatic/translator/yandex.rb', line 21

def languages
  @languages ||= @impl.langs.collect { |i| i[0, 2] }.uniq
end