cocoapods-aqara-localzedLoader 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1c8b35a21944c2257f6cda58ccde6d3e70c1c7a8cb59fb296f57da48624985f
4
- data.tar.gz: bc46aaae6ccc4d1d9690879a5749ee0f78c070d10452411c81268c6303cb5894
3
+ metadata.gz: 70f7cdf4029ec8ec4a7a1b0f49700e141507fa80073509d21835b0c82e71ff94
4
+ data.tar.gz: 7d0dc878df2a7e977e0555adcb1a6b8e130f7b477c5cb984cc1d4ccc2221b8e8
5
5
  SHA512:
6
- metadata.gz: a472db5098379de9440faf436dd9157620fa07d920c77beab9762daab3f9f5897b1c93b0d784ce7d9a1435077273b5ea3dc5d41fdd6e3dbf259435eb5bbfa70b
7
- data.tar.gz: f4a581688db6c60c35766ddb01c1cb6c577331e194531083d974d13ccb726a336b47c570659b2ec39de7577bad2eea7f8e783cd106fbedf39a8f1989af9b71ea
6
+ metadata.gz: be02d3c670ea91b1883c6b2b4f45f2006d5abed9e867eeaa15fca706f56d997ae029e6f8d016996d2e8df57f172299fb8e0b60eb54832af6976ca52afdd57018
7
+ data.tar.gz: cb182f9cbc60eb5810d6736f8e34923b0f2dcb950c6d305f5bea1474af33e15775379d2c502107811d216a15bc83305006b42bbc60bc3be5d0bd3c71143038b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-aqara-localzedLoader (0.0.7)
4
+ cocoapods-aqara-localzedLoader (0.0.9)
5
5
  claide (>= 1.0.2, < 2.0)
6
6
  colored2
7
7
  fileutils
@@ -1,3 +1,3 @@
1
1
  module Localzedloader
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -7,18 +7,62 @@ require 'open3'
7
7
  class BundleGenerater
8
8
 
9
9
  # INFO_PLIST_ARRAY = [NSAppleMusicUsageDescription","NSLocalNetworkUsageDescription"]
10
- INFO_PLIST_MAP = {:common_app_name=>["CFBundleDisplayName"],other_perm_camera_permission_description:["NSCameraUsageDescription"],other_perm_location_permission_description:["NSLocationAlwaysAndWhenInUseUsageDescription","NSLocationWhenInUseUsageDescription","NSLocationAlwaysUsageDescription"],other_perm_bluetooth_permission_description:["NSBluetoothPeripheralUsageDescription","NSBluetoothAlwaysUsageDescription"],access_content_permssion_storage:["NSPhotoLibraryUsageDescription"],other_perm_mic_permission_description:["NSMicrophoneUsageDescription"],other_set_permissions_homedata_desc:["NSHomeKitUsageDescription"],other_set_permissions_asr_text:["NSSpeechRecognitionUsageDescription"],device_add_device:["Add_Device_Title"],automation_add:["Add_Automation_Title"],device_create_scene:["Add_Scene_Title"]}
10
+ INFO_PLIST_MAP = {
11
+ common_app_name: ["CFBundleDisplayName"],
12
+ other_perm_camera_permission_description: [
13
+ "NSCameraUsageDescription"
14
+ ],
15
+ other_perm_location_permission_description: [
16
+ "NSLocationAlwaysAndWhenInUseUsageDescription",
17
+ "NSLocationWhenInUseUsageDescription",
18
+ "NSLocationAlwaysUsageDescription"
19
+ ],
20
+ other_perm_bluetooth_permission_description: [
21
+ "NSBluetoothPeripheralUsageDescription",
22
+ "NSBluetoothAlwaysUsageDescription"
23
+ ],
24
+ access_content_permssion_storage: [
25
+ "NSPhotoLibraryUsageDescription"
26
+ ],
27
+ other_perm_mic_permission_description: [
28
+ "NSMicrophoneUsageDescription"
29
+ ],
30
+ other_set_permissions_homedata_desc: [
31
+ "NSHomeKitUsageDescription"
32
+ ],
33
+ other_set_permissions_asr_text: [
34
+ "NSSpeechRecognitionUsageDescription"
35
+ ],
36
+ device_add_device: [
37
+ "Add_Device_Title"
38
+ ],
39
+ automation_add: [
40
+ "Add_Automation_Title"
41
+ ],
42
+ device_create_scene: [
43
+ "Add_Scene_Title"
44
+ ],
45
+ NFCReaderUsageDescription: [
46
+ "NFCReaderUsageDescription"
47
+ ]
48
+ }
11
49
 
