<commit_before>module TranslatableFormHelper
  def translatable_form_for(record_or_record_path, options = {})
    object = record_or_record_path.is_a?(Array) ? record_or_record_path.last : record_or_record_path

    form_for(record_or_record_path, options.merge(builder: TranslatableFormBuilder)) do |f|

      object.globalize_locales.each do |locale|
        concat translation_enabled_tag(locale, enable_locale?(object, locale))
      end

      yield(f)
    end
  end

  def merge_translatable_field_options(options, locale)
    options.merge(
      class: "#{options[:class]} js-globalize-attribute".strip,
      style: display_translation?(locale),
      data:  options.fetch(:data, {}).merge(locale: locale),
      label_options: {
        class: "#{options[:class]} js-globalize-attribute".strip,
        style: display_translation?(locale),
        data:  (options.dig(:label_options, :data) || {}) .merge(locale: locale)
      }
    )
  end
end

class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder

  def translatable_text_field(method, options = {})
    translatable_field(:text_field, method, options)
  end
  def translatable_text_area(method, options = {})
    translatable_field(:text_area, method, options)
  end

  private

    def translatable_field(field_type, method, options = {})
      @template.capture do
        @object.globalize_locales.each do |locale|
          Globalize.with_locale(locale) do
            final_options = @template.merge_translatable_field_options(options, locale)
            @template.concat send(field_type, "#{method}_#{locale}", final_options)
          end
        end
      end
    end
end<commit_msg>Add missing blank line between methods<commit_after>module TranslatableFormHelper
  def translatable_form_for(record_or_record_path, options = {})
    object = record_or_record_path.is_a?(Array) ? record_or_record_path.last : record_or_record_path

    form_for(record_or_record_path, options.merge(builder: TranslatableFormBuilder)) do |f|

      object.globalize_locales.each do |locale|
        concat translation_enabled_tag(locale, enable_locale?(object, locale))
      end

      yield(f)
    end
  end

  def merge_translatable_field_options(options, locale)
    options.merge(
      class: "#{options[:class]} js-globalize-attribute".strip,
      style: display_translation?(locale),
      data:  options.fetch(:data, {}).merge(locale: locale),
      label_options: {
        class: "#{options[:class]} js-globalize-attribute".strip,
        style: display_translation?(locale),
        data:  (options.dig(:label_options, :data) || {}) .merge(locale: locale)
      }
    )
  end
end

class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder

  def translatable_text_field(method, options = {})
    translatable_field(:text_field, method, options)
  end

  def translatable_text_area(method, options = {})
    translatable_field(:text_area, method, options)
  end

  private

    def translatable_field(field_type, method, options = {})
      @template.capture do
        @object.globalize_locales.each do |locale|
          Globalize.with_locale(locale) do
            final_options = @template.merge_translatable_field_options(options, locale)
            @template.concat send(field_type, "#{method}_#{locale}", final_options)
          end
        end
      end
    end
end
{'fraction_non_alphanumeric': 0.10463733650416171, 'fraction_numerical': 0.0, 'mean_word_length': 3.8002853067047075, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7135762', 'n_tokens_mistral': 1005, 'n_tokens_neox': 1011, 'n_words': 188}