Class: Translatomatic::Translator::Google

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

Overview

Interface to the Google translation API

Instance Attribute Summary

Attributes inherited from Base

#listener

Instance Method Summary collapse

Methods inherited from Base

#name, #translate

Constructor Details

#initialize(options = {}) ⇒ Google

Create a new Google translator instance



15
16
17
18
19
20
# File 'lib/translatomatic/translator/google.rb', line 15

def initialize(options = {})
  super(options)
  key = options[:google_api_key] || ENV["GOOGLE_API_KEY"]
  raise t("translator.google_key_required") if key.nil?
  EasyTranslate.api_key = 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.



23
24
25
# File 'lib/translatomatic/translator/google.rb', line 23

def languages
  EasyTranslate::LANGUAGES.keys
end