我的before_filter使用的ApplicationController爲我的應用程序設置的地點:Ruby on Rails + Devise + I18n:如何設置區域設置?
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
它適用於由我寫的控制器。但是,所有設計的信息仍然是英語。
設置config.i18n.default_locale = "uk"
(或其他)在config/application.rb
的作品,所以我想這麻煩的是能想出的控制器不使用我的before_filter(可能是,它不繼承ApplicationController
在所有的(?))。
如何解決此問題?如何使設計使用我的語言環境?
devise使用您的應用程序ApplicationController。這可以通過parent_controller設置進行配置。 – phoet
@Hauleth是的,我做到了。如果我將application.rb中的config.i18n.default_locale設置爲默認的非英文語言環境,它們就會工作 – frp