Last active
June 14, 2020 10:58
-
-
Save ryuta-ito/244003eaf0dc791afa5d89f07adb494d to your computer and use it in GitHub Desktop.
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
diff --git a/config/application.rb b/config/application.rb | |
index 282a956..3aa17b2 100644 | |
--- a/config/application.rb | |
+++ b/config/application.rb | |
@@ -16,6 +16,10 @@ module Sample | |
# -- all .rb files in that directory are automatically loaded after loading | |
# the framework and any gems in your application. | |
config.i18n.default_locale = :ja | |
+ config.generators do |g| | |
+ g.javascript_engine :coffee | |
+ g.javascripts true | |
+ end | |
end | |
end | |
diff --git a/lib/generators/coffee/assets/assets_generator.rb b/lib/generators/coffee/assets/assets_generator.rb | |
new file mode 100644 | |
index 0000000..76c4752 | |
--- /dev/null | |
+++ b/lib/generators/coffee/assets/assets_generator.rb | |
@@ -0,0 +1,15 @@ | |
+module Coffee | |
+ module Generators | |
+ class AssetsGenerator < Rails::Generators::NamedBase | |
+ source_root File.expand_path("../../../templates/rails/", __dir__) | |
+ | |
+ def copy_js | |
+ template "javascript/src/javascript.coffee", File.join('app/javascript/src', class_path, "#{file_name}.coffee") | |
+ end | |
+ | |
+ def copy_locale | |
+ template "locales/locale.yml", File.join('config/locales', class_path, "#{file_name}.yml") | |
+ end | |
+ end | |
+ end | |
+end | |
diff --git a/lib/templates/rails/javascript/src/javascript.coffee.tt b/lib/templates/rails/javascript/src/javascript.coffee.tt | |
new file mode 100644 | |
index 0000000..e69de29 | |
diff --git a/lib/templates/rails/locales/locale.yml.tt b/lib/templates/rails/locales/locale.yml.tt | |
new file mode 100644 | |
index 0000000..529fc5c | |
--- /dev/null | |
+++ b/lib/templates/rails/locales/locale.yml.tt | |
@@ -0,0 +1,11 @@ | |
+--- | |
+ja: | |
+ activerecord: | |
+ models: | |
+ <%= singular_table_name %>: '' | |
+ attributes: | |
+ <%= singular_table_name %>: | |
+ attribute: '' | |
+ <%= singular_table_name %>: | |
+ label: | |
+ name: '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment