mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
minor stuff
This commit is contained in:
parent
9e2d95c3e1
commit
d89266d9f1
@ -84,7 +84,7 @@ module ValidatesTimeliness
|
|||||||
restriction = [restriction] unless restriction.is_a?(Array)
|
restriction = [restriction] unless restriction.is_a?(Array)
|
||||||
|
|
||||||
if defined?(I18n)
|
if defined?(I18n)
|
||||||
message = custom_error_messages[option] || I18n.translate('activerecord.errors.messages')[option]
|
message = custom_error_messages[option] || I18n.t('activerecord.errors.messages')[option]
|
||||||
subs = message.scan(/\{\{([^\}]*)\}\}/)
|
subs = message.scan(/\{\{([^\}]*)\}\}/)
|
||||||
interpolations = {}
|
interpolations = {}
|
||||||
subs.each_with_index {|s, i| interpolations[s[0].to_sym] = restriction[i].strftime(format) }
|
subs.each_with_index {|s, i| interpolations[s[0].to_sym] = restriction[i].strftime(format) }
|
||||||
@ -150,16 +150,16 @@ module ValidatesTimeliness
|
|||||||
class << self
|
class << self
|
||||||
|
|
||||||
def default_error_messages
|
def default_error_messages
|
||||||
if Rails::VERSION::STRING < '2.2'
|
if defined?(I18n)
|
||||||
::ActiveRecord::Errors.default_error_messages
|
I18n.t('activerecord.errors.messages')
|
||||||
else
|
else
|
||||||
I18n.translate('activerecord.errors.messages')
|
::ActiveRecord::Errors.default_error_messages
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_value_formats
|
def error_value_formats
|
||||||
if defined?(I18n)
|
if defined?(I18n)
|
||||||
I18n.translate('validates_timeliness.error_value_formats')
|
I18n.t('validates_timeliness.error_value_formats')
|
||||||
else
|
else
|
||||||
@@error_value_formats
|
@@error_value_formats
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user