0

I Have been using resque quite comfortably, But for following scenario

In one of my perform method

class A < ActiveRecord::Base
  def self.perform
    B.something
  end
end

class B < ActiveRecord::Base
  def self.something
   l = Misc.get_locale
    ....
    ....
  end
end

class Misc
  def self.get_locale
    return I18n.locale
  end
end

Issue is that it always return I18n.locale as :en even though in my application config, I have set it to :us_en(or whatever), like below

config.i18n.default_locale = :us_en
config.i18n.locale = :us_en

Is it because I am reading that I18n.locale from a class and not a rails Model? Or is it because of some other reason?

4

1 回答 1

0

我认为 resque 更有可能没有读取您的 rails 配置。

您可以尝试在初始化程序中设置它(我相信应该阅读)。

config/initalizers/i18n.rb

I18n.default_locale = 'en-US'
I18n.locale = 'en-US'

作为旁注,语言代码在bcp47标准中用于识别语言的区域代码之前首先出现(尽管我是肛门!)。

于 2012-09-12T00:30:52.523 回答