i18n-js: I18n::JS::Middleware autogeneration not working in Rails 4.2.3

I added config.middleware.use I18n::JS::Middleware in development.rb but it does not work in rails 4.2.3 can someone reproduce this?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16

Commits related to this issue

Most upvoted comments

I’m not following why this would be an issue in production. This isn’t removing caching in the middleware, it’s only resets the caching once after the rails starts. Otherwise after the cache is created, each subsequent request (page refresh) uses the cache from then on. This mimics the same behavior of rails in that it initially loads and caches the yaml files into memory when the application first starts, and then uses the cache from then on.

With my pull request, if someone is using the middleware in production then this would only impact the very first request where it would rebuild the cache and files. Otherwise, it would continue to use the cache until someone restarts rails, which in production usually means a new deployment.

In the meantime, I’ve added this to my rails configuration which does the same thing.

I18N_MIDDLEWARE_CACHE = 'tmp/cache/i18n-js.yml'
if Rails.env.development? && File.exist?(I18N_MIDDLEWARE_CACHE)
    File.delete(I18N_MIDDLEWARE_CACHE) # clear i18n-js cache on startup
    config.middleware.use(I18n::JS::Middleware)
end