Skip to content

Instantly share code, notes, and snippets.

@drogus
Created January 15, 2014 13:34
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 drogus/8436273 to your computer and use it in GitHub Desktop.
Save drogus/8436273 to your computer and use it in GitHub Desktop.
require 'yaml'
TRANSLATIONS = YAML.load_file('en.yml')['en']
def t(path)
current = TRANSLATIONS
path.split('.').take_while { |key| current = current[key] }
current
end
templates = Dir.glob("assets/scripts/app/templates/**/*.hbs")
templates.each do |template_path|
template = File.read(template_path)
template.gsub!(/\{\{t\s+([^\}]+)\}\}/) do |match|
t $1
end
File.open(template_path, 'w') { |f|
f.write template
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment