Class: Decidim::MachineTranslationFieldsJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
decidim-core/app/jobs/decidim/machine_translation_fields_job.rb

Overview

This job is part of the machine translation flow. This one specifically delegates the arguments to the translation service, if any.

Instance Method Summary collapse

Instance Method Details

#perform(resource, field_name, field_value, target_locale, source_locale) ⇒ Object

Performs the job. It won't perform anything if the `Decidim.machine_translation_service` config is not set.

resource - Any kind of `Decidim::TranslatableResource` model instance field_name - A Symbol representing the name of the field being translated field_value - A String with the value of the field to translate target_locale - A Symbol representing the target locale for the translation source_locale - A Symbol representing the source locale for the translation


17
18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-core/app/jobs/decidim/machine_translation_fields_job.rb', line 17

def perform(resource, field_name, field_value, target_locale, source_locale)
  klass = Decidim.machine_translation_service_klass
  return unless klass

  klass.new(
    resource,
    field_name,
    field_value,
    target_locale,
    source_locale
  ).translate
end