Class: Translatomatic::Provider::Google

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

Overview

Interface to the Google translation API

Instance Attribute Summary

Attributes inherited from Base

#listener

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#name, supports_alternative_translations?, #to_s, #translate

Constructor Details

#initialize(options = {}) ⇒ Google

Create a new Google provider instance



18
19
20
21
22
23
# File 'lib/translatomatic/provider/google.rb', line 18

def initialize(options = {})
  super(options)
  @key = options[:google_api_key] || ENV['GOOGLE_API_KEY']
  raise t('provider.google.key_required') if @key.nil?
  @model = options[:google_model]
end

Class Method Details

.supports_no_translate_html?boolean

Returns true if this provider supports html5 <span translate=“no”></span> tags.

Returns:

  • (boolean)

    true if this provider supports html5 <span translate=“no”></span> tags.



13
14
15
# File 'lib/translatomatic/provider/google.rb', line 13

def self.supports_no_translate_html?
  true
end

Instance Method Details

#languagesArray<String>

Returns A list of languages supported by this provider.

Returns:

  • (Array<String>)

    A list of languages supported by this provider.



26
27
28
# File 'lib/translatomatic/provider/google.rb', line 26

def languages
  @languages ||= fetch_languages
end