Module: I18nYamlEditor::Update

Includes:
Cast
Included in:
Store
Defined in:
lib/i18n_yaml_editor/update.rb

Overview

Provides update functionality for Store

Constant Summary

Constants included from Cast

Cast::CHECK, Cast::CONVERT, Cast::TYPES

Instance Method Summary collapse

Methods included from Cast

#cast

Instance Method Details

#update(new_translations) ⇒ Object

Update translations in store



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/i18n_yaml_editor/update.rb', line 11

def update(new_translations)
  translations_in_store = translations.values.group_by(&:key)

  new_translations.each do |name, text|
    if translations[name]
      update_translation(name, text, translations_in_store)
    else
      # rubocop:disable Style/StderrPuts
      $stderr.puts 'Translation not found'
      # rubocop:enable Style/StderrPuts
      next
    end
  end
end