cocoapods-localzedLoader 0.1.3 → 0.1.4

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: 35da642dbe713c4432282321be4a088ccc8e2506b6be79cb8379565ceb0096cf
4
- data.tar.gz: 42d8236a2c31a5a99a2dd8d9dea3a8cbb4b4dcd8c8ebbe531c3b92c67e2a3a63
3
+ metadata.gz: 38a0241050c77fad4ec3a6bba1bbea3982956ec4ce3d9dc66d9a31f5e1cb2788
4
+ data.tar.gz: a7e89c0bdaef7f80dd9ceb7614de36eecf0576fa6958d03f649e2d06590b3fb1
5
5
  SHA512:
6
- metadata.gz: adbcd572073abab951f26d0771c6b132056ed963f47d9b75637d056eb35abb251eb214c43f83361e9ab2479aa40ea64a39b9d295dfee4021090118964b3b4435
7
- data.tar.gz: cb66b6149919c1d74bc41f169340d26a5d26a10b9d765b74be0fe4a8a21fe5e9664e32ce8f2bd40221fb3af08f4be63f8ee9475449d5603446187f40f8bb663f
6
+ metadata.gz: 5b0fd8d9bc1dec67f5c540dee7ecb7e984d3d5f32d7a106d2ebd3efdc295737cab97c16d5bcf7ec45a84b58c9e686c896b1d5135ee633584d555645804bcd319
7
+ data.tar.gz: 8e840f0bb13fb5eee5bb1e1f5ee6646a9f28346c0a2dc08fa39d0508a8d974abf769ce5bae90fac04f96a759c289e37899775e8df5b5af8ba330758af89d4078
@@ -0,0 +1,102 @@
1
+ import os
2
+ import shutil
3
+
4
+ import requests
5
+ # import zipfile
6
+
7
+ # from __future__ import print_function
8
+
9
+ from volcengine.iam.IamService import IamService
10
+
11
+ from volcengine.ApiInfo import ApiInfo
12
+ from volcengine.Credentials import Credentials
13
+ from volcengine.base.Service import Service
14
+ from volcengine.ServiceInfo import ServiceInfo
15
+
16
+ from volcengine.auth.SignerV4 import SignerV4
17
+
18
+
19
+ # 浏览器登录后抓取的 cookie
20
+ myheader = '''
21
+ accept: application/json, text/plain, */*
22
+ accept-encoding: gzip, deflate, br
23
+ accept-language: zh
24
+ content-length: 155
25
+ content-type: application/json
26
+ cookie:experimentation_subject_id=IjZmOTJkNTAwLWRhNGQtNDllOS04NWJmLTViMDA3YWQyNzNmNSI%3D--ea0d856d9ab513dbab485429b3eb34d28baf575c; _ga_WF6G97Z3ZH=GS1.1.1655109583.7.0.1655109635.0; Hm_lvt_2df419cadb3951597d5f6df3a9e563d1=1677809958; __gads=ID=7b3f01c117b67f05-227ecfaf8fe20014:T=1688561915:RT=1695382086:S=ALNI_MZWfx6X7kl8bcHGz9c7kVOi5EJ97g; __gpi=UID=00000c96aea158eb:T=1688561915:RT=1695382086:S=ALNI_MaQoB1d1fZVX_-TNOZ9-FBy0AmJeQ; _ga_3EMB6JL0XV=GS1.1.1695897491.159.0.1695897491.60.0.0; _ga=GA1.1.726824286.1621481586; _ga_1MSMD2CRQ5=GS1.1.1695897492.25.0.1695897492.0.0.0; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%222698037175171e6d.824697002942386177%22%2C%22first_id%22%3A%2217954f52ff723e-046b05611aed99-113a6054-1296000-17954f52ff9e4c%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fuc.aqara.cn%2F%22%7D%2C%22%24device_id%22%3A%2217954f52ff723e-046b05611aed99-113a6054-1296000-17954f52ff9e4c%22%7D; Token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI4MzcyOTA5NzQ3NmUwMmYyLjY0MjA2ODExMTgyMzk1MzkyMSIsImlzcyI6Imh0dHBzOi8vYWlvdC1ycGMuYXFhcmEuY24iLCJhY2NvdW50Ijoid2FuaHVhLnlhbkBhcWFyYS5jb20iLCJpYXRHbXQ4IjoxNjk2NjQ2MDYyLCJqdGkiOiI4ZjJlNDJiNTk1MTE0ODFmOTBiMDI3NWExZmE2OWNkZDlkMjVhZDY5NGUzMDQ4MGZhNDM3ZDM2NGI5YTFjZTIzIn0.FqpQfHNi--7FxAu4ytiGpQBwUdMVGDgdKaqZI4hLAus; Userid=83729097476e02f2.642068111823953921; currentSid=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI4MzcyOTA5NzQ3NmUwMmYyLjY0MjA2ODExMTgyMzk1MzkyMSIsImlzcyI6Imh0dHBzOi8vYWlvdC1ycGMuYXFhcmEuY24iLCJpYXRHbXQ4IjoxNjk2NjQ2MDYyLCJqdGkiOiJhNDZlZjExOGE3YTk0ZTIwYTBkNmE5YTE5YjRiM2UxYjM0ZmMxNjYzZTUzYjQ1NzI4Zjk5YzhiYzRhZGUzMGE4In0.W_fWYx-B0kvj2uAUz0pw8vOhw5VKJ4SM5oCwpY_YZkk; currentAccount=wanhua.yan@aqara.com; userInfo=%7B%22accountCategory%22%3A%220%22%2C%22company%22%3A%7B%22companyId%22%3A1%2C%22companyName%22%3A%22%E7%BB%BF%E7%B1%B3%E8%81%94%E5%88%9B%22%7D%2C%22user%22%3A%7B%22avatarUrl%22%3A%22%22%2C%22companyId%22%3A1%2C%22email%22%3A%22wanhua.yan%40aqara.com%22%2C%22nickName%22%3A%22%22%2C%22userType%22%3A0%7D%7D; sidebarStatus=0
27
+ lang: zh
28
+ nonce: z7isblgw7hzfrlebmu7fzoukr20vpvs8
29
+ operate-platform: 40
30
+ origin: https://intl-lang.aqara.com
31
+ projectid: 5
32
+ referer: https://intl-lang.aqara.com/
33
+ sec-ch-ua: "Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"
34
+ sec-ch-ua-mobile: ?1
35
+ sec-ch-ua-platform: "Android"
36
+ sec-fetch-dest: empty
37
+ sec-fetch-mode: cors
38
+ sec-fetch-site: same-origin
39
+ time: 1690280776221
40
+ timestamp: 1690280776221
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
42
+ '''
43
+
44
+
45
+
46
+ def MakeHeader(headerText):
47
+ s = headerText.strip().split('\n')
48
+ s = {x.split(':', 1)[0].strip() :x.split(':', 1)[1].strip() for x in s}
49
+ return s
50
+
51
+ def DownLatestLocalizableSource():
52
+ iam_service = IamService()
53
+ ak = 'AKLTZTFjNzFjYTczMzJjNGQyMjg0NTRkZjQ2ZTA4MTE1Mjc'
54
+ sk = 'TkdRMU9HSTJZemt6Tmpkak5ERXhaVGt5WXpVNU5qSmxPVFkzWWpBM1pqRQ=='
55
+ iam_service.set_ak(ak)
56
+ iam_service.set_sk(sk)
57
+
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(ak,sk, 'i18n_openapi', 'cn-north-1'),20,20)
62
+ iam_service.service_info = service_info
63
+
64
+ params = {'async': 0, 'projectId': 5788, 'namespaceId': 42835, 'format': 'xlsx'}
65
+
66
+ r = iam_service.prepare_request(api_info, params, 0)
67
+ SignerV4.sign(r, service_info.credentials)
68
+ 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('成功l----')
76
+ with open("download" + ".xlsx", "wb") as code:
77
+ # 将 response 保存成本地文件
78
+ code.write(resp.content)
79
+ code.close()
80
+ else:
81
+ raise Exception(resp.text)
82
+
83
+
84
+
85
+ # def Unzip():
86
+ # f = zipfile.ZipFile("./localizable.zip", 'r') # 压缩文件位置
87
+ # for file in f.namelist():
88
+ # f.extract(file, "../") # 解压位置
89
+ # f.close()
90
+ # os.remove('./localizable.zip')
91
+
92
+ def UpdateSource_language():
93
+ DownLatestLocalizableSource()
94
+ return './download.xlsx'
95
+
96
+ # Unzip()
97
+ # os.rename('./download.xlsx', '../hit_all_str.xlsx')
98
+ # shutil.copy('./download.xlsx', '../source_language/hit_all_str.xlsx')
99
+ # os.remove('./download.xlsx')
100
+
101
+ if __name__ == '__main__':
102
+ UpdateSource_language()
@@ -20,21 +20,21 @@ class File_util
20
20
  row1 = worksheet[0]
21
21
  @key_hash = getkeyHash(row1)
22
22
  lang_hash = {}
23
- worksheet.each_with_index do |row|
23
+ worksheet.each_with_index do |row,rowIndex|
24
+ next unless rowIndex>0
24
25
  ele = StringElement.new
25
26
  self_key = ''
26
27
  # 设置StringElement的值
27
28
  row.cells.each_with_index do |cell, i|
28
-
29
- next unless cell
29
+ next unless cell.value
30
30
  case i
31
31
  when 0
32
-
33
- when 1
34
32
  self_key = cell.value
35
33
  else
36
34
  key = @key_hash[i]
37
- ele.langHash[key] = (cell.value || '')
35
+ if key
36
+ ele.langHash[key] = (cell.value || '')
37
+ end
38
38
  end
39
39
  end
40
40
 
@@ -48,38 +48,27 @@ class File_util
48
48
  # Command+Option+L 对齐快捷键
49
49
  def getkeyHash(row1,ios:true)
50
50
  keys_hash = {}
51
+ key = ''
51
52
  row1.cells.each_with_index do |cell, i|
52
- next unless cell
53
- if i > 1
54
- result = cell.value.scan(/.*?\[(.*)\]/)
55
- key = result[0][0]
56
- case key
57
- when /zh_HK/
58
- key="zh-HK"
59
- when /zh_TW/
60
- key ="zh-Hant-TW"
61
- when /zh/
62
- key ="zh-Hans"
63
- when /fr.*/
64
- key ="fr"
65
- when /it.*/
66
- key="it"
67
- when /ger.*/
68
- key ="de"
69
- else
70
- key
71
- end
72
- keys_hash[i] = key
73
- elsif i == 1
74
- keys_hash[i] = cell.value
53
+ next unless cell.value && i > 3
54
+ if cell.value === "zh-CN"
55
+ key = 'zh-Hans'
56
+ elsif cell.value == "zh-TW"
57
+ key = 'zh-Hant-TW'
58
+ elsif cell.value == "zh-HK"
59
+ key = 'zh-HK'
60
+ else
61
+ key = cell.value.split("-")[0]
75
62
  end
