Sha256: 0f708b6d08b9a027aaccbb480684b6657bbd7f397b6f8b6d31080f189b2b959b
Contents?: true
Size: 825 Bytes
Versions: 5
Compression:
Stored size: 825 Bytes
Contents
require 'i18n' require 'dry/validation/messages/abstract' module Dry module Validation class Messages::I18n < Messages::Abstract attr_reader :t ::I18n.load_path.concat(config.paths) def initialize super @t = I18n.method(:t) end def get(key, options = {}) t.(key, options) if key end def rule(name, options = {}) path = "rules.#{name}" get(path, options) if key?(path, options) end def key?(key, options) ::I18n.exists?(key, options.fetch(:locale, default_locale)) || ::I18n.exists?(key, I18n.default_locale) end def merge(path) ::I18n.load_path << path self end def default_locale I18n.locale || I18n.default_locale || super end end end end
Version data entries
5 entries across 5 versions & 1 rubygems