[英]I18n together with clockwork
When a model method "model_method" is called from clockwork, I18n.locale always equals to my default locale. 当从发条方法调用模型方法“ model_method”时,I18n.locale始终等于我的默认语言环境。
How do I pass the current locale to the model method? 如何将当前语言环境传递给模型方法?
Part of clockwork.rb
: clockwork.rb
:
every(10.minutes, 'test') do
Book.delay(:queue => 'some_queue').model_method
end
Part of book.rb
: book.rb
:
def self.model_method
...
message = I18n.t('some_text')
# always equals to ":en"
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.