Class: I18n::Tasks::Translators::BaseTranslator
- Inherits:
-
Object
- Object
- I18n::Tasks::Translators::BaseTranslator
- Includes:
- Logging
- Defined in:
- lib/i18n/tasks/translators/base_translator.rb
Direct Known Subclasses
DeeplTranslator, GoogleTranslator, OpenAiTranslator, YandexTranslator
Constant Summary
Constants included from Logging
Logging::MUTEX, Logging::PROGRAM_NAME
Instance Method Summary collapse
-
#initialize(i18n_tasks) ⇒ BaseTranslator
constructor
A new instance of BaseTranslator.
-
#translate_forest(forest, from) ⇒ I18n::Tasks::Tree::Siblings
Translated forest.
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.
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.
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 |