Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Config option to prevent i18n.reload! on each request

#4820

In development mode on each request I18n.reload! is called. If you use a custom backend that e.g. loads all translations from a database this will significantly slow down development.

Attached patches for 2-3-stable and rails 3 add the option config.i18n.reload_on_each_request, which is default set to +false+. In environment/development.rb it is set to +true+ by default.

Reported by Lawrence Pit · June 10th, 2010 @ 02:03 PM

State: invalid
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Lawrence Pit
  2. Lawrence Pit
    Lawrence Pit

    Btw, in rails 3 I18n.reload! is called twice on initialization in railtie.rb, namely in "i18n.initialize" and in the after_initialize. Not sure if any of the two could be removed.. it seems to me the call in the initialize block could be removed. What do you think?

    June 10th, 2010 @ 02:09 PM

  3. José Valim
    José Valim
    • Milestone cleared.

    Hey Lawrence, a few notes. First, it would be nice if the new option you added simply delegates to config.cache_classes if it is not set. I think that less than 1% of people are going to use it, so it makes no sense being required to add it config/environments/*.rb.

    Besides that, it looks great! Just one note, you don't need to update the patch for Rails 2.3, because I'm not willing to apply it on 2.3, since it's a maintenance branch.

    June 10th, 2010 @ 02:12 PM

  4. Lawrence Pit
    Lawrence Pit

    In development mode I do want to reload the classes on each request, just not all the i18n stuff, so delegating to cache_caches is not what I want.

    I think > 90% don't do i18n, they just hard code all strings. So having i18n reload by default is just a waste for them.

    June 11th, 2010 @ 01:23 AM

  5. José Valim
    José Valim

    It's going to delegate to cache_classes unless it is set. The idea is to avoid configuration hell. If they are not using I18n at all, reloading it take few miliseconds just.

    June 11th, 2010 @ 07:22 AM

  6. José Valim
    José Valim

    We just changed I18n.reload! to be called only if any of the locale files were modified. This may have solved your problem!

    June 21st, 2010 @ 12:10 PM

  7. Lawrence Pit
    Lawrence Pit

    Brilliant! Thanks mate, like it a lot !

    June 21st, 2010 @ 01:47 PM

  8. José Valim
    José Valim
    • State changed from new to invalid

    Ok, closing. :)

    June 21st, 2010 @ 02:25 PM

  9. Jeremy Kemper
  10. Ryan Bigg
    Ryan Bigg
    • Importance changed from to Low

    Automatic cleanup of spam.

    November 8th, 2010 @ 01:48 AM