Skip to content

Instantly share code, notes, and snippets.

@sixtyfive

sixtyfive/ctk.rb Secret

Created May 28, 2016 15:43
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 sixtyfive/dafc1fd138705d500909ce03f0a696d8 to your computer and use it in GitHub Desktop.
Save sixtyfive/dafc1fd138705d500909ce03f0a696d8 to your computer and use it in GitHub Desktop.
def collect_translation_keys
big_string = String.new
# File#read should be fine given that all the files are quite short.
Dir.glob(File.join(Rails.root, 'app', '**', '*.{rb,haml}')) {|path| big_string += File.read(path)}
big_string.scan(/_\(['"](.*)['"]\)/) do |result|
# Do things with each result.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment