Strange problem setting correct locale for Hobo 1.3

26 views
Skip to first unread message

Ronny Hanssen

unread,
Jun 16, 2011, 6:58:02 PM6/16/11
to hobo...@googlegroups.com
I am running a site in development where I have set the appropriate locale (to norwegian, :nb), and everything is working fine. I can also switch between different locales without a problem. However, I am experiencing problems controlling the locale - now that I am deploying the site to a server hosted by my customer. At this location they already have an old version of this site (my first version, running a hobo-site that is almost at hobo-1.0). The old app is btw running fine with the :nb locale (in production). The site is set up using nginx, passenger and ruby-ee.

For testing the latest commits I have created an "edge"-environment that I am deploying to. The new site is also running on the same setup as above, except this time it is using rails 3, bundler and Gemfile to specify the rails3/Hobo1.3 environment - and it is also using another port to target the site. Everything seems to work out as expected, except one strange thing:

The site uses :en for the locale, even though I am very certain that it is set up correctly. I have added an initializer that writes the locale to the log during startup to confirm that I have :nb set up - the output claims that :nb is set - as expected. I have in addition to this also started the Rails console in "edge" environment (RAILS_ENV=edge rails c), and this is what it yields:
ree-1.8.7-2010.02 :005 > DJBM2::Application.config.i18n.default_locale
 => :nb
I also did the following, confirming that my locale-files are available:
ree-1.8.7-2010.02 :008 > pp DJBM2::Application.config.i18n
{[:railties_load_path,
  ["/var/www/djbm2-edge/releases/20110614183129/config/locales/hobo.nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/en.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/app.nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/hobo.en.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/app.en.yml"]]=>
  nil,
 [:load_path,
  ["/var/www/djbm2-edge/releases/20110614183129/config/locales/hobo.nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/en.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/app.nb.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/hobo.en.yml",
   "/var/www/djbm2-edge/releases/20110614183129/config/locales/app.en.yml"]]=>
  nil,
 [:default_locale, :nb]=>nil}
 => nil
I am totally unable to find out where the locale gets changed back to :en during requests. Could there perhaps be issues with using a custom environment name ("edge")?

Any help appreciated, thanks,
Ronny

Ronny Hanssen

unread,
Jun 18, 2011, 6:51:40 PM6/18/11
to hobo...@googlegroups.com
I just made a check using a before_filter in the application_controller, and my app thinks that the locale is :nb when each controller action kicks in. In other words - my config setting is good (DJBM2::Application.config.i18n.default_locale=:nb)

I am still able to see that the locales that are looked up are using :en when finding them.

Could this be a strange side-effect to memory sharing between passenger (and ruby-ee) rails instance code?

I am not sure how to get ahead with this. Anyone got some tips on how to figure out what and why this doesn't work?

This is really weird...


~Ronny

Ronny Hanssen

unread,
Jun 19, 2011, 5:03:58 AM6/19/11
to hobo...@googlegroups.com
I tried to rename all the :en locale-files to :nb, since it was using the :en strings and not the :nb ones. It still shows the same english strings, so it seems it isn't even using the locale-folder.

So in desperation I added another:
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
to the application config. But, it still doesn't use my locale setting or my locales.

I then renamed my locales folder to force rails to not use it, but even that didn't make a change.

I have checked using:
config.hobo.show_translation_keys = true
which confirms that all translations are done using :en as key, instead of the :nb default_locale.

So, somewhere - somehow the locale-setting changes from :nb to :en.

I changed the debug code in my controller action to use locale instead of default_locale. The output shows that when it enters the controller the locale is unset (default_locale is :nb though).I then force the locale by setting set it it is :nb:
DJBM2::Application.config.i18n.locale=:nb
(and confirmed the setting by log-output). But, when the translation methods are called it is again using :en as the locale.

This is freaking me out!
How and where is it getting set to :en?
How can that happen?
Any ideas?


~Ronny

Domizio Demichelis

unread,
Jun 19, 2011, 7:27:27 AM6/19/11
to hobo...@googlegroups.com
Ronny,
please, post a bare app that reproduces the behaviour and I will look into it.

ciao
dd

--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/pHZmA75qBEkJ.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

Reply all
Reply to author
Forward
0 new messages