<commit_before>namespace :gettext do
  def load_gettext
    require 'gettext'
    require 'gettext/utils'
  end

  desc "Create mo-files for L10n"
  task :pack => :environment do
    load_gettext
    GetText.create_mofiles(true, locale_path, locale_path)
  end

  desc "Update pot/po files."
  task :find => :environment do
    load_gettext
    $LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib')
    require 'gettext_i18n_rails/haml_parser'


    if GetText.respond_to? :update_pofiles_org
      GetText.update_pofiles_org(
        text_domain,
        files_to_translate,
        "version 0.0.1",
        :po_root => locale_path,
        :msgmerge=> Rails.application.config.gettext_i18n_rails.msgmerge
      )
    else #we are on a version < 2.0
      puts "install new GetText with gettext:install to gain more features..."
      #kill ar parser...
      require 'gettext/parser/active_record'
      module GetText
        module ActiveRecordParser
          module_function
          def init(x);end
        end
      end

      #parse files.. (models are simply parsed as ruby files)
      GetText.update_pofiles(
        text_domain,
        files_to_translate,
        "version 0.0.1",
        locale_path
      )
    end
  end

  # This is more of an example, ignoring
  # the columns/tables that mostly do not need translation.
  # This can also be done with GetText::ActiveRecord<commit_msg>keep everything working for rails 2<commit_after>namespace :gettext do
  def load_gettext
    require 'gettext'
    require 'gettext/utils'
  end

  desc "Create mo-files for L10n"
  task :pack => :environment do
    load_gettext
    GetText.create_mofiles(true, locale_path, locale_path)
  end

  desc "Update pot/po files."
  task :find => :environment do
    load_gettext
    $LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib')
    require 'gettext_i18n_rails/haml_parser'


    if GetText.respond_to? :update_pofiles_org
      if defined?(Rails.application)
        msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge
      end
      msgmerge ||= %w[--sort-output --no-location --no-wrap]

      GetText.update_pofiles_org(
        text_domain,
        files_to_translate,
        "version 0.0.1",
        :po_root => locale_path,
        :msgmerge => msgmerge
      )
    else #we are on a version < 2.0
      puts "install new GetText with gettext:install to gain more features..."
      #kill ar parser...
      require 'gettext/parser/active_record'
      module GetText
        module ActiveRecordParser
          module_function
          def init(x);end
        end
      end

      #parse files.. (models are simply parsed as ruby files)
      GetText.update_pofiles(
        text_domain,
        files_to_translate,
        "version 0.0.1",
        locale_path
      )
    end
  end

  # This is more of an example, ignoring
  # the columns/tables that mostly do not need translation.
  # This can also be done with GetText::ActiveRecord
{'fraction_non_alphanumeric': 0.08768406961178045, 'fraction_numerical': 0.009705488621151271, 'mean_word_length': 2.495906432748538, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '1662241', 'n_tokens_mistral': 953, 'n_tokens_neox': 920, 'n_words': 251}