Sha256: 6f67819820292f13f2f46c8a00771c506022cd4ebc7884e0f4f16c0679ab31eb

Contents?: true

Size: 938 Bytes

Versions: 3

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

require 'i18n/tasks/translators/deepl_translator.rb'
require 'i18n/tasks/translators/google_translator.rb'
require 'i18n/tasks/translators/yandex_translator.rb'

module I18n::Tasks
  module Translation
    # @param [I18n::Tasks::Tree::Siblings] forest to translate to the locales of its root nodes
    # @param [String] from locale
    # @param [:deepl, :google, :yandex] backend
    # @return [I18n::Tasks::Tree::Siblings] translated forest
    def translate_forest(forest, from:, backend: :google)
      case backend
      when :deepl
        Translators::DeeplTranslator.new(self).translate_forest(forest, from)
      when :google
        Translators::GoogleTranslator.new(self).translate_forest(forest, from)
      when :yandex
        Translators::YandexTranslator.new(self).translate_forest(forest, from)
      else
        fail CommandError, "invalid backend: #{backend}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n-tasks-0.9.33 lib/i18n/tasks/translation.rb
i18n-tasks-0.9.32 lib/i18n/tasks/translation.rb
i18n-tasks-0.9.31 lib/i18n/tasks/translation.rb