Skip to content

Commit

Permalink
Generate locales automatically at initialization with Rails engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jul 21, 2011
1 parent 8a010cc commit 35d4bb8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 empty string on Rails 3.1, but is still required to regenerate the file in
development mode. development mode.


For Babilu to work in production mode, you need to add an initializer like this: In production mode, locales.js will be generated automatically at startup.

# config/initializers/babilu.rb
Babilu::Generator.generate


Copyright (c) 2008 Tore Darell, released under the MIT license Copyright (c) 2008 Tore Darell, released under the MIT license
1 change: 1 addition & 0 deletions lib/babilu.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "babilu/i18n_extensions" require "babilu/i18n_extensions"
require "babilu/generator" require "babilu/generator"
require "babilu/include_tag_helper" require "babilu/include_tag_helper"
require "babilu/engine"


ActionController::Base.send(:include, Babilu::Generator) ActionController::Base.send(:include, Babilu::Generator)
ActionView::Base.send(:include, Babilu::IncludeTagHelper) ActionView::Base.send(:include, Babilu::IncludeTagHelper)
7 changes: 7 additions & 0 deletions lib/babilu/engine.rb
Original file line number Original file line Diff line number Diff line change
@@ -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.