-
-
Save gabrielg/b68ea622f6ade2b6a99f to your computer and use it in GitHub Desktop.
Contrived recipe for a blog post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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