Module: Localeapp::Rails::Controller

Defined in:
lib/localeapp/rails/controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
# File 'lib/localeapp/rails/controller.rb', line 4

def self.included(base)
  base.before_filter :handle_translation_updates
  base.after_filter  :send_missing_translations
end

Instance Method Details

#handle_translation_updatesObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/localeapp/rails/controller.rb', line 9

def handle_translation_updates
  raise Localeapp::MissingApiKey unless ::Localeapp.configuration.has_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.sync_data.updated_at
    end
  end
end

#send_missing_translationsObject



28
29
30
31
32
# File 'lib/localeapp/rails/controller.rb', line 28

def send_missing_translations
  return if ::Localeapp.configuration.sending_disabled?
  ::Localeapp.missing_translations.reject_blacklisted
  ::Localeapp.sender.post_missing_translations
end