<commit_before>module Kuhsaft
  module Translatable

    def self.included(base)
      base.extend ClassMethods
    end

    extend self

    module ClassMethods
      def translate(*args)
        args.each do |attr_name|
          define_method attr_name do
            send "#{attr_name}_#{locale_for_attr_name}"
          end

          define_method "#{attr_name}?" do
            send "#{attr_name}_#{locale_for_attr_name}?"
          end

          define_method "#{attr_name}=" do |val|
            send "#{attr_name}_#{locale_for_attr_name}=", val
          end

          define_singleton_method "find_by_#{attr_name}" do |val|
            send "find_by_#{attr_name}_#{locale_for_attr_name}", val
          end
        end
      end

      def locale_for_attr_name
        I18n.locale.to_s.gsub('-', '_').downcase
      end

      def locale_attr attr_name
        "#{attr_name}_#{locale_for_attr_name}"
      end
    end

    def locale_for_attr_name
      I18n.locale.to_s.gsub('-', '_').downcase
    end

    def locale_attr(attr_name)
      "#{attr_name}_#{locale_for_attr_name}"
    end
  end
end<commit_msg>avoid redundance methods<commit_after>module Kuhsaft
  module Translatable

    def self.included(base)
      base.extend ClassMethods
    end

    extend self

    module ClassMethods
      def translate(*args)
        args.each do |attr_name|
          define_method attr_name do
            send "#{attr_name}_#{locale_for_attr_name}"
          end

          define_method "#{attr_name}?" do
            send "#{attr_name}_#{locale_for_attr_name}?"
          end

          define_method "#{attr_name}=" do |val|
            send "#{attr_name}_#{locale_for_attr_name}=", val
          end

          define_singleton_method "find_by_#{attr_name}" do |val|
            send "find_by_#{attr_name}_#{locale_for_attr_name}", val
          end
        end
      end

      def locale_for_attr_name
        I18n.locale.to_s.gsub('-', '_').downcase
      end

      def locale_attr attr_name
        "#{attr_name}_#{locale_for_attr_name}"
      end
    end

    include ClassMethods
  end
end
{'fraction_non_alphanumeric': 0.09568924680246328, 'fraction_numerical': 0.0028422548555187117, 'mean_word_length': 2.209726443768997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6245445', 'n_tokens_mistral': 686, 'n_tokens_neox': 681, 'n_words': 134}