Skip to content

Instantly share code, notes, and snippets.

@gregoriokusowski
Created February 21, 2011 14:29
Show Gist options
  • Save gregoriokusowski/837121 to your computer and use it in GitHub Desktop.
Save gregoriokusowski/837121 to your computer and use it in GitHub Desktop.
A helper that finds the informed word(when running in shell), and gives all the options, with the respectives I18n keys, like "activerecord.models.attributes.etc.name"
require 'yaml'
@sentence = ARGV.shift
def find(path, map)
map.each do |key, value|
if value.is_a? Hash
find("#{path}#{key}.", value)
else
puts "#{path}#{key} - #{value}" if value =~ /#{@sentence}/
end
end
end
@translations = YAML.load(File.open('config/locales/pt.yml'))
find("", @translations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment