Skip to content

Instantly share code, notes, and snippets.

@morika-t
Forked from massive/locale_diff.rb
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morika-t/229a881162ee16c22e83 to your computer and use it in GitHub Desktop.
Save morika-t/229a881162ee16c22e83 to your computer and use it in GitHub Desktop.
# Run: curl https://gist.github.com/raw/719970/locale_diff.rb | ruby - en fi
require 'rubygems'
require 'yaml'
l1 = ARGV[0]
l2 = ARGV[1]
first = YAML.load_file(l1 + ".yml")
second = YAML.load_file(l2 + ".yml")
def diff(root, compared, structure = [])
root.each_key do |key|
next_root = root[key]
next_compared = compared.nil? ? nil : compared[key]
new_structure = structure.dup << key
if compared.nil? || compared[key].nil?
print "#{new_structure.join(".")}"
print ": \"#{root[key]}\"" if next_root.kind_of? String
print "\n"
end
diff(next_root, next_compared, new_structure) if next_root.kind_of? Hash
end
end
puts "MISSING FROM #{l2}"
diff(first[l1], second[l2], [l2])
puts "\nMISSING FROM #{l1}"
diff(second[l2], first[l1], [l1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment