Sha256: f554fe0dc6642c5b2755f5a8ff538739db2605a57aaccb12294ad16a4ee3be2d

Contents?: true

Size: 992 Bytes

Versions: 14

Compression:

Stored size: 992 Bytes

Contents

class PeakFlowUtils::ApplicationHandler
  def add_translations_for_hash(dir, _group, yielder, hash)
    translations_for_hash_recursive(dir, hash[:translations], yielder, [])
  end

  def translations_for_hash_recursive(dir, hash, yielder, current_keys)
    hash.each do |key, value|
      current_keys << key

      if value.is_a?(Hash)
        translations_for_hash_recursive(dir, value, yielder, current_keys)
      elsif value.is_a?(Array)
        value.each_index do |index|
          yielder << PeakFlowUtils::TranslationService.new(
            dir: dir,
            key: "#{current_keys.join('.')}[#{index}]",
            key_show: "#{current_keys.join('.')}[#{index}]"
          )
        end
      else
        yielder << PeakFlowUtils::TranslationService.new(
          dir: dir,
          key: current_keys.join("."),
          key_show: current_keys.join("."),
          default: value
        )
      end

      current_keys.pop
    end
  end

  def enabled?
    true
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
peak_flow_utils-0.1.19 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.18 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.17 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.16 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.15 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.14 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.13 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.12 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.11 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.10 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.9 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.8 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.7 app/handlers/peak_flow_utils/application_handler.rb
peak_flow_utils-0.1.6 app/handlers/peak_flow_utils/application_handler.rb