Class: I18n::Tasks::Translators::BaseTranslator

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/i18n/tasks/translators/base_translator.rb

Constant Summary

Constants included from Logging

Logging::MUTEX, Logging::PROGRAM_NAME

Instance Method Summary collapse

Methods included from Logging

log_error, log_stderr, log_verbose, log_warn, program_name, warn_deprecated

Constructor Details

#initialize(i18n_tasks) ⇒ BaseTranslator

Returns a new instance of BaseTranslator.

Parameters:



8
9
10
# File 'lib/i18n/tasks/translators/base_translator.rb', line 8

def initialize(i18n_tasks)
  @i18n_tasks = i18n_tasks
end

Instance Method Details

#translate_forest(forest, from) ⇒ I18n::Tasks::Tree::Siblings

Returns translated forest.

Parameters:

  • forest (I18n::Tasks::Tree::Siblings)

    to translate to the locales of its root nodes

  • from (String)

    locale

Returns:

  • (I18n::Tasks::Tree::Siblings)

    translated forest



15
16
17
18
19
20
# File 'lib/i18n/tasks/translators/base_translator.rb', line 15

def translate_forest(forest, from)
  forest.inject @i18n_tasks.empty_forest do |result, root|
    translated = translate_pairs(root.key_values(root: true), to: root.key, from: from)
    result.merge! Data::Tree::Siblings.from_flat_pairs(translated)
  end
end