Sha256: fb2effbf08a90c30aa68619fcd05f3c39508fe6f406d62d0aa085d0215b37e65
Contents?: true
Size: 615 Bytes
Versions: 10
Compression:
Stored size: 615 Bytes
Contents
module I18n module Backend module Flatten # Nest keys for flatten (dotted) hashes # IN: { "hello.world" => "hello world" } # OUT: { :hello => { :world => "hello world" } } def nest_translations(hash) hash.map do |main_key, main_value| main_key.to_s.split(".").reverse.inject(main_value) do |value, key| if value.is_a?(Hash) { key.to_sym => nest_translations(value) } else { key.to_sym => value } end end end.inject(&:deep_merge) end end include Flatten end end
Version data entries
10 entries across 10 versions & 1 rubygems