module LocalizeStringFilter

Constants

VERSION

Public Class Methods

run() click to toggle source
# File lib/localize_string_filter.rb, line 91
def self.run()

        puts "input project path: "
        project_path = gets.chomp.strip
        if project_path.empty?
                puts "error: invalid project_path"
                return
        end

        puts "input .strings file path: "
        strings_path = gets.chomp.strip
        if strings_path.empty?
                puts "error: invalid strings_path"
                return
        end

        puts "running..."
  if File.directory?(project_path)
       swift_files = Array.new
    traverse_swift_files(project_path, swift_files)
    localized_keys = collect_keys(strings_path)
    missing_keys = collect_missing_keys(localized_keys, swift_files)
    output_missing_keys(missing_keys, project_path)

                puts "remove all missing keys directly from .strings file? Y/(N)"
                need_delete_missing_keys = gets.chomp
                if need_delete_missing_keys.empty? || need_delete_missing_keys == "Y"
                        puts "deleting..."
                        delete_missing_keys(missing_keys, strings_path)
                else
                        puts "check missing_keys.txt file in project path, and remove keys manually"
                end
                puts "done."

  else
    puts "error: project_path is not a directory"
  end
end