Localisation for delayed_job

I can’t get delayed_job using the LOCALE file (fr in my case).

The Order Details emails received are in english while my staging instance in v1.3.1 with the fr LOCALE.

I have tried:

  • adding LOCALE=“fr” in .profile and in .bashrc of the user that monit is using
  • trying to start delayed_job manually (i.e. without monit) with the same user (running ruby ~/apps/openfoodnetwork/current/script/delayed_job -i 0 start)
  • modifying the start line in monit for openfoodnetwork start program = "/bin/bash -c 'LOCALE=fr RAILS_ENV=staging /home/offrance/.rbenv/shims/ruby /home/offrance/apps/openfoodnetwork/current/script/delayed_job -i 0 start'"

None of these changes worked.

Any clues?

Hi @marito59,

I haven’t encountered this before, but I have an approach that you could try as a start to an investigation.

The locale should be reading from config/application.rb, which in turn gets its values from config/application.yml. So check that both of these are as expected. Perhaps instrument application.rb to check that it’s being set to what you expect within the delayed job process. Also check the value of config.i18n.default_locale right before the email is rendered.

Hopefully something here will give a clue as to what’s happening.

Cheers,
Rohan

Thanks @RohanM.

Seems OK at first look, config.i18n.default_locale is ENV["LOCALE"]. I’ll try to instrument the code tonight to see the actual value that is used.

Well, I’ve got it, @RohanM

We need to have the following lines in config/application.rb:
config.i18n.default_locale = ENV["LOCALE"] I18n.locale = config.i18n.locale = config.i18n.default_locale

The information can be found here : https://stackoverflow.com/questions/8478597/rails-3-set-i18n-locale-is-not-working

It solved my issue.

Great! Could you submit a PR with that fix?

Done, #770.