Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve

### Added

- Add `i18n` gem to the default `Gemfile`, and generate a placeholder `config/i18n/en.yml` for the app and each generated slice. (@timriley)
- Add `--name` option to `hanami new`, to specify a custom module namespace while using the positional argument as the directory path. For example, `hanami new my_bookshelf --name=bookshelf` creates the app in `my_bookshelf/` with `Bookshelf` as the module name. (@aaronmallen in #387)
- Add `--template-engine` option to `hanami generate` and `hanami new` to specify which template engine should be used for generated template files. Supports `erb`, `haml` and `slim`. (@katafrakt in #280, #389, #390)
- Add `--test` option to `hanami new` to specify which test framework to use. Supports `rspec` (default) and `minitest`. (@timriley in #399)
Expand Down
6 changes: 6 additions & 0 deletions lib/hanami/cli/generators/app/slice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def call(app, slice, url, force: false, **opts) # rubocop:disable Metrics/AbcSiz
force:
)

fs.create(
fs.join(directory, "config", "i18n", "en.yml"),
File.read(File.join(__dir__, "..", "i18n.yml")),
force:
)

if Hanami.bundled?("dry-operation")
RubyClassFile.new(
fs: fs,
Expand Down
1 change: 1 addition & 0 deletions lib/hanami/cli/generators/gem/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def generate_app(app, context) # rubocop:disable Metrics/AbcSize
fs.create("config/settings.rb", t("settings.erb", context))
fs.create("config/routes.rb", t("routes.erb", context))
fs.create("config/puma.rb", t("puma.erb", context))
fs.create("config/i18n/en.yml", File.read(File.join(__dir__, "..", "i18n.yml")))

fs.create("lib/tasks/.keep", t("keep.erb", context))
fs.create("lib/#{app}/types.rb", t("types.erb", context))
Expand Down
1 change: 1 addition & 0 deletions lib/hanami/cli/generators/gem/app/gemfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ source "<%= gem_source %>"
gem "dry-types", "~> 1.7"
gem "dry-operation", ">= 1.0.1"
gem "dry-validation", "~> 1.11"
gem "i18n", "~> 1.14"
gem "puma", ">= 7.1"
gem "rake"
<%- if generate_sqlite? -%>
Expand Down
3 changes: 3 additions & 0 deletions lib/hanami/cli/generators/i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add your translations here. See https://hanakai.org/learn/hanami/i18n for details.
en:
hello: "Hello"
9 changes: 9 additions & 0 deletions spec/unit/hanami/cli/commands/app/generate/slice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ class Operation < Test::Operation
expect(fs.read("slices/#{slice}/templates/layouts/app.html.erb")).to eq(layout)
expect(output).to include("Created slices/#{slice}/templates/layouts/app.html.erb")

# slices/admin/config/i18n/en.yml
i18n = <<~EXPECTED
# Add your translations here. See https://hanakai.org/learn/hanami/i18n for details.
en:
hello: "Hello"
EXPECTED
expect(fs.read("slices/#{slice}/config/i18n/en.yml")).to eq(i18n)
expect(output).to include("Created slices/#{slice}/config/i18n/en.yml")

# slices/admin/assets/js/app.js
app_js = <<~EXPECTED
import "../css/app.css";
Expand Down
12 changes: 12 additions & 0 deletions spec/unit/hanami/cli/commands/gem/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
gem "dry-types", "~> 1.7"
gem "dry-operation", ">= 1.0.1"
gem "dry-validation", "~> 1.11"
gem "i18n", "~> 1.14"
gem "puma", ">= 7.1"
gem "rake"
gem "sqlite3"
Expand Down Expand Up @@ -401,6 +402,15 @@ class Routes < Hanami::Routes
expect(fs.read("config/puma.rb")).to eq(puma)
expect(output).to include("Created config/puma.rb")

# config/i18n/en.yml
i18n = <<~EXPECTED
# Add your translations here. See https://hanakai.org/learn/hanami/i18n for details.
en:
hello: "Hello"
EXPECTED
expect(fs.read("config/i18n/en.yml")).to eq(i18n)
expect(output).to include("Created config/i18n/en.yml")

# lib/tasks/.keep
tasks_keep = <<~EXPECTED
EXPECTED
Expand Down Expand Up @@ -574,6 +584,7 @@ class Operation < Dry::Operation
gem "dry-types", "~> 1.7"
gem "dry-operation", ">= 1.0.1"
gem "dry-validation", "~> 1.11"
gem "i18n", "~> 1.14"
gem "puma", ">= 7.1"
gem "rake"
gem "sqlite3"
Expand Down Expand Up @@ -737,6 +748,7 @@ class Operation < Dry::Operation
gem "dry-types", "~> 1.7"
gem "dry-operation", ">= 1.0.1"
gem "dry-validation", "~> 1.11"
gem "i18n", "~> 1.14"
gem "puma", ">= 7.1"
gem "rake"
gem "sqlite3"
Expand Down
Loading