Aqara_localizable 0.0.3 → 0.0.5

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: 81a6dcb2ae02b0dd0a6770219c2b504066dbaf18230d3de3c1774ecf3d1bd09a
4
- data.tar.gz: c34677b5b73c122f71bb588ea32bff28f3750163ced5b095b640f79b29ae79c8
3
+ metadata.gz: bbf09c7da40f156a14ad3a0dbfdc5305ebac729efea9f0bdc8f2b6001661263e
4
+ data.tar.gz: b03412d3bd6aeb77abcfd6e9aec48fbbca7995198c2feb7e1841747a752b3fd0
5
5
  SHA512:
6
- metadata.gz: 8fbb8cc1a89bf10fea55eff789b141bc776a35e4a4807c4be7df1d5fb0561469481dd31a903126a209efdf2a5eb8b63dbc9647ea21f918d93e582c926da5309b
7
- data.tar.gz: fec24ebc5ad4806b65fdcfaf1bec1cc98a5034e5abc74362bd5066bf99bf813a39581dde9ea7562e0df2faf63c3b80d4bb8969b727001b1bbc6a989f80848b66
6
+ metadata.gz: 34f0034ad3d38935d4b98914e5285c518d1216c22e78b7a6f8d1675de844c820f8b2cae98278ece624115ba65f368edcfc5202b5c1aba1523f9d927048ad9a79
7
+ data.tar.gz: 57371e5c944b00fdb18e7579eade2d2cececf20a9281f53d5cf9b20a4f906f7f30b08dc63bb9a6003344a04ded75a124cdfe14dff681b96c57dc0ac026e9317e
@@ -4,7 +4,6 @@ module AqaraLocalizable
4
4
  class Command
5
5
  class Gen < Command
6
6
  self.summary = '开始下载多语言平台的代码并替换项目多语言文件'
7
-
8
7
  def initialize(argv)
9
8
  super
10
9
  project_directory = argv.option('project-directory')
@@ -28,7 +27,8 @@ module AqaraLocalizable
28
27
  def run
29
28
  puts '如果多语言脚本插件有问题可以找zxf看看'.green
30
29
  target_path = Pathname.new(File.dirname(__FILE__)).realpath.parent.parent
31
-
30
+ puts target_path
31
+ # system "pip3 install requests;pip3 install openpyxl"
32
32
  system "cd #{target_path}/script/ios_py_code;python3 ios_sp_str_generator.py #{@project_directory}"
33
33
  # system 'cd /lib/script/ios_py_code;python3 ios_sp_str_generator.py'
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module AqaraLocalizable
2
- VERSION = '0.0.3'.freeze unless defined? AqaraLocalizable::VERSION
2
+ VERSION = '0.0.5'.freeze unless defined? AqaraLocalizable::VERSION
3
3
  end
@@ -34,26 +34,24 @@ def MakeHeader(headerText):
34
34
  s = {x.split(':', 1)[0].strip() :x.split(':', 1)[1].strip() for x in s}
35
35
  return s
36
36
 
37
- def DownLatestLocalizableSource():
37
+ def DownLatestLocalizableSource(targetPath):
38
38
  session = requests.Session()
39
39
  headers = MakeHeader(myheader)
40
40
  params = '{"projectIdList":[5],"langIds":[1,2,3,9,10,11,12,13,14,15],"fileTypeList":["excel"],"auditState":1,"valueState":0,"userId":"","value":"","tagIds":null,"bizUseTagIds":null,"pkeys":[]}'
41
41
  response = session.post("https://intl-lang.aqara.com/v1.0/lumi/language/file/export", headers = headers, data=params, timeout=3)
42
- with open("localizable" + ".zip","wb") as code:
42
+ with open(f'{targetPath}/localizable' + ".zip","wb") as code:
43
43
  # 将 response 保存成本地文件
44
44
  code.write(response.content)
45
45
  code.close()
46
46
 
47
- def Unzip():
48
- f = zipfile.ZipFile("./localizable.zip", 'r') # 压缩文件位置
47
+ def Unzip(targetPath):
48
+ f = zipfile.ZipFile(f'{targetPath}/localizable.zip', 'r') # 压缩文件位置
49
49
  for file in f.namelist():
50
- f.extract(file, "../") # 解压位置
50
+ f.extract(file, targetPath) # 解压位置
51
51
  f.close()
52
- os.remove('./localizable.zip')
52
+ os.remove(f'{targetPath}/localizable.zip')
53
53
 
54
- def UpdateSource_language():
55
- DownLatestLocalizableSource()
56
- Unzip()
57
- os.rename('../excel.xls', '../hit_all_str.xlsx')
58
- shutil.copy('../hit_all_str.xlsx', '../source_language/hit_all_str.xlsx')
59
- os.remove('../hit_all_str.xlsx')
54
+ def UpdateSource_language(targetPath):
55
+ DownLatestLocalizableSource(targetPath)
56
+ Unzip(targetPath)
57
+ os.rename(f'{targetPath}/excel.xls', f'{targetPath}/hit_all_str.xlsx')
@@ -86,17 +86,17 @@ def getfilter():
86
86
  if __name__ == '__main__':
87
87
 
88
88
  localizable_path = sys.argv[1]
89
-
90
- DownloadNewLanguage.UpdateSource_language()
91
- filepath = '../source_language/hit_all_str.xlsx'
89
+ target_path = f'{localizable_path}/AqaraHome'
90
+ DownloadNewLanguage.UpdateSource_language(target_path)
91
+ filepath = f'{target_path}/hit_all_str.xlsx'
92
92
 
93
93
  platformUniteStrDict = file_util.readXlsxFileToDict(filepath)
94
- print(len(platformUniteStrDict))
94
+ print(f'\033[4;36m多语言Key总数:{len(platformUniteStrDict)}\033[0m')
95
95
  isIndexLan = False
96
96
  if isIndexLan:
97
97
  addIndex(platformUniteStrDict)
98
98
 
99
- dirname = '../output_file/ios'
99
+ dirname = f'{target_path}/output_file/ios'
100
100
  iosStringListPath = string_repeat_filter.generateIOSStringPathList(dirname)
101
101
 
102
102
 
@@ -138,10 +138,16 @@ if __name__ == '__main__':
138
138
  ifs.close()
139
139
 
140
140
  codePath = f'{localizable_path}/AqaraHome/Common/Frameworks/LMFramework.bundle'
141
- print(f'校对下替换的位置是否正确====={codePath}')
141
+ print(f'\033[1;35m校对下替换的位置是否正确:{codePath}\033[0m')
142
142
  if os.path.exists(codePath):
143
143
  copyLocalizedToDestPath(iosStringListPath,codePath)
144
144
 
145
+ os.remove(f'{target_path}/hit_all_str.xlsx')
146
+ if os.path.exists(os.path.dirname(f'{target_path}/output_file')):
147
+ shutil.rmtree(f'{target_path}/output_file')
148
+
149
+
150
+
145
151
 
146
152
 
147
153
 
@@ -164,7 +164,6 @@ def readXlsxFileToDict(filepath):
164
164
  for cell in ws.rows:
165
165
 
166
166
  key = cell[1].value
167
- print(key)
168
167
  if key == None or key == 'key':
169
168
  continue
170
169
  chinese_simp = cell[Language.CHI_SIMPLE.value].value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Aqara_localizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2022-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler