class TranslationSupport
def create_hash(data, _basename)
def create_hash(data, _basename) words = Hash.new return words if !data parent = Array.new previous_key = 'base' data.split("\n").each do |w| next if w.strip.blank? (key, value) = w.split(':', 2) value ||= '' shift = (key =~ /\w/) / 2 - parent.size # Determine level of current key in comparison to parent array key = key.sub(/^\s+/, '') parent << previous_key if shift > 0 # If key is child of previous key, add previous key as parent (shift * -1).times { parent.pop } if shift < 0 # If key is not related to previous key, remove parent keys previous_key = key # Track key in case next key is child of this key words[parent.join(':') + ':' + key] = value unless key.blank? end words end