Create a gist now

Instantly share code, notes, and snippets.

@gabrielg /recipe.rb Secret
Last active May 26, 2017

What would you like to do?
Contrived recipe for a blog post.
gem "i18n-js", git: "https://github.com/gabrielg/i18n-js.git"
append_file 'app/assets/javascripts/application.js' do <<-JS
//= require i18n
//= require i18n/translations
JS
end
inject_into_file 'config/application.rb', after: "Rails::Application" do <<-RUBY
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
RUBY
end
LOCALES = %w[en-US es-AR en-AU hr pl ru ko]
run 'mkdir config/locales/views config/locales/models'
LOCALES.each do |locale|
translation_data = <<-"FILE"
#{locale}:
hello: hello world from #{locale}
FILE
create_file "config/locales/views/#{locale}.yml", translation_data
create_file "config/locales/models/#{locale}.yml", translation_data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment