<commit_before>module I18n
  module Backend

    class Simple

      def localize_with_complements(locale, object, format = nil, options = {})
        
        if object.respond_to?(:strftime)
          format ||= :default
          return localize_without_complements(locale, object, format, options)
        elsif object.respond_to?(:abs)
          if currency = options[:currency]
            raise I18n::InvalidCurrency.new("Currency #{currency.to_s} does not exist.") unless I18nComplements::Numisma[currency.to_s]
            return I18nComplements::Numisma[currency.to_s].localize(object, :locale => locale)
          else
            formatter = I18n.translate('number.format'.to_sym, :locale => locale, :default => {})
            if formatter.is_a?(Proc)
              return formatter[object]
            elsif formatter.is_a?(Hash)
              formatter = {:format => "%n", :separator => '.', :delimiter => '', :precision => 3}.merge(formatter).merge(options)
              format = formatter[:format]
              negative_format = formatter[:negative_format] || "-" + format

              if object.to_f < 0
                format = negative_format
                object = object.abs
              end
              
              value = object.to_s.split(/\./)
              integrals, decimals = value[0].to_s, value[1].to_s
              value = integrals.gsub(/^0+[1-9]+/, '').gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{formatter[:delimiter]}")
              decimals = "0" if decimals.to_s.match(/^\s*$/) and object.is_a?(Float)
              unless decimals.to_s.match(/^\s*$/)
                value << formatter[:separator]
                value << decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').scan(/.{1,3}/).join(formatter[:delimiter])
              end
              return format.gsub(/%n/, value).gsub(/%s/, "\u{00A0}")
            end
          end
        elsif object.is_a?(TrueClass) or object.is_a?(FalseClass)
          return I18n.translate("boolean.human.#{object.to_s}_class")
        elsif object.is_a?(String)
          return object          
        else
          raise ArgumentError, "Object must be a Numeric, TrueClass, FalseClass, String, Date, DateTime or Time object. #{object.class.name}:#{object.inspect} given."
        end
      end

      alias_method(:localize_without_complements, :localize)
      alias_method(:localize, :localize_with_complements)

    end
  end
end<commit_msg>Considers locale parameter for boolean l10n<commit_after>module I18n
  module Backend

    class Simple

      def localize_with_complements(locale, object, format = nil, options = {})
        
        if object.respond_to?(:strftime)
          format ||= :default
          return localize_without_complements(locale, object, format, options)
        elsif object.respond_to?(:abs)
          if currency = options[:currency]
            raise I18n::InvalidCurrency.new("Currency #{currency.to_s} does not exist.") unless I18nComplements::Numisma[currency.to_s]
            return I18nComplements::Numisma[currency.to_s].localize(object, :locale => locale)
          else
            formatter = I18n.translate('number.format'.to_sym, :locale => locale, :default => {})
            if formatter.is_a?(Proc)
              return formatter[object]
            elsif formatter.is_a?(Hash)
              formatter = {:format => "%n", :separator => '.', :delimiter => '', :precision => 3}.merge(formatter).merge(options)
              format = formatter[:format]
              negative_format = formatter[:negative_format] || "-" + format

              if object.to_f < 0
                format = negative_format
                object = object.abs
              end
              
              value = object.to_s.split(/\./)
              integrals, decimals = value[0].to_s, value[1].to_s
              value = integrals.gsub(/^0+[1-9]+/, '').gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{formatter[:delimiter]}")
              decimals = "0" if decimals.to_s.match(/^\s*$/) and object.is_a?(Float)
              unless decimals.to_s.match(/^\s*$/)
                value << formatter[:separator]
                value << decimals.gsub(/0+$/, '').ljust(formatter[:precision], '0').scan(/.{1,3}/).join(formatter[:delimiter])
              end
              return format.gsub(/%n/, value).gsub(/%s/, "\u{00A0}")
            end
          end
        elsif object.is_a?(TrueClass) or object.is_a?(FalseClass)
          return I18n.translate("boolean.human.#{object.to_s}_class", locale: locale)
        elsif object.is_a?(String)
          return object          
        else
          raise ArgumentError, "Object must be a Numeric, TrueClass, FalseClass, String, Date, DateTime or Time object. #{object.class.name}:#{object.inspect} given."
        end
      end

      alias_method(:localize_without_complements, :localize)
      alias_method(:localize, :localize_with_complements)

    end
  end
end
{'fraction_non_alphanumeric': 0.14210526315789473, 'fraction_numerical': 0.01174089068825911, 'mean_word_length': 2.1959896507115135, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '1357531', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1450, 'n_words': 282}