Class: Localer::Data::Processor

Inherits:
Service
  • Object
show all
Defined in:
lib/localer/data/processor.rb

Overview

Parse translations into hash: key: translation key value: hash of locale values

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



15
16
17
# File 'lib/localer/data/processor.rb', line 15

def data
  @data
end

#localesObject (readonly)

Returns the value of attribute locales.



15
16
17
# File 'lib/localer/data/processor.rb', line 15

def locales
  @locales
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/localer/data/processor.rb', line 17

def call
  @data = Hash.new { |hsh, key| hsh[key] = {} }
  @locales = []
  translations.each do |(locale, translation)|
    next unless config.locale[locale.downcase].enabled

    @locales.push locale
    prepare(locale, translation)
  end
  [@locales, @data]
end