繁体   English   中英

I18n与发条一起

[英]I18n together with clockwork

当从发条方法调用模型方法“ model_method”时,I18n.locale始终等于我的默认语言环境。

如何将当前语言环境传递给模型方法?

clockwork.rb

every(10.minutes, 'test') do
  Book.delay(:queue => 'some_queue').model_method
end

book.rb

def self.model_method
  ...
  message = I18n.t('some_text')
  # always equals to ":en"
end

您可以传递语言环境选项:

  message = I18n.t('some_text', locale: 'en')

Read the documentation.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM