Skip to content
Browse files

Generate locales automatically at initialization with Rails engine.

  • Loading branch information...
1 parent 8a010cc commit 35d4bb89fcf9fa35cba0825f498abf96d28fd285 @whitequark whitequark committed Jul 22, 2011
Showing with 9 additions and 4 deletions.
  1. +1 −4 README
  2. +1 −0 lib/babilu.rb
  3. +7 −0 lib/babilu/engine.rb
View
5 README
@@ -41,9 +41,6 @@ layout. It will expand to javascript_include_tag 'babilu' on Rails <3.1, and to
empty string on Rails 3.1, but is still required to regenerate the file in
development mode.
-For Babilu to work in production mode, you need to add an initializer like this:
-
- # config/initializers/babilu.rb
- Babilu::Generator.generate
+In production mode, locales.js will be generated automatically at startup.
Copyright (c) 2008 Tore Darell, released under the MIT license
View
1 lib/babilu.rb
@@ -2,6 +2,7 @@
require "babilu/i18n_extensions"
require "babilu/generator"
require "babilu/include_tag_helper"
+require "babilu/engine"
ActionController::Base.send(:include, Babilu::Generator)
ActionView::Base.send(:include, Babilu::IncludeTagHelper)
View
7 lib/babilu/engine.rb
@@ -0,0 +1,7 @@
+module Babilu
+ class Engine < Rails::Engine
+ initializer 'babilu.generate_locales' do
+ Babilu::Generator.generate
+ end
+ end
+end

0 comments on commit 35d4bb8

Please sign in to comment.
Something went wrong with that request. Please try again.