Sha256: de7a42f7168d7d857c16af5e4b2af3ff75a77943e9f0470b7b18cbbe54ad409d

Contents?: true

Size: 613 Bytes

Versions: 8

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fast_gettext-3.1.0 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.3.0 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.2.0 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.1.0 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.0.3 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.0.2 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.0.1 lib/fast_gettext/translation_repository/logger.rb
fast_gettext-2.0.0 lib/fast_gettext/translation_repository/logger.rb