63
+ # result = cell.value.scan(/.*?\[(.*)\]/)
64
+ keys_hash[i] = key
76
65
  end
77
66
  keys_hash
78
67
  end
79
68
 
80
69
  def getLangList
81
70
  list = @key_hash.values
82
- list.delete_if{|item| item.downcase === "selfkey"}
71
+ list.delete_if{|item| item.downcase === "keys"||item.downcase === "source" || item.downcase === "length limit" || item.downcase === "context"}
83
72
  list
84
73
  end
85
74
  end
@@ -90,5 +79,5 @@ end
90
79
  # puts value
91
80
  # end
92
81
 
93
- # p "sssssssss中文[zh]".scan(/.*?\[(.*)\]/)
82
+ # p "key-sname".split("-")[0]
94
83
 
@@ -6,27 +6,14 @@ require 'colored2'
6
6
 
7
7
  class LanguageDownloader
8
8
 
9
- HeaderString = %Q{Accept:application/json, text/plain, */*
10
- Accept-Encoding:gzip, deflate, br
11
- Accept-Language:zh
12
- Content-Length:194
13
- Content-Type:application/json
14
- Cookie:_ga=GA1.2.1025116346.1676013076; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%224902805f3ea41882.692841132392792065%22%2C%22first_id%22%3A%221859aeaeae8ac6-062e0ea9cca7ea-17525635-2073600-1859aeaeae9f16%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fuc.aqara.cn%2F%22%7D%2C%22%24device_id%22%3A%221859aeaeae8ac6-062e0ea9cca7ea-17525635-2073600-1859aeaeae9f16%22%7D; Token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI0OTAyODA1ZjNlYTQxODgyLjY5Mjg0MTEzMjM5Mjc5MjA2NSIsImlzcyI6Imh0dHBzOi8vYWlvdC1ycGMuYXFhcmEuY24iLCJhY2NvdW50IjoiamluZ3lhLmx1LWExMDc5QGFxYXJhLmNvbSIsImlhdEdtdDgiOjE2OTM1NzE0MDksImp0aSI6ImU4Y2YzNGMyNGRlYzQ0YWZiNzM5ODg3YzhiMGI3ZWE0YWM2OWFhNjViZmFjNDcxNWFlM2M1NmFkOGVhNDJlZGUifQ.INPHQkRwwRpXyRYpbRpNm6MfoYKUm7O4QjW7sOGNd6I; Userid=4902805f3ea41882.692841132392792065; currentSid=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI0OTAyODA1ZjNlYTQxODgyLjY5Mjg0MTEzMjM5Mjc5MjA2NSIsImlzcyI6Imh0dHBzOi8vYWlvdC1ycGMuYXFhcmEuY24iLCJpYXRHbXQ4IjoxNjkzNTcxNDA5LCJqdGkiOiI4M2JmOWRkNDlmZDU0ZTUwOWVmODFjNjJhZjMwYTg4NmVjN2E1N2QzMGVkYTQ3ZTM5MDEzMGVhNWI5MWUxZTBkIn0.wHuZsMUkvTg4i-C4nHDhCpAiq-1acfl_G6KeycekIiw; currentAccount=jingya.lu-a1079@aqara.com; userInfo=%7B%22accountCategory%22%3A%220%22%2C%22company%22%3A%7B%22companyId%22%3A1%2C%22companyName%22%3A%22%E7%BB%BF%E7%B1%B3%E8%81%94%E5%88%9B%22%7D%2C%22user%22%3A%7B%22avatarUrl%22%3A%22%22%2C%22companyId%22%3A1%2C%22email%22%3A%22jingya.lu-a1079%40aqara.com%22%2C%22nickName%22%3A%22%22%2C%22userName%22%3A%22%E9%B2%81%E9%9D%99%E4%BA%9A%22%2C%22userType%22%3A0%7D%7D
15
- Lang:zh
16
- Nonce:980m43cn1qezpnplek4ovr8ahkg2enq1
17
- Operate-Platform:40
18
- Origin:https://intl-lang.aqara.com
19
- Projectid:5
20
- Referer:https://intl-lang.aqara.com/
21
- Sec-Ch-Ua:"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"
22
- Sec-Ch-Ua-Mobile:?0
23
- Sec-Ch-Ua-Platform:"macOS"
24
- Sec-Fetch-Dest:empty
25
- Sec-Fetch-Mode:cors
26
- Sec-Fetch-Site:same-origin
27
- Time:1693571557934
28
- Timestamp:1693571557934
29
- User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
9
+ HeaderString = %Q{User-Agent: volc-sdk-python/v1.0.109
10
+ Accept-Encoding: gzip, deflate
11
+ Accept: application/json
12
+ Host: iam.volcengineapi.com
13
+ X-Date: 20231017T062815Z
14
+ X-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
15
+ Authorization: HMAC-SHA256 Credential=AKLTZTFjNzFjYTczMzJjNGQyMjg0NTRkZjQ2ZTA4MTE1Mjc/20231017/cn-north-1/i18n_openapi/request, SignedHeaders=host;x-content-sha256;x-date, Signature=fb24f4211cf74f4e985cdd72f09156c288bd8e078d9867813327084204587b0a
16
+ Connection: keep-alive
30
17
  }
31
18
 
32
19
  def self.makeHeader
@@ -40,7 +27,6 @@ User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (K
40
27
  def self.download
41
28
 
42
29
  # puts makeHeader
43
-
44
30
  #下载文件
45
31
 
46
32
  params = {"projectIdList":[5],"langIds":[1,2,3,9,10,11,12,13,14,15,16,17,18],"fileTypeList":["excel"],"auditState":1,"valueState":0,"userId":"","value":"","tagIds":nil,"bizUseTagIds":nil,"pkeys":[]}
@@ -1,3 +1,3 @@
1
1
  module CocoapodsLocalzedloader
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -3,18 +3,17 @@ require_relative './LanguageDownloader'
3
3
  require_relative './File_util'
4
4
  require 'fileutils'
5
5
  require 'colored2'
6
-
7
6
  class BundleGenerater
8
7
 
9
8
  # INFO_PLIST_ARRAY = [NSAppleMusicUsageDescription","NSLocalNetworkUsageDescription"]
10
9
  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"]}
11
10
  def self.generate
12
11
  # 下载excel
13
- f_path = LanguageDownloader.download
14
- # unless f_path != nil
15
- # return
16
- # end
17
- # f_path = "./hit_all.xls"
12
+ puts __FILE__
13
+ system "cd #{File.dirname(__FILE__)};python3 DownloadNewLanguage.py"
14
+ f_path = "#{File.dirname(__FILE__)}/download.xlsx"
15
+ print(f_path)
16
+
18
17
  # 读取excel到内存
19
18
  file_til = File_util.new
20
19
  hash = file_til.read_excel f_path
@@ -83,7 +82,9 @@ class BundleGenerater
83
82
  if File.exist?(file)
84
83
  system("plutil #{file}")
85
84
  end
86
- system("plutil #{localized_file}")
85
+ if File.exist?(localized_file)
86
+ system("plutil #{localized_file}")
87
+ end
87
88
  end
88
89
 
89
90
  #拷贝到代码仓库里
@@ -123,9 +124,8 @@ class BundleGenerater
123
124
  if copy_info_plist
124
125
  puts "InfoPlist多语言拷贝到目录:#{info_plist_path}"
125
126
  end
126
- end
127
127
 
128
- private
128
+ end
129
129
  #对多语言的value进行处理
130
130
  def self.handleValue(value='',stringElement = nil)
131
131
  #替换{=}
@@ -146,6 +146,8 @@ class BundleGenerater
146
146
 
147
147
  end
148
148
 
149
+
150
+ # BundleGenerater.generate
149
151
  # map = {:common_app_name=>["CFBundleDisplayName"]}
150
152
  # if map.has_key?("common_app_name".to_sym)
151
153
  # puts map[:common_app_name]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-localzedLoader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - jeremylu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - lib/cocoapods-localzedLoader/DownloadNewLanguage.py
48
49
  - lib/cocoapods-localzedLoader/File_util.rb
49
50
  - lib/cocoapods-localzedLoader/LanguageDownloader.rb
50
51
  - lib/cocoapods-localzedLoader/StringElement.rb