Module: Formeze::Errors
- Defined in:
- lib/formeze/errors.rb
Constant Summary collapse
- SCOPE =
[:formeze, :errors].freeze
- DEFAULT =
{ bad_value: 'is invalid', not_accepted: 'is not an accepted file type', not_multiline: 'cannot contain newlines', no_match: 'is invalid', required: 'is required', too_large: 'is too large', too_long: 'is too long', too_short: 'is too short', }
Class Method Summary collapse
Class Method Details
.translate(error, scope:) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/formeze/errors.rb', line 17 def self.translate(error, scope:) default = DEFAULT[error] || 'is invalid' return default unless defined?(I18n) = I18n.translate(error, scope: scope, default: nil) || I18n.translate(error, scope: SCOPE, default: default) end |