8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/ios_bundle_generate.rb', line 8
def self.generate
f_path = LanguageDownloader.download
file_til = File_util.new
hash = file_til.read_excel f_path
if File.exist? f_path
FileUtils.rm_rf f_path
end
puts "一共有 #{hash.keys.size} 条文案".green
file_til.getLangList.each do |lang|
localized_file = "./#{lang}.lproj/Localizable.strings"
dir = File.dirname localized_file
FileUtils.rm_rf localized_file
FileUtils.mkdir_p dir
end
hash.each do |key, stringElement|
stringElement.langHash.each do |lang, value|
next if lang.downcase === "selfkey" or value === nil or value === " " or value === ""
value = self.handleValue value,stringElement
localized_file = "./#{lang}.lproj/Localizable.strings"
str = %Q|"#{key}" = "#{value}";\n|
File.open(localized_file, "a") do |io|
io.write str
end
end
end
puts '开始校验多语言包格式'.red
file_til.getLangList.each do |lang|
localized_file = "./#{lang}.lproj/Localizable.strings"
system("plutil #{localized_file}")
end
bundPath = ""
require 'find'
Find.find("./") do |filePath|
if filePath.end_with?("LMFramework.bundle")
bundPath = filePath
break
end
end
unless bundPath != ""
puts '没有拷贝'
return
end
file_til.getLangList.each do |lang|
path = "#{lang}.lproj/Localizable.strings"
dest = bundPath + "/#{lang}.lproj"
FileUtils.mkdir_p dest
FileUtils.mv("./#{path}",dest,force:true)
FileUtils.rm_rf File.dirname("./#{path}")
end
puts "多语言拷贝到目录:#{bundPath}"
end
|