<commit_before>require 'i18n'
require 'i18n/debug/version'

module I18n
  module Debug
    @on_lookup = lambda do |key, result|
      logger.debug("[i18n-debug] #{key} => #{result.inspect}")
    end

    class << self
      attr_accessor :logger, :on_lookup

      def logger
        @logger ||=
          if defined?(::Rails)
            ::Rails.logger
          else
            require 'logger'
            ::Logger.new($stdout)
          end
      end
    end

    module Hook
      def self.included(klass)
        klass.class_eval do
          alias_method :lookup_without_debug, :lookup
          alias_method :lookup, :lookup_with_debug
        end
      end

      def lookup_with_debug(*args)
        lookup_without_debug(*args).tap do |result|
          options = args.last.is_a?(Hash) ? args.pop : {}
          separator = options[:separator] || I18n.default_separator
          key = I18n.normalize_keys(*args, separator).join(separator)
          Debug.on_lookup[key, result]
        end
      end
    end
  end

  Backend::Simple.include(Debug::Hook)
end
<commit_msg>Use Module#prepend instead of aliasing<commit_after>require 'i18n'
require 'i18n/debug/version'

module I18n
  module Debug
    @on_lookup = lambda do |key, result|
      logger.debug("[i18n-debug] #{key} => #{result.inspect}")
    end

    class << self
      attr_accessor :logger, :on_lookup

      def logger
        @logger ||=
          if defined?(::Rails)
            ::Rails.logger
          else
            require 'logger'
            ::Logger.new($stdout)
          end
      end
    end

    module Hook
      def lookup(*args)
        super.tap do |result|
          options = args.last.is_a?(Hash) ? args.pop : {}
          separator = options[:separator] || I18n.default_separator
          key = I18n.normalize_keys(*args, separator).join(separator)
          Debug.on_lookup[key, result]
        end
      end
    end
  end

  Backend::Simple.prepend(Debug::Hook)
end

{'fraction_non_alphanumeric': 0.10868461147790756, 'fraction_numerical': 0.01218892839004571, 'mean_word_length': 2.068535825545171, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6913721', 'n_tokens_mistral': 629, 'n_tokens_neox': 604, 'n_words': 134}