Sha256: 90560cdfdd86bf02274b375b1f043d8b62f09523d4531c5356e9761a263a865c

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Localeapp
  module Rails
    module Controller
      def self.included(base)
        base.before_filter :handle_translation_updates
        base.after_filter  :send_missing_translations
      end

      def handle_translation_updates
        raise Localeapp::MissingApiKey unless ::Localeapp.configuration.api_key
        unless ::Localeapp.configuration.polling_disabled?
          ::Localeapp.log_with_time 'Handling translation updates'
          if ::Localeapp.poller.needs_polling?
            ::Localeapp.log_with_time 'polling'
            ::Localeapp.poller.poll!
          end
        end

        unless ::Localeapp.configuration.reloading_disabled?
          if ::Localeapp.poller.needs_reloading?
            ::Localeapp.log_with_time 'reloading I18n'
            I18n.reload!
            ::Localeapp.poller.updated_at = ::Localeapp.poller.synchronization_data[:updated_at]
          end
        end
      end

      def send_missing_translations
        return if ::Localeapp.configuration.sending_disabled?

        ::Localeapp.sender.post_missing_translations
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
localeapp-0.7.0 lib/localeapp/rails/controller.rb
localeapp-0.6.14 lib/localeapp/rails/controller.rb
localeapp-0.6.13 lib/localeapp/rails/controller.rb
localeapp-0.6.12 lib/localeapp/rails/controller.rb