lhj-tools 0.2.68 → 0.2.70

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c23165c469fd6d71c90bdd7084b586791467fa476c5b7900bf6a6390c75c5a77
4
- data.tar.gz: 0d2c4a52513393230ed54e001639e6bc86cc0eabcbd015ef753429785cfc5af8
3
+ metadata.gz: 69043d324a75d0736920413e53feea9866fcbcf70632b93bce05586533496a78
4
+ data.tar.gz: afbb9a634140e0995858df548b5ee8a35e57098397764893828f2fbc11fc7781
5
5
  SHA512:
6
- metadata.gz: c7cb08beec96cd9b1ab1c92c55c99aa364531ccae929a87a0dacff18d35e10b08af4616de77034641728ab208452e2253d71fe301f50fc8eda76c1d56035c9a4
7
- data.tar.gz: 6bbbe3a17f63e7b8431a15d9e6e2e2345ab3993e41080aa8c03c7c024708133ae733336cce2a69ef51c9f4d8c64121aac091e2400b13504602b55518ab5ccfe4
6
+ metadata.gz: 58c6ef833505fdc7163305bf423b72a37c15a943df6e95530fd4f5e495e46e599f99ba83ba2f9d031ec52b872817717b85842d73601060bcdd11460efb6aa404
7
+ data.tar.gz: a8e6a8dc5b49fe21309a9a6f1fbdb985b6bae46b6e9938cc2ba185886e411e0f96f71224921b642cfca0623d6afd5910ca354cb3e57490fddfff95a6dd8a6666
@@ -18,7 +18,7 @@ module Lhj
18
18
  def handle
19
19
  @file_name = @cli.ask(HighLine.color('生成csv文件名:', :green), String) do |q|
20
20
  time = Time.now.strftime('%Y%m%d_%H%M')
21
- q.default = "gen_cn_key_#{time}.csv"
21
+ q.default = "gen_ch_en_#{time}.csv"
22
22
  end
23
23
  @file_type = @cli.ask(HighLine.color('从哪些源码中查找中文字符串, 默认为m,h:', :green), String) do |q|
24
24
  q.default = 'm,h'
@@ -93,6 +93,7 @@ module Lhj
93
93
 
94
94
  next if multi_comment
95
95
  next if line =~ %r{/\*.*\*/}
