Class: InlineTranslation::Translators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/inline_translation/translators/base.rb

Direct Known Subclasses

Bing, Null

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#translatorObject (readonly)

Returns the value of attribute translator.



4
5
6
# File 'lib/inline_translation/translators/base.rb', line 4

def translator
  @translator
end

Class Method Details

.ready?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/inline_translation/translators/base.rb', line 6

def self.ready?
  false
end

Instance Method Details

#can_translate?(translatable, field, to) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
# File 'lib/inline_translation/translators/base.rb', line 10

def can_translate?(translatable, field, to)
  self.class.ready? &&
  to.present? &&
  translatable.respond_to?(field) &&
  translatable.language_field.present? &&
  translatable.language_field.to_s != to.to_s &&
  translatable.translations.where(field: field, language: to).empty?
end

#translate(text, from: nil, to: I18n.locale) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/inline_translation/translators/base.rb', line 19

def translate(text, from: nil, to: I18n.locale)
  raise NotImplementedError.new
end