91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# 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
|