17 lines
588 B
Ruby
17 lines
588 B
Ruby
module ActiveModel
|
|
class Name
|
|
def human_plural
|
|
# Try to find the plural name of a model. If none can be found try to find a non namespaced version and return that one
|
|
default = Proc.new do |path|
|
|
if path.present? and path['/'] # non namespaced model a/b/c => a
|
|
unnamespaced_path = path.sub(/\.(\w+)\/[\w\\]+/, '.\1')
|
|
I18n.t(unnamespaced_path, default: Proc.new{ human.pluralize })
|
|
else
|
|
human.pluralize
|
|
end
|
|
end
|
|
I18n.t("#{@klass.i18n_scope}.models.plural.#{i18n_key}", default: default )
|
|
end
|
|
end
|
|
end
|