12
50
  #定义类变量记录下载次数
13
51
 
14
52
  @@download_Count = 1
15
53
 
16
54
  def self.downloadxls(project_path)
55
+ if @@download_Count > 10
56
+ puts "当前无网络,程序即将退出。"
57
+ exit(1)
58
+ end
17
59
  if @@download_Count > 1
18
- sleep 10
60
+ base = 2
61
+ sleep_time = base * (2 ** (@@download_Count - 2))
62
+ puts "等待#{sleep_time}秒后重试..."
63
+ sleep sleep_time
19
64
  end
20
65
  puts "当前进行第#{@@download_Count}次尝试下载多语言文件"
21
- #Open3.capture3("cd #{File.dirname(__FILE__)};python3 DownloadNewLanguage.py #{project_path}")
22
66
  system "cd #{File.dirname(__FILE__)};python3 DownloadNewLanguage.py #{project_path}"
23
67
  @@download_Count = @@download_Count + 1
24
68
  end
@@ -34,7 +78,6 @@ class BundleGenerater
34
78
  until File.exist?(f_path)
35
79
  self.downloadxls(project_path)
36
80
  end
37
-
38
81
  # 读取excel到内存
39
82
  file_til = File_util.new
40
83
  hash = file_til.read_excel f_path
@@ -55,18 +98,26 @@ class BundleGenerater
55
98
 
56
99
  end
57
100
 
101
+ errors = []
58
102
  #生成资源文件
59
103
  hash.each do |key, stringElement|
60
- num = 0
104
+ expected_count = nil
61
105
  stringElement.langHash.each do |lang, value|
62
106
  # puts "#{lang}:#{value}"
63
107
  next if lang.downcase === "selfkey" or value === nil or value === " " or value === ""
64
108
  value = self.handleValue value,stringElement
65
- value.scan(/%@/) do |match|
66
- num = match.size if num == 0
67
- if num != match.size
68
- puts "key:#{key}中%@ 数量不一致,请检查".red
69
- end
109
+ current_count = value.scan(/%@/).size
110
+
111
+ if expected_count.nil?
112
+ expected_count = current_count
113
+ elsif current_count != expected_count
114
+ errors << {
115
+ key: key,
116
+ lang: lang,
117
+ expected: expected_count,
118
+ actual: current_count
119
+ }
120
+ next
70
121
  end
71
122
  str = %Q|"#{key}" = "#{value}";\n|
72
123
  localized_file = "./#{lang}.lproj/Localizable.strings"
@@ -100,6 +151,17 @@ class BundleGenerater
100
151
  end
101
152
  end
102
153
 
154
+ #判读是否有多语言出现不同语种%@数量不匹配,出现后中断打包
155
+ if errors.any?
156
+ puts "以下 key 的 %@ 在不同语种的数量存在不一致,让产品交互速度改后再打包:\n".red
157
+ errors.each do |err|
158
+ puts "key: #{err[:key]} | 语言: #{err[:lang]} | 实际: #{err[:actual]} | 应为: #{err[:expected]}".red
159
+ end
160
+ exit(1)
161
+ else
162
+ puts "✅ 所有 key 的 %@ 在不同语种保持数量一致".green
163
+ end
164
+
103
165
  #验证导出的多语言包格式是否正确
104
166
  puts '开始校验多语言包格式'.red
105
167
  # puts "\e[31m 开始校验多语言包格式\e[0m"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-aqara-localzedLoader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-06 00:00:00.000000000 Z
11
+ date: 2025-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler