class Decidim::Dev::DummyTranslator

This Dummy translator recieves 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.

Attributes

field_name[R]
resource[R]
source_locale[R]
target_locale[R]
text[R]

Public Class Methods

new(resource, field_name, text, target_locale, source_locale) click to toggle source
# 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

Public Instance Methods

translate() click to toggle source
# 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