96
+ next if line =~ %r{^\s*//}
96
97
  next unless zh_ch_reg =~ line
97
98
  next if line =~ /#pragma/
98
99
  next if line =~ /log|Log|LOG|NSCAssert/
@@ -20,23 +20,44 @@ module Lhj
20
20
  end
21
21
 
22
22
  def handle
23
+ setting_handle
24
+ if @key_map.keys.length.positive?
25
+ write_en_strings
26
+ write_zh_hk_strings
27
+ write_zh_cn_strings
28
+ handle_modify_source if @modify_source_flag
29
+ else
30
+ puts "获取中英文映射文件失败, 检查参数--read-csv-file=xx是否正常\n"
31
+ end
32
+ end
33
+
34
+ def setting_csv_handle
23
35
  @cli.say(HighLine.color('选择中英对应照csv文件:', :green))
24
36
  path = File.join(@current_path, '**', '*.csv')
25
- @csv_file = @cli.choose(*Dir.glob(path))
26
- puts "选择对照文档>>>>>>>>> #{@csv_file}"
27
-
28
- @gen_file_name = @cli.ask('生成.strings文件的名称: '.green, String) do |q|
29
- q.default = 'Localizable.strings'
30
- end
31
- @key_col = @cli.ask('中英对应照csv中key所在的列, 默认为0: '.yellow, Integer) do |q|
37
+ csv_file = @cli.choose(*Dir.glob(path))
38
+ puts "选择对照文档>>>>>>>>> #{csv_file}"
39
+ key_col = @cli.ask('中英对应照csv中<<key>>所在的列, 默认为0: '.yellow, Integer) do |q|
32
40
  q.default = 0
33
41
  end
34
- @cn_col = @cli.ask('中英对应照csv<<中文>>所在的列, 默认为1: '.yellow, Integer) do |q|
42
+ cn_col = @cli.ask('中英对应照csv<<中文>>所在的列, 默认为1: '.yellow, Integer) do |q|
35
43
  q.default = 1
36
44
  end
37
- @en_col = @cli.ask('中英对应照csv<<英文>>所在的列, 默认为2: '.yellow, Integer) do |q|
45
+ en_col = @cli.ask('中英对应照csv<<英文>>所在的列, 默认为2: '.yellow, Integer) do |q|
38
46
  q.default = 2
39
47
  end
48
+ read_csv_file(csv_file, key_col, cn_col, en_col)
49
+ need_add_other = @cli.ask('是否继续添加csv文件yes?: '.yellow, ->(yn) { yn.downcase[0] == 'y' }) do |q|
50
+ q.default = false
51
+ end
52
+ setting_csv_handle if need_add_other
53
+ end
54
+
55
+ def setting_handle
56
+ setting_csv_handle
57
+ @gen_file_name = @cli.ask('生成.strings文件的名称: '.green, String) do |q|
58
+ time = Time.now.strftime('%Y%m%d_%H%M')
59
+ q.default = "Localizable_#{time}.strings"
60
+ end
40
61
  @en_dir_name = @cli.ask('生成英文.strings文件对应路径: '.yellow, String) do |q|
41
62
  q.default = 'MacauLife/en.lproj'
42
63
  end
@@ -55,16 +76,6 @@ module Lhj
55
76
  q.default = 'MLLocalizedString(%s)'
56
77
  end
57
78
  end
58
-
59
- read_csv
60
- if @key_map.keys.length.positive?
61
- write_en_strings
62
- write_zh_hk_strings
63
- write_zh_cn_strings
64
- handle_modify_source if @modify_source_flag
65
- else
66
- puts "获取中英文映射文件失败, 检查参数--read-csv-file=xx是否正常\n"
67
- end
68
79
  end
69
80
 
70
81
  def generate_file_name
@@ -76,14 +87,7 @@ module Lhj
76
87
  File.exist?(dest_file) ? bak_file(dest_file) : dest_file
77
88
  end
78
89
 
79
- def read_csv
80
- read_csv_file @csv_file
81
- end
82
-
83
- def read_csv_file(file)
84
- key_c = @key_col
85
- cn_c = @cn_col
86
- en_c = @en_col
90
+ def read_csv_file(file, key_c, cn_c, en_c)
87
91
  # trans_hk = false
88
92
  # trans_cn = true
89
93
  CSV.foreach(file) do |row|
@@ -92,7 +96,7 @@ module Lhj
92
96
  cn_str = row[cn_c]
93
97
  hk_str = row[cn_c]
94
98
  # cn_str = Lhj::Trans::Helper.instance.trans_zh_cn_str(cn_str) if trans_cn
95
- # hk_str = Lhj::Trans::Helper.instance.trans_zh_hk_str(hk_str) if trans_hk
99
+ hk_str = Lhj::Trans::Helper.instance.trans_zh_hk_str(hk_str)
96
100
  @key_map[key] = { key: key, cn: cn_str, hk: hk_str, en: row[en_c] } unless key =~ /[\u4e00-\u9fa5]/
97
101
  end
98
102
  end
@@ -140,6 +144,10 @@ module Lhj
140
144
  str += line
141
145
  next
142
146
  end
147
+ if line =~ %r{^\s*//}
148
+ str += line
149
+ next
150
+ end
143
151
  unless zh_ch_reg =~ line
144
152
  str += line
145
153
  next
@@ -157,7 +165,9 @@ module Lhj
157
165
  next
158
166
  end
159
167
 
160
- str += handle_modify_line(f, line)
168
+ modify_line = handle_modify_line(f, line)
169
+ str += "//#{line}" unless line.eql?(modify_line)
170
+ str += modify_line
161
171
  end
162
172
  end
163
173
  str
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.68'
4
+ VERSION = '0.2.70'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.68
4
+ version: 0.2.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-28 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj