<commit_before>require "i18n"

module I18n
  module Backend
    class MongoDB
      include Base, Flatten
      
      attr_accessor :collection
      
      def initialize(collection, auto_insert_missing=false)
        @collection, @auto_insert_missing = collection, auto_insert_missing
        @collection.ensure_index([['k', 1], ['l', 1]], unique: true)
      end
      
      def available_locales
        collection.distinct(:l).map(&:to_sym)
      end
      
      def store_translations(locale, data, options={})
        flatten_translations(locale, data, options.fetch(:escape, false), true).each do |key, value|
          self.update_collection(locale, key, value)
        end
      end
      
      def translate(locale, key, options={})
        super
      rescue I18n::MissingTranslationData => e
        self.update_collection(locale, key, nil) if @auto_insert_missing
        raise e
      end
      
      protected
      
      def lookup(locale, key, scope=[], options={})
        key   = normalize_flat_keys(locale, key, scope, options[:separator])<commit_msg>fix name of missing translation exception<commit_after>require "i18n"

module I18n
  module Backend
    class MongoDB
      include Base, Flatten
      
      attr_accessor :collection
      
      def initialize(collection, auto_insert_missing=false)
        @collection, @auto_insert_missing = collection, auto_insert_missing
        @collection.ensure_index([['k', 1], ['l', 1]], unique: true)
      end
      
      def available_locales
        collection.distinct(:l).map(&:to_sym)
      end
      
      def store_translations(locale, data, options={})
        flatten_translations(locale, data, options.fetch(:escape, false), true).each do |key, value|
          self.update_collection(locale, key, value)
        end
      end
      
      def translate(locale, key, options={})
        super
      rescue I18n::MissingTranslation => e
        self.update_collection(locale, key, nil) if @auto_insert_missing
        raise e
      end
      
      protected
      
      def lookup(locale, key, scope=[], options={})
        key   = normalize_flat_keys(locale, key, scope, options[:separator])
{'fraction_non_alphanumeric': 0.0981651376146789, 'fraction_numerical': 0.007339449541284404, 'mean_word_length': 2.5754098360655737, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7457835', 'n_tokens_mistral': 627, 'n_tokens_neox': 612, 'n_words': 154}