0
votes

I'm localizing Rails app with Rails Admin using I18n. In some models (Good < ActiveRecord) Rails admin configured as follows:

rails_admin do
  label = 'Good'
  label_plural = 'Goods'
  navigation_label = 'Settings'
  navigation_icon = 'icon-settings'
end

I know that label localization can be stored in config/locales/en.yml (Translations for Active Record Models) as follows:

en:
  activerecord:
    models:
      good:
        one: Good
        few: Goods
        many: Goods
        other: Goods

The question is: how can I store and use locale for navigation_label? (Can't find the answer on rails admin wiki page)

1

1 Answers

1
votes

Here's a way I got it to work. Define your label as:

NAV_SETTINGS = Proc.new { I18n.t('admin.navigation_labels.settings') }

Then, when you make the call in your model configuration to use the labels, use:

navigation_label NAV_SETTINGS

Then, of course, set your config/en.yml like:

en:
  admin:
    navigation_labels:
      settings: Settings

But in terms of having RailsAdmin do it for you, I haven't encountered it.

I have not tried this defining Rails Admin config in the model itself, but I know it works when defining things in config/initializers/rails_admin.rb, so should work here as well.