File: logger.rb

package info (click to toggle)
ruby-fast-gettext 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 720 kB
  • ctags: 301
  • sloc: ruby: 3,092; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 578 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'fast_gettext/translation_repository/base'

module FastGettext
  module TranslationRepository
    # This should be used in a TranslationRepository::Chain, so tat untranslated keys can be found
    # Responsibility:
    #  - log every translation call
    class Logger < Base
      attr_accessor :callback

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

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

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