Reputation: 23
search status not translated (image)
English Locale (activeadmin.en.yml)
en:
active_admin:
search_status:
headline: "Search status:"
Japanese Locale (activeadmin.ja.yml)
ja:
active_admin:
search_status:
headline: "検索条件:"
I already have these translations in my yml files but I don't know why it won't work. I also found that ActiveAdmin uses this code I18n.t("active_admin.search_status.headline")
I've already searched for issues in ActiveAdmin Github page and here on StackOverflow but I can't find any same issue I'm having right now.
Upvotes: 2
Views: 800
Reputation: 1736
Looking at the code Activeadmin seems to have a bug.
The following line seems to be executed only once and does not change with the current locale
ActiveAdmin::SidebarSection.new I18n.t("active_admin.search_status.headline"), only: :index, if: -> { params[:q] || params[:scope] } do
Another line of code in activeadmin is like this and is working properly whenever the locale is changed
ActiveAdmin::SidebarSection.new :filters, only: :index, if: ->{ active_admin_config.filters.any? } do
So it seems that it would be better to pass a symbol instead. Here is a patch(add this to an intializer) you can add to make it work:
module ActiveAdmin
module Filters
module ResourceExtension
def search_status_section
ActiveAdmin::SidebarSection.new :headline, only: :index, if: -> { params[:q] || params[:scope] } do
active = ActiveAdmin::Filters::Active.new(resource_class, params)
span do
h4 I18n.t("active_admin.search_status.current_scope"), style: 'display: inline'
b active.scope, style: "display: inline"
div style: "margin-top: 10px" do
h4 I18n.t("active_admin.search_status.current_filters"), style: 'margin-bottom: 10px'
ul do
if active.filters.blank?
li I18n.t("active_admin.search_status.no_current_filters")
else
active.filters.each do |filter|
li do
span filter.body
b filter.value
end
end
end
end
end
end
end
end
end
end
end
Also, add a headline
key on your locale file:
sidebars:
filters: "検索条件"
search_status: "検索状態"
headline: "TODO Search status:"
Upvotes: 1
Reputation: 7044
Actually, your yml
files should look like this:
activeadmin.en.yml:
en:
active_admin:
search_status:
headline: "Search status:"
activeadmin.ja.yml:
ja:
active_admin:
search_status:
headline: "検索条件:"
Upvotes: 1