0

How are you. I have just installed padrino framework admin panel. And it shows several tabs in admin module. I want to rename the labels. but how to do it? This is view side code

<%= link_to project_module.human_name, url(project_module.path) %>

Here I can't set human_name of project_module. And this is module definition in application.rb

access_control.roles_for :admin do |role|
      role.project_module :accounts, '/accounts'
      role.project_module :venues, '/venues'
      role.project_module :shows, '/shows'
end

Now tabs labels are Accounts, Venues, Shows. how to set them as Users, MyVenues, MyShows? Thanks

Nomura Nori
  • 4,689
  • 8
  • 47
  • 85

1 Answers1

1

Just seemed to hit this issue tonight as well. It seems that this is a slight bug that is in the core Padrino framework.

The standard navigation logic out of the box will never produce a proper localized text. It renders the output of function .humanize

https://github.com/padrino/padrino-framework/blob/8bd3796d45eae5e3f7dc52316c8c25c44563f8cd/padrino-admin/lib/padrino-admin/access_control.rb#L176

At best, the humanize function will upcase your text. See https://apidock.com/rails/String/humanize

You can replace the human_name reference with the I18n.t() localizable function:

  %ul.nav.navbar-nav.pull-left
        - project_modules.each do |project_module|
          %li{:class => "navbar-module #{('active' if request.path_info =~ /^#{project_module.path}/)}"}
            =link_to I18n.t(project_module.name), url(project_module.path)

See http://padrinorb.com/guides/features/localization/ for reference.

One note, the navigation is not model aware, so your translated text will need to be right under the locale reference in the yml file.

Ex.

en:
  accounts: Users
  venues: MyVenue
  shows: MyShows

This should do the trick. Let me know if you have any questions.