lhj-tools 0.2.68 → 0.2.69

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: bd2067cef96b6de5accdb2a0944a424879ec9c700c853be313389db776c54c8f
4
+ data.tar.gz: 28b3a6b6a1589d2ed1f06bcdb2ec4380ff95cd175fa11b876aa0b7e75f4b3a49
5
5
  SHA512:
6
- metadata.gz: c7cb08beec96cd9b1ab1c92c55c99aa364531ccae929a87a0dacff18d35e10b08af4616de77034641728ab208452e2253d71fe301f50fc8eda76c1d56035c9a4
7
- data.tar.gz: 6bbbe3a17f63e7b8431a15d9e6e2e2345ab3993e41080aa8c03c7c024708133ae733336cce2a69ef51c9f4d8c64121aac091e2400b13504602b55518ab5ccfe4
6
+ metadata.gz: 76a2fbc806f1a656859ebb6cc332736419d411ce06d94a8911dd24072177c919642f330be073b84651512f2c89f0e8b370280ceee0eccf836639b783f7d5a837
7
+ data.tar.gz: b6d2754b914fdc39f1458c0c8a47c08548d0e8b7732ba05ec9ebb16f9987953560c7ae4682ddc089a50685af17788cebbcd3a5972c5144cb723b35656288e3b3
@@ -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'
@@ -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
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.69'
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.69
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: 2023-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj