Created
February 28, 2014 23:30
-
-
Save eddanger/9282175 to your computer and use it in GitHub Desktop.
Convert locales files for testing new locales.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locale = YAML.load_file("#{Rails.root}/config/locales/en.yml") | |
new_locale = zero_value_in_hash(locale) | |
puts new_locale.to_yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def zero_value_in_hash(hash) | |
result = {} | |
hash.each do |k,v| | |
if v.is_a?(Hash) | |
result[k] = zero_value_in_hash(v) | |
else | |
result[k] = "XXXXXX" | |
end | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment