<commit_before>BABELYODA_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))

require 'awesome_print'
require 'fileutils'

require_relative 'babelyoda/genstrings'
require_relative 'babelyoda/git'
require_relative 'babelyoda/ibtool'
require_relative 'babelyoda/keyset'
require_relative 'babelyoda/localization_key'
require_relative 'babelyoda/localization_value'
require_relative 'babelyoda/logger'
require_relative 'babelyoda/rake'
require_relative 'babelyoda/specification'
require_relative 'babelyoda/tanker'
require_relative 'babelyoda/xib'

desc "Do a full localization cycle: push new strings, get translations and merge them"
task :babelyoda => ['babelyoda:push', 'babelyoda:pull'] do
end

namespace :babelyoda do
  
  file 'Babelfile' do
    Babelyoda::Specification.generate_default_babelfile
  end
  
  desc "Create a basic bootstrap Babelfile"
  task :init => 'Babelfile' do
  end
  
  Babelyoda::Rake.spec do |spec|
    
    desc "Extract strings from sources"
    task :extract_strings do
      spec.scm.transaction("[Babelyoda] Extract strings from sources") do 
        $logger.info "Extracting strings from sources..."
        dev_lang = spec.development_language
        Babelyoda::Genstrings.run(spec.source_files, dev_lang) do |keyset|
          keyset_name = File.join(spec.resources_folder, keyset.name)
          old_strings_filename = strings_filename(keyset_name, dev_lang)
          old_strings = Babelyoda::Strings.new(old_strings_filename, dev_lang).read<commit_msg>The :extract_strings tasks now honors the PRESERVE=1 environment key, if present, and doesn't drop keys not present in the source files<commit_after>BABELYODA_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))

require 'awesome_print'
require 'fileutils'

require_relative 'babelyoda/genstrings'
require_relative 'babelyoda/git'
require_relative 'babelyoda/ibtool'
require_relative 'babelyoda/keyset'
require_relative 'babelyoda/localization_key'
require_relative 'babelyoda/localization_value'
require_relative 'babelyoda/logger'
require_relative 'babelyoda/rake'
require_relative 'babelyoda/specification'
require_relative 'babelyoda/tanker'
require_relative 'babelyoda/xib'

desc "Do a full localization cycle: push new strings, get translations and merge them"
task :babelyoda => ['babelyoda:push', 'babelyoda:pull'] do
end

namespace :babelyoda do
  
  file 'Babelfile' do
    Babelyoda::Specification.generate_default_babelfile
  end
  
  desc "Create a basic bootstrap Babelfile"
  task :init => 'Babelfile' do
  end
  
  Babelyoda::Rake.spec do |spec|
    
    desc "Extract strings from sources. Use PRESERVE=1 so that orphan keys don't get dropped."
    task :extract_strings do
      spec.scm.transaction("[Babelyoda] Extract strings from sources") do 
        $logger.info "Extracting strings from sources..."
        dev_lang = spec.development_language
        Babelyoda::Genstrings.run(spec.source_files, dev_lang) do |keyset|
          keyset_name = File.join(spec.resources_folder, keyset.name)
          old_strings_filename = strings_filename(keyset_name, dev_lang)
          old_strings = Babelyoda::Strings.new(old_strings_filename, dev_lang)
          old_strings.read if ENV['PRESERVE'].to_i == 1
{'fraction_non_alphanumeric': 0.08956145768993205, 'fraction_numerical': 0.0009264978381717109, 'mean_word_length': 4.9981481481481485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4776475', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1006, 'n_words': 240}