Class: Translatomatic::Provider::GoogleWeb

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

Overview

Google translation web interface. supports multiple translations

Instance Attribute Summary collapse

Attributes inherited from Base

#listener

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#name, supports_no_translate_html?, #to_s, #translate

Constructor Details

#initialize(options = {}) ⇒ GoogleWeb

Create a new GoogleWeb provider instance



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

def initialize(options = {})
  super(options)
  require 'google_web_translate'
  @dt = %w[t at]
  @debug = options[:debug]
end

Instance Attribute Details

#dtObject

Returns the value of attribute dt.



7
8
9
# File 'lib/translatomatic/provider/google_web.rb', line 7

def dt
  @dt
end

Class Method Details

.supports_alternative_translations?boolean

Returns True if a string can have alternative translations.

Returns:

  • (boolean)

    True if a string can have alternative translations



10
11
12
# File 'lib/translatomatic/provider/google_web.rb', line 10

def self.supports_alternative_translations?
  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.



23
24
25
# File 'lib/translatomatic/provider/google_web.rb', line 23

def languages
  api.respond_to?(:languages) ? api.languages : []
end