This project is archived and is in readonly mode.

#6353 ✓resolved
Saimon Moore

I18n load path needs to be setup before eager loading

Reported by Saimon Moore | February 1st, 2011 @ 03:21 PM

While running some cucumber features I came across a failing cuke that at first glance seemed to be a simple case of a missing translation. In fact, the translation was not missing at all and was rendered properly when viewing the same page in development.

I traced the issue to the fact that in certain cases, when config.cache_classes is true (e.g. in cucumber environments), eager loading of various initializers triggers loading of app models (e.g. via observers). The I18n load path is setup (e.g. config/locales/*.{rb,yml} added to it) via an after_initialize hook but in this particular case, active record models that have been loaded via eagerly loaded initializers (e.g.) and use I18n (.e.g validation messages) don't see the fully loaded load path and thus we get the missing translation issue.

In my opinion, the I18n load path setup should happen before any eager loading is done so that it's completely setup if any AR models are eagerly loaded.

Please see my pull request ( which contains both a fix and a test that fails without the fix but passes with it.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by