Class: Locomotive::Mounter::Reader::FileSystem::TranslationsReader

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/mounter/reader/file_system/translations_reader.rb

Instance Attribute Summary

Attributes inherited from Base

#items, #runner

Instance Method Summary collapse

Methods inherited from Base

#initialize, #mounting_point

Constructor Details

This class inherits a constructor from Locomotive::Mounter::Reader::FileSystem::Base

Instance Method Details

#readHash

Build the list of translations based on the config/translations.yml file

Returns:

  • (Hash)

    Hash whose the key is the translation key



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/locomotive/mounter/reader/file_system/translations_reader.rb', line 12

def read
  config_path = File.join(self.runner.path, 'config', 'translations.yml')

  {}.tap do |translations|
    if File.exists?(config_path)
      (self.read_yaml(config_path) || []).each do |translation|
        key, values = translation

        entry = Locomotive::Mounter::Models::Translation.new({
          key:    key,
          values: values
        })

        translations[key] = entry
      end
    end
  end
end