Class: Decidim::Dev::DummyTranslator
- Inherits:
-
Object
- Object
- Decidim::Dev::DummyTranslator
- Defined in:
- lib/decidim/dev/dummy_translator.rb
Overview
This Dummy translator receives the field value and the locale of the field which has to be translated. It returns the appended value for both. This is for testing only.
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#source_locale ⇒ Object
readonly
Returns the value of attribute source_locale.
-
#target_locale ⇒ Object
readonly
Returns the value of attribute target_locale.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(resource, field_name, text, target_locale, source_locale) ⇒ DummyTranslator
constructor
A new instance of DummyTranslator.
- #translate ⇒ Object
Constructor Details
#initialize(resource, field_name, text, target_locale, source_locale) ⇒ DummyTranslator
Returns a new instance of DummyTranslator.
12 13 14 15 16 17 18 |
# File 'lib/decidim/dev/dummy_translator.rb', line 12 def initialize(resource, field_name, text, target_locale, source_locale) @resource = resource @field_name = field_name @text = text @target_locale = target_locale @source_locale = source_locale end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
10 11 12 |
# File 'lib/decidim/dev/dummy_translator.rb', line 10 def field_name @field_name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/decidim/dev/dummy_translator.rb', line 10 def resource @resource end |
#source_locale ⇒ Object (readonly)
Returns the value of attribute source_locale.
10 11 12 |
# File 'lib/decidim/dev/dummy_translator.rb', line 10 def source_locale @source_locale end |
#target_locale ⇒ Object (readonly)
Returns the value of attribute target_locale.
10 11 12 |
# File 'lib/decidim/dev/dummy_translator.rb', line 10 def target_locale @target_locale end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
10 11 12 |
# File 'lib/decidim/dev/dummy_translator.rb', line 10 def text @text end |
Instance Method Details
#translate ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/decidim/dev/dummy_translator.rb', line 20 def translate translated_text = "#{target_locale} - #{text}" MachineTranslationSaveJob.perform_later( resource, field_name, target_locale, translated_text ) end |