cocoapods-aqara-localzedLoader 0.0.9 → 0.0.10

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: 70f7cdf4029ec8ec4a7a1b0f49700e141507fa80073509d21835b0c82e71ff94
4
- data.tar.gz: 7d0dc878df2a7e977e0555adcb1a6b8e130f7b477c5cb984cc1d4ccc2221b8e8
3
+ metadata.gz: ca66c069a60268e820de61841a1822c4b0dd5451d3d11722737b6fd07a8ee7f7
4
+ data.tar.gz: 91b69746652c5f93f4ef4f15da3f6b9e5dc4caf5d614b599292de9c474248db8
5
5
  SHA512:
6
- metadata.gz: be02d3c670ea91b1883c6b2b4f45f2006d5abed9e867eeaa15fca706f56d997ae029e6f8d016996d2e8df57f172299fb8e0b60eb54832af6976ca52afdd57018
7
- data.tar.gz: cb182f9cbc60eb5810d6736f8e34923b0f2dcb950c6d305f5bea1474af33e15775379d2c502107811d216a15bc83305006b42bbc60bc3be5d0bd3c71143038b6
6
+ metadata.gz: 10e9b060a91aed917cbfc26d792d6848b447973c2589183a3f02c47eefa2ee8a559a949a1233e96b18856ebfcf211939772a28b4a9840b34736922323c6548c0
7
+ data.tar.gz: fdf67d56ffd37644df469557c9da0452ce446f7c9058aeea23b41de231d0d057ce2ab48b087a7b243c55e2d9d3acd41ae1c78e5ddeb91c58026fafd10e37e19b
data/Gemfile CHANGED
@@ -16,4 +16,5 @@ group :development do
16
16
  gem 'httparty'
17
17
  gem 'rubyXL'
18
18
  gem 'open3'
19
+ gem 'ruby-lsp'
19
20
  end
data/Gemfile.lock CHANGED
@@ -13,26 +13,38 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- CFPropertyList (3.0.5)
16
+ CFPropertyList (3.0.7)
17
+ base64
18
+ nkf
17
19
  rexml
18
- activesupport (6.1.7)
20
+ activesupport (7.1.5.1)
21
+ base64
22
+ benchmark (>= 0.3)
23
+ bigdecimal
19
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ connection_pool (>= 2.2.5)
26
+ drb
20
27
  i18n (>= 1.6, < 2)
28
+ logger (>= 1.4.2)
21
29
  minitest (>= 5.1)
30
+ mutex_m
31
+ securerandom (>= 0.3)
22
32
  tzinfo (~> 2.0)
23
- zeitwerk (~> 2.3)
24
- addressable (2.8.1)
25
- public_suffix (>= 2.0.2, < 6.0)
33
+ addressable (2.8.7)
34
+ public_suffix (>= 2.0.2, < 7.0)
26
35
  algoliasearch (1.27.5)
27
36
  httpclient (~> 2.8, >= 2.8.3)
28
37
  json (>= 1.5.1)
29
38
  atomos (0.1.3)
30
39
  bacon (1.2.0)
40
+ base64 (0.3.0)
41
+ benchmark (0.4.1)
42
+ bigdecimal (3.2.2)
31
43
  claide (1.1.0)
32
- cocoapods (1.15.2)
44
+ cocoapods (1.16.2)
33
45
  addressable (~> 2.8)
34
46
  claide (>= 1.0.2, < 2.0)
35
- cocoapods-core (= 1.15.2)
47
+ cocoapods-core (= 1.16.2)
36
48
  cocoapods-deintegrate (>= 1.0.3, < 2.0)
37
49
  cocoapods-downloader (>= 2.1, < 3.0)
38
50
  cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -46,8 +58,8 @@ GEM
46
58
  molinillo (~> 0.8.0)
47
59
  nap (~> 1.0)
48
60
  ruby-macho (>= 2.3.0, < 3.0)
49
- xcodeproj (>= 1.23.0, < 2.0)
50
- cocoapods-core (1.15.2)
61
+ xcodeproj (>= 1.27.0, < 2.0)
62
+ cocoapods-core (1.16.2)
51
63
  activesupport (>= 5.0, < 8)
52
64
  addressable (~> 2.8)
53
65
  algoliasearch (~> 1.0)
@@ -67,94 +79,111 @@ GEM
67
79
  netrc (~> 0.11)
68
80
  cocoapods-try (1.2.0)
69
81
  colored2 (3.1.2)
70
- concurrent-ruby (1.3.3)
82
+ concurrent-ruby (1.3.5)
83
+ connection_pool (2.5.3)
71
84
  coveralls (0.8.23)
72
85
  json (>= 1.8, < 3)
73
86
  simplecov (~> 0.16.1)
74
87
  term-ansicolor (~> 1.3)
75
88
  thor (>= 0.19.4, < 2.0)
76
89
  tins (~> 1.6)
77
- csv (3.3.0)
78
- diff-lcs (1.5.0)
79
- docile (1.4.0)
90
+ csv (3.3.5)
91
+ diff-lcs (1.6.2)
92
+ docile (1.4.1)
93
+ drb (2.2.3)
80
94
  escape (0.0.4)
81
95
  ethon (0.16.0)
82
96
  ffi (>= 1.15.0)
83
- ffi (1.15.5)
84
- fileutils (1.7.2)
97
+ ffi (1.17.2-arm64-darwin)
98
+ fileutils (1.7.3)
85
99
  fourflusher (2.3.1)
86
100
  fuzzy_match (2.0.4)
87
101
  gh_inspector (1.1.3)
88
- httparty (0.22.0)
102
+ httparty (0.23.1)
89
103
  csv
90
104
  mini_mime (>= 1.0.0)
91
105
  multi_xml (>= 0.5.2)
92
- httpclient (2.8.3)
93
- i18n (1.12.0)
106
+ httpclient (2.9.0)
107
+ mutex_m
108
+ i18n (1.14.7)
94
109
  concurrent-ruby (~> 1.0)
95
- json (2.6.2)
110
+ json (2.12.2)
111
+ language_server-protocol (3.17.0.5)
112
+ logger (1.7.0)
96
113
  mini_mime (1.1.5)
97
- minitest (5.16.3)
98
- mocha (2.0.2)
114
+ minitest (5.25.5)
115
+ mocha (2.7.1)
99
116
  ruby2_keywords (>= 0.0.5)
100
117
  mocha-on-bacon (0.2.3)
101
118
  mocha (>= 0.13.0)
102
119
  molinillo (0.8.0)
103
120
  multi_xml (0.6.0)
104
- nanaimo (0.3.0)
121
+ mutex_m (0.3.0)
122
+ nanaimo (0.4.0)
105
123
  nap (1.1.0)
106
124
  netrc (0.11.0)
107
- nokogiri (1.14.0-arm64-darwin)
125
+ nkf (0.2.0)
126
+ nokogiri (1.17.2-arm64-darwin)
108
127
  racc (~> 1.4)
109
- open3 (0.1.0)
128
+ open3 (0.2.1)
110
129
  prettybacon (0.0.2)
111
130
  bacon (~> 1.2)
131
+ prism (1.4.0)
112
132
  public_suffix (4.0.7)
113
- racc (1.6.2)
114
- rake (13.0.6)
115
- rexml (3.2.5)
116
- rspec (3.12.0)
117
- rspec-core (~> 3.12.0)
118
- rspec-expectations (~> 3.12.0)
119
- rspec-mocks (~> 3.12.0)
120
- rspec-core (3.12.0)
121
- rspec-support (~> 3.12.0)
122
- rspec-expectations (3.12.0)
133
+ racc (1.8.1)
134
+ rake (13.3.0)
135
+ rbs (3.6.1)
136
+ logger
137
+ rexml (3.4.1)
138
+ rspec (3.13.1)
139
+ rspec-core (~> 3.13.0)
140
+ rspec-expectations (~> 3.13.0)
141
+ rspec-mocks (~> 3.13.0)
142
+ rspec-core (3.13.4)
143
+ rspec-support (~> 3.13.0)
144
+ rspec-expectations (3.13.5)
123
145
  diff-lcs (>= 1.2.0, < 2.0)
124
- rspec-support (~> 3.12.0)
125
- rspec-mocks (3.12.0)
146
+ rspec-support (~> 3.13.0)
147
+ rspec-mocks (3.13.5)
126
148
  diff-lcs (>= 1.2.0, < 2.0)
127
- rspec-support (~> 3.12.0)
128
- rspec-support (3.12.0)
149
+ rspec-support (~> 3.13.0)
150
+ rspec-support (3.13.4)
151
+ ruby-lsp (0.24.1)
152
+ language_server-protocol (~> 3.17.0)
153
+ prism (>= 1.2, < 2.0)
154
+ rbs (>= 3, < 5)
155
+ sorbet-runtime (>= 0.5.10782)
129
156
  ruby-macho (2.5.1)
130
157
  ruby2_keywords (0.0.5)
131
- rubyXL (3.4.12)
132
- nokogiri (>= 1.4.4)
158
+ rubyXL (3.4.33)
159
+ nokogiri (>= 1.10.8)
133
160
  rubyzip (>= 1.3.0)
134
- rubyzip (2.3.2)
161
+ rubyzip (2.4.1)
162
+ securerandom (0.3.2)
135
163
  simplecov (0.16.1)
136
164
  docile (~> 1.1)
137
165
  json (>= 1.8, < 3)
138
166
  simplecov-html (~> 0.10.0)
139
167
  simplecov-html (0.10.2)
168
+ sorbet-runtime (0.5.12167)
140
169
  sync (0.5.0)
141
- term-ansicolor (1.7.1)
170
+ term-ansicolor (1.11.2)
142
171
  tins (~> 1.0)
143
- thor (1.2.1)
144
- tins (1.31.1)
172
+ thor (1.3.2)
173
+ tins (1.38.0)
174
+ bigdecimal
145
175
  sync
146
- typhoeus (1.4.0)
176
+ typhoeus (1.4.1)
147
177
  ethon (>= 0.9.0)
148
- tzinfo (2.0.5)
178
+ tzinfo (2.0.6)
149
179
  concurrent-ruby (~> 1.0)
150
- xcodeproj (1.24.0)
180
+ xcodeproj (1.27.0)
151
181
  CFPropertyList (>= 2.3.3, < 4.0)
152
182
  atomos (~> 0.1.3)
153
183
  claide (>= 1.0.2, < 2.0)
154
184
  colored2 (~> 3.1)
155
- nanaimo (~> 0.3.0)
156
- rexml (~> 3.2.4)
157
- zeitwerk (2.6.6)
185
+ nanaimo (~> 0.4.0)
186
+ rexml (>= 3.3.6, < 4.0)
158
187
 
159
188
  PLATFORMS
160
189
  arm64-darwin-21
@@ -174,6 +203,7 @@ DEPENDENCIES
174
203
  prettybacon
175
204
  rake (>= 10.0)
176
205
  rspec (>= 3.0)
206
+ ruby-lsp
177
207
  rubyXL
178
208
  rubyzip
179
209
 
@@ -1,5 +1,6 @@
1
1
  import shutil
2
2
  import os, sys, stat
3
+ import time
3
4
  import requests
4
5
  # import zipfile
5
6
 
@@ -40,7 +41,22 @@ timestamp: 1690280776221
40
41
  user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36
41
42
  '''
42
43
 
44
+ def get_ak_sk():
45
+ """从环境变量读取 AK/SK,未配置时回退到本地默认值。"""
46
+ ak_env = os.getenv("VOLC_ACCESSKEY") or os.getenv("VOLCENGINE_ACCESS_KEY")
47
+ sk_env = os.getenv("VOLC_SECRETKEY") or os.getenv("VOLCENGINE_SECRET_KEY")
43
48
 
49
+ # 兼容现有脚本中写死的 AK/SK(建议在外部通过环境变量配置)
50
+ default_ak = 'AKLTMjQ5NzU0YWY0ODU1NGVjOGIwMmVlYzk3ZGVhMjgzZmM'
51
+ default_sk = 'TkRZeE9UazRNVEl4TW1JNU5HSTRZV0U0TUdRNU1HTmxNMk5pWVRJMU1EYw=='
52
+
53
+ ak = ak_env or default_ak
54
+ sk = sk_env or default_sk
55
+
56
+ if not ak or not sk:
57
+ raise RuntimeError("未找到火山引擎 AK/SK,请配置 VOLC_ACCESSKEY / VOLC_SECRETKEY 环境变量")
58
+
59
+ return ak, sk
44
60
 
45
61
  def MakeHeader(headerText):
46
62
  s = headerText.strip().split('\n')
@@ -49,37 +65,77 @@ def MakeHeader(headerText):
49
65
 
50
66
  def DownLatestLocalizableSource(downloadPath):
51
67
  print("开始发送下载请求...")
68
+
69
+ # 确保下载目录存在
70
+ if not os.path.isdir(downloadPath):
71
+ os.makedirs(downloadPath, exist_ok=True)
72
+
73
+ # 加载 AK/SK
74
+ ak123, sk = get_ak_sk()
75
+
52
76
  iam_service = IamService()
53
- ak123 = 'AKLTMjQ5NzU0YWY0ODU1NGVjOGIwMmVlYzk3ZGVhMjgzZmM'
54
- sk = 'TkRZeE9UazRNVEl4TW1JNU5HSTRZV0U0TUdRNU1HTmxNMk5pWVRJMU1EYw=='
55
77
  iam_service.set_ak(ak123)
56
78
  iam_service.set_sk(sk)
57
79
 
58
- api_info = ApiInfo("GET", "/", {"serviceName": "i18n_openapi", "Action": "ProjectNamespaceTextDownload",
59
- "Version": "2021-05-21"}, {}, {})
60
- service_info = ServiceInfo("iam.volcengineapi.com", {'Accept': 'application/json'},
61
- Credentials(ak123,sk, 'i18n_openapi', 'cn-north-1'),20,20)
80
+ # 使用 OpenAPI 网关域名,结合 serviceName = i18n_openapi
81
+ # 参考 Node SDK 的 OpenAPI 用法,统一走 open.volcengineapi.com
82
+ connection_timeout = 10 # 建连超时
83
+ socket_timeout = 300 # 读取超时(导出大项目时可能比较慢)
84
+
85
+ service_info = ServiceInfo(
86
+ "open.volcengineapi.com",
87
+ {'Accept': 'application/json'},
88
+ Credentials(ak123, sk, 'i18n_openapi', 'cn-north-1'),
89
+ connection_timeout,
90
+ socket_timeout
91
+ )
62
92
  iam_service.service_info = service_info
63
93
 
64
- params = {'async': 0, 'projectId': 5788, 'namespaceId': 42835, 'format': 'xlsx'}
65
-
94
+ # OpenAPI Action / Version / serviceName 与文档保持一致
95
+ api_info = ApiInfo(
96
+ "GET",
97
+ "/",
98
+ {"serviceName": "i18n_openapi", "Action": "ProjectNamespaceTextDownload", "Version": "2021-05-21"},
99
+ {},
100
+ {}
101
+ )
102
+
103
+ params = {
104
+ 'async': 0, # 同步导出;如仍然超时,可改为 1 走异步任务
105
+ 'projectId': 5788,
106
+ 'namespaceId': 42835,
107
+ 'format': 'xlsx',
108
+ }
109
+
110
+ # 生成并签名请求
66
111
  r = iam_service.prepare_request(api_info, params, 0)
67
112
  SignerV4.sign(r, service_info.credentials)
68
113
  url = r.build(0)
69
- # print(r.headers)
70
- # res = iam_service.projectNamespaceTextDownload(params)
71
-
72
- resp = iam_service.session.get(url, headers=r.headers,
73
- timeout=(service_info.connection_timeout,service_info.socket_timeout))
74
- if resp.status_code == 200:
75
- print('下载exccel成功')
76
- with open(downloadPath+"/download.xlsx", "wb") as code:
77
- # 将 response 保存成本地文件
78
- code.write(resp.content)
79
- code.close()
80
- else:
81
- print(resp.text)
82
- raise Exception(resp.text)
114
+
115
+ # 使用流式下载 + 调大的超时,避免大文件导出导致总是超时
116
+ resp = iam_service.session.get(
117
+ url,
118
+ headers=r.headers,
119
+ timeout=(service_info.connection_timeout, service_info.socket_timeout),
120
+ stream=True,
121
+ )
122
+
123
+ if resp.status_code != 200:
124
+ # 打印部分响应文本,方便排查权限 / 参数问题
125
+ print('下载失败,HTTP 状态码:', resp.status_code)
126
+ try:
127
+ print('响应内容预览:', resp.text[:1000])
128
+ except Exception:
129
+ pass
130
+ raise Exception(f"下载失败,状态码 {resp.status_code}")
131
+
132
+ out_file = os.path.join(downloadPath, "download.xlsx")
133
+ with open(out_file, "wb") as code:
134
+ for chunk in resp.iter_content(chunk_size=1024 * 128):
135
+ if chunk:
136
+ code.write(chunk)
137
+
138
+ print('下载 excel 成功:', out_file)
83
139
 
84
140
 
85
141
 
@@ -9,7 +9,7 @@ class File_util
9
9
 
10
10
  attr_accessor :keys_hash
11
11
  #读取excel 返回StringElement数组
12
- def read_excel(filename)
12
+ def read_excel(filename, crowdin = false)
13
13
  unless filename != nil
14
14
  puts "读取的excel为空"
15
15
  return
@@ -17,6 +17,20 @@ class File_util
17
17
 
18
18
  workbook = RubyXL::Parser.parse filename
19
19
  worksheet = workbook[0]
20
+
21
+ if crowdin
22
+ last_col_index = worksheet[0].cells.size # 当前最后一列索引+1
23
+
24
+ # 遍历 B 列(索引 1)所有行
25
+ worksheet.each_with_index do |row, row_index|
26
+ b_value = row && row[1] ? row[1].value : nil
27
+ worksheet.add_cell(row_index, last_col_index, b_value)
28
+ end
29
+
30
+ worksheet[0].cells[last_col_index] = worksheet.add_cell(0, last_col_index, 'zh-CN')
31
+ workbook.write(filename)
32
+ end
33
+
20
34
  row1 = worksheet[0]
21
35
  @key_hash = getkeyHash(row1)
22
36
  lang_hash = {}
@@ -1,3 +1,3 @@
1
1
  module Localzedloader
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -51,7 +51,7 @@ class BundleGenerater
51
51
 
52
52
  @@download_Count = 1
53
53
 
54
- def self.downloadxls(project_path)
54
+ def self.downloadxls(project_path, crowdin=false)
55
55
  if @@download_Count > 10
56
56
  puts "当前无网络,程序即将退出。"
57
57
  exit(1)
@@ -63,7 +63,11 @@ class BundleGenerater
63
63
  sleep sleep_time
64
64
  end
65
65
  puts "当前进行第#{@@download_Count}次尝试下载多语言文件"
66
- system "cd #{File.dirname(__FILE__)};python3 DownloadNewLanguage.py #{project_path}"
66
+ if crowdin
67
+ system "crowdin download sources"
68
+ else
69
+ system "cd #{File.dirname(__FILE__)};python3 DownloadNewLanguage.py #{project_path}"
70
+ end
67
71
  @@download_Count = @@download_Count + 1
68
72
  end
69
73
 
@@ -71,18 +75,28 @@ class BundleGenerater
71
75
  # 下载excel
72
76
  puts "开始下载多语言文件...".green
73
77
 
78
+ crowdin = true if File.exist? "#{project_path}/crowdin.yml"
74
79
 
75
80
  f_path = "#{project_path}/download.xlsx"
76
- printf(f_path)
81
+ if crowdin
82
+ f_path = "#{project_path}/APP/Aqara_Home_App.xlsx"
83
+ end
84
+
85
+ puts f_path
77
86
 
78
87
  until File.exist?(f_path)
79
- self.downloadxls(project_path)
88
+ self.downloadxls(project_path, crowdin)
80
89
  end
81
90
  # 读取excel到内存
82
91
  file_til = File_util.new
83
- hash = file_til.read_excel f_path
92
+ hash = file_til.read_excel(f_path, crowdin)
84
93
  if File.exist? f_path
85
- FileUtils.rm_rf f_path
94
+ if crowdin
95
+ parent_dir = File.dirname(f_path)
96
+ FileUtils.rm_rf(parent_dir)
97
+ else
98
+ FileUtils.rm_rf f_path
99
+ end
86
100
  end
87
101
  puts "一共有 #{hash.keys.size} 条文案".green
88
102
 
@@ -209,7 +223,7 @@ class BundleGenerater
209
223
  FileUtils.mkdir_p dest
210
224
  FileUtils.mv("#{info_plist_file}",dest,force:true)
211
225
  end
212
- FileUtils.rm_rf (File.dirname(path))
226
+ # FileUtils.rm_rf (File.dirname(path))
213
227
  end
214
228
  puts "多语言拷贝到目录:#{bundPath}"
215
229
  if copy_info_plist
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-28 00:00:00.000000000 Z
11
+ date: 2025-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  - !ruby/object:Gem::Version
218
218
  version: '0'
219
219
  requirements: []
220
- rubygems_version: 3.3.26
220
+ rubygems_version: 3.2.22
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: Aqara 多语言从云端多语言平台下载并处理解析成Xcode需要的多语言文件