Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n #14

Open
chiwenchen opened this issue May 15, 2017 · 1 comment
Open

i18n #14

chiwenchen opened this issue May 15, 2017 · 1 comment

Comments

@chiwenchen
Copy link

Hi there, is anyone knows how to set i18n translate for royce role?

@n-rodriguez
Copy link

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}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants