This project is archived and is in readonly mode.
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 (https://github.com/rails/rails/pull/179) which contains both a fix and a test that fails without the fix but passes with it.
Comments and changes to this ticket
-
Repository February 1st, 2011 @ 05:42 PM
- State changed from new to resolved
(from [c2aca3ddd78b514d099ddef5afc4cee0dd7d75f2]) Ensure I18n setup is only executed once if triggered on eager loading [#6353 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/c2aca3ddd78b514d099ddef5afc4c... -
Repository February 1st, 2011 @ 05:42 PM
(from [b1ca339b53559a71958c02644e329c714037f616]) Additionally trigger i18n configuration setup before any eager loading [#6353 state:resolved]
This handles the case where config.cache_classes is true and classes
are loaded before the I18n load path has had a chance to be populated.Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/b1ca339b53559a71958c02644e329... -
Repository February 1st, 2011 @ 05:43 PM
(from [979f38a4ff20f388bf75da2d1a3c7e76f1c82fc6]) Additionally trigger i18n configuration setup before any eager loading [#6353 state:resolved]
This handles the case where config.cache_classes is true and classes
are loaded before the I18n load path has had a chance to be populated.Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/979f38a4ff20f388bf75da2d1a3c7... -
Repository February 1st, 2011 @ 05:43 PM
(from [effb582955e0aedd12260ca989d77083c242b072]) Ensure I18n setup is only executed once if triggered on eager loading [#6353 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/effb582955e0aedd12260ca989d77... -
Sven Fuchs February 2nd, 2011 @ 02:57 PM
- Importance changed from to Low
Wow, that was quick!
I just wanted to +1 on this, but it's already applied.
Thanks Saimon for looking into this! And thanks Santiago for acting so quickly :)
-
Robert Pankowecki February 7th, 2011 @ 10:07 PM
Thank you for fixing this bug and backporting it to 3-0-stable :-)
-
tbh February 16th, 2011 @ 09:51 AM
Has this fix made its way into 3.0.4? I just upgraded and still have problems with mixed translations due to eagerly loaded models when using cache_classes = true.
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 6353 I18n load path needs to be setup before eager loading (from [c2aca3ddd78b514d099ddef5afc4cee0dd7d75f2]) Ensure ...
- 6353 I18n load path needs to be setup before eager loading (from [b1ca339b53559a71958c02644e329c714037f616]) Additio...
- 6353 I18n load path needs to be setup before eager loading (from [979f38a4ff20f388bf75da2d1a3c7e76f1c82fc6]) Additio...
- 6353 I18n load path needs to be setup before eager loading (from [effb582955e0aedd12260ca989d77083c242b072]) Ensure ...
- 5522 Model classes are loaded before I18n is set when running tests. Is #6353 about the same issue as this ticket? In case one...
- 5522 Model classes are loaded before I18n is set when running tests. Fixed on #6353.
- 5522 Model classes are loaded before I18n is set when running tests. It is a shame, I do not know what is wrong with this path...
- 5522 Model classes are loaded before I18n is set when running tests. Sorry Franco, but it was not intentional. Somehow, #6353 ...
- 5522 Model classes are loaded before I18n is set when running tests. Sorry Franco, but it was not intentional. Somehow, #6353 ...