mirror of
https://github.com/usetrmnl/terminus.git
synced 2026-08-13 14:29:27 -07:00
Brings the configuration in line with Hanami 3.0.0 internationalization defaults by first loading the shared paths and then the load paths. Unfortunately, Hanami's default load paths are relative paths with glob syntax so we have to strip off the globs before adding with our specific globs. This is because Hanami supports different file formats but Dry Validation on supports YAMLs. Milestone: patch
18 lines
442 B
Ruby
18 lines
442 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "dry/validation"
|
|
|
|
module Terminus
|
|
# Defines user create contract.
|
|
class Contract < Dry::Validation::Contract
|
|
config.messages.backend = :i18n
|
|
|
|
Hanami.app.config.i18n.tap do |i18n|
|
|
(i18n.shared_load_path + i18n.load_path).each do |entry|
|
|
path = Hanami.app.root.join entry.sub(/\*.*/, "")
|
|
config.messages.load_paths.merge path.glob("**/*.yml")
|
|
end
|
|
end
|
|
end
|
|
end
|