Royce
Royce copied to clipboard
i18n
Hi there, is anyone knows how to set i18n translate for royce role?
That's what I did for my app :
module MyApp
module CoreExt
module RoyceRolePatch
def self.included(base)
base.send(:prepend, InstanceMethods)
base.class_eval do
scope :order_by_name, -> { order(name: :asc) }
end
end
module InstanceMethods
def to_s
super.capitalize
end
end
end
end
end
unless Royce::Role.included_modules.include?(MyApp::CoreExt::RoyceRolePatch)
Royce::Role.send(:include, MyApp::CoreExt::RoyceRolePatch)
end
It adds a scope order_by_name
and override to_s
method. You could change it to
I18n.t("roles.#{name}")