I am trying to create an Arabic version of a Rails app which is based on Blacklight. Here's the problem I am facing:
When I switch the language, everything translates perfectly EXCEPT the Blacklight labels. It's only when I refresh the page that the labels get translated.
This is the label I want to display: "ترتيب حسب عام" (Translation: Sort by Year)
But this is what I am getting currently: "Year ترتيب حسب"
The same issue happens when switching back to English from Arabic - the label displays in Arabic until I refresh the page.
This is what my Blacklight configuration looks like:
class CatalogController < ApplicationController
include Blacklight::Catalog
configure_blacklight do |config|
# ...
config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => I18n.t('sortby.year')
# ...
end
end
Here's how I am setting the locale in my Application controller:
class ApplicationController < ActionController::Base
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# ...
end
I am not sure what's happening and I would really appreciate your help in this.