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

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

Instance Method Summary collapse

Constructor Details

#initialize(i18n_tasks) ⇒ BaseTranslator

Returns a new instance of BaseTranslator.

Parameters:



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

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



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

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