【问题标题】:Devise timeout message always in default language始终以默认语言设计超时消息
【发布时间】:2013-01-29 07:31:06
【问题描述】:

我有一个带有设计和 30 分钟会话超时的 Rails 应用程序。当会话过期并且用户重新加载页面或单击链接时,他们会收到消息Your session expired, please sign in again to continue.,但此消息始终使用默认语言(在我的情况下为英语)。我已经配置了语言环境文件,devise.en.ymldevise.ru.yml

有没有办法以当前语言显示 Flash 消息?

【问题讨论】:

  • 您如何设置请求的语言环境?
  • 在带有 before_filter :set_locale 的 application_controller.rb 中。我认为该设计在收到请求之前设置了闪存消息。

标签: ruby-on-rails-3 internationalization devise locale


【解决方案1】:

应用程序控制器仅在用户登录时处理内容。尝试将 before_filter :set_locale 添加到 DeviseSessions 控制器的自定义子类中。

【讨论】:

  • 非常感谢,但这并不能解决我的问题。我手动设置了I18n.locale = :ru,但没有更改超时消息。我认为如果当前用户语言使用I18n.default_locale 值而不是设计
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多