Sha256: 4da3604608c8b53b65142ca7a01299d1e54b90ecc127f0c0c441d510d976d998

Contents?: true

Size: 1.08 KB

Versions: 31

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  # This job is part of the machine translation flow. This one specifically
  # delegates the arguments to the translation service, if any.
  class MachineTranslationFieldsJob < ApplicationJob
    queue_as :translations

    # 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
    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
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.8 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.7 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.6 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.10 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.9 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.5 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.8 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.4 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.3 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.7 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.5 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.2 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.1 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.4 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.0 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.3 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.0.rc2 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.27.0.rc1 app/jobs/decidim/machine_translation_fields_job.rb
decidim-core-0.26.2 app/jobs/decidim/machine_translation_fields_job.rb