diff options
Diffstat (limited to 'railties/lib/initializer.rb')
-rw-r--r-- | railties/lib/initializer.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index e3a0e3bad1..3e97a17e0e 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -147,7 +147,10 @@ module Rails initialize_dependency_mechanism initialize_whiny_nils initialize_temporary_session_directory + initialize_time_zone + initialize_i18n + initialize_framework_settings initialize_framework_views @@ -504,6 +507,18 @@ Run `rake gems:install` to install the missing gems. end end + # Set the i18n configuration from config.i18n but special-case for the load_path which should be + # appended to what's already set instead of overwritten. + def initialize_i18n + configuration.i18n.each do |setting, value| + if setting == :load_path + I18n.load_path += value + else + I18n.send("#{setting}=", value) + end + end + end + # Initializes framework-specific settings for each of the loaded frameworks # (Configuration#frameworks). The available settings map to the accessors # on each of the corresponding Base classes. @@ -732,6 +747,9 @@ Run `rake gems:install` to install the missing gems. # timezone to <tt>:utc</tt>. attr_accessor :time_zone + # Accessor for i18n settings. + attr_accessor :i18n + # Create a new Configuration instance, initialized with the default # values. def initialize @@ -755,6 +773,7 @@ Run `rake gems:install` to install the missing gems. self.database_configuration_file = default_database_configuration_file self.routes_configuration_file = default_routes_configuration_file self.gems = default_gems + self.i18n = default_i18n for framework in default_frameworks self.send("#{framework}=", Rails::OrderedOptions.new) @@ -967,6 +986,18 @@ Run `rake gems:install` to install the missing gems. def default_gems [] end + + def default_i18n + i18n = Rails::OrderedOptions.new + i18n.load_path = [] + + if File.exist?(File.join(RAILS_ROOT, 'config', 'locales')) + i18n.load_path << Dir[File.join(RAILS_ROOT, 'config', 'locales', '*.{rb,yml}')] + i18n.load_path.flatten! + end + + i18n + end end end |