Skip to content

Instantly share code, notes, and snippets.

@gabrielg
Last active May 26, 2017 21:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gabrielg/b68ea622f6ade2b6a99f to your computer and use it in GitHub Desktop.
Save gabrielg/b68ea622f6ade2b6a99f to your computer and use it in GitHub Desktop.
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