我在ApplicationController中使用before_filter来设置我的应用程序的语言环境:
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
def set_locale
I18n.locale = request.compatible_language_from ["uk", "ru", "de", "en"]
end
end
它适用于我编写的控制器。但所有devise的消息仍然是英文。
在config/application.rb
中设置config.i18n.default_locale = "uk"
(或其他)有效,因此我猜测问题是devise的控制器不使用我的before_filter(可能它根本没有继承ApplicationController
?)。
如何解决这个问题?如何使devise使用我的语言环境?