Sha256: 9ebec3544ab32dbf64f5d420618c85cabf47fe4e5bfcbac860f8144a53179b48

Contents?: true

Size: 1.69 KB

Versions: 27

Compression:

Stored size: 1.69 KB

Contents

module Localeapp
  module Rails
    def self.initialize
      if defined?(::Rails.logger)
        rails_logger = ::Rails.logger
      elsif defined?(RAILS_DEFAULT_LOGGER)
        rails_logger = RAILS_DEFAULT_LOGGER
      end

      if defined?(::Rails.env)
        rails_env = ::Rails.env
      elsif defined?(RAILS_ENV)
        rails_env = RAILS_ENV
      end

      if defined?(::Rails.root)
        rails_root = ::Rails.root
      elsif defined?(RAILS_ROOT)
        rails_root = RAILS_ROOT
      end

      ActionController::Base.send(:include, Localeapp::Rails::Controller)

      if ::Rails::VERSION::MAJOR == 2 && ::Rails::VERSION::MINOR >= 3 # TODO: Check previous rails versions if required
        require 'localeapp/rails/2_3_translation_helper_monkeypatch'
      end

      Localeapp.configure do |config|
        config.logger                     = rails_logger
        config.environment_name           = rails_env
        config.project_root               = rails_root
        config.synchronization_data_file  = File.join([rails_root, 'log', 'localeapp.yml'])
        config.translation_data_directory = File.join([rails_root, 'config', 'locales'])
      end
      initialize_synchronization_data_file
    end

    def self.initialize_synchronization_data_file
      if !File.exists?(Localeapp.configuration.synchronization_data_file)
        File.open(Localeapp.configuration.synchronization_data_file, 'w') do |f|
          f.write({:polled_at => Time.now.to_i, :updated_at => Time.now.to_i}.to_yaml)
        end
      end
    end
  end
end

if defined?(Rails)
  require 'localeapp/rails/controller'
  require 'localeapp/exception_handler'
  Localeapp::Rails.initialize
  Localeapp.log('Loaded localeapp/rails')
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
localeapp-0.6.10 lib/localeapp/rails.rb
localeapp-0.6.9 lib/localeapp/rails.rb
localeapp-0.6.8 lib/localeapp/rails.rb
localeapp-0.6.7 lib/localeapp/rails.rb
localeapp-0.6.6 lib/localeapp/rails.rb
localeapp-0.6.5 lib/localeapp/rails.rb
localeapp-0.6.4 lib/localeapp/rails.rb
localeapp-0.6.3 lib/localeapp/rails.rb
localeapp-0.6.2 lib/localeapp/rails.rb
localeapp-0.6.1 lib/localeapp/rails.rb
localeapp-0.6.0 lib/localeapp/rails.rb
localeapp-0.5.2 lib/localeapp/rails.rb
localeapp-0.5.1 lib/localeapp/rails.rb
localeapp-0.5.0 lib/localeapp/rails.rb
localeapp-0.4.3 lib/localeapp/rails.rb
localeapp-0.4.2 lib/localeapp/rails.rb
localeapp-0.4.1 lib/localeapp/rails.rb
localeapp-0.4.0 lib/localeapp/rails.rb
localeapp-0.3.2 lib/localeapp/rails.rb
localeapp-0.3.1 lib/localeapp/rails.rb