Class: FastGettext::TranslationRepository::Logger

Inherits:
Base
  • Object
show all
Defined in:
lib/fast_gettext/translation_repository/logger.rb

Overview

This should be used in a TranslationRepository::Chain, so tat untranslated keys can be found Responsibility:

- log every translation call

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #options

Instance Method Summary collapse

Methods inherited from Base

#available_locales, #pluralisation_rule, #reload

Constructor Details

#initialize(name, options = {}) ⇒ Logger

Returns a new instance of Logger.



13
14
15
16
# File 'lib/fast_gettext/translation_repository/logger.rb', line 13

def initialize(name, options = {})
  super
  self.callback = options[:callback]
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



11
12
13
# File 'lib/fast_gettext/translation_repository/logger.rb', line 11

def callback
  @callback
end

Instance Method Details

#[](key) ⇒ Object



18
19
20
21
# File 'lib/fast_gettext/translation_repository/logger.rb', line 18

def [](key)
  callback.call(key)
  nil
end

#plural(*keys) ⇒ Object



23
24
25
26
# File 'lib/fast_gettext/translation_repository/logger.rb', line 23

def plural(*keys)
  callback.call(keys)
  []
end