Aqara_localizable 0.0.1 → 0.0.4

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: d60fa736dfb0db80fef1a6d8cbbd386c16a0ed3d4af05bf76205c5f470a0308d
4
- data.tar.gz: ce3fc2c27b75c36958eaefde370ed108b5c18abfd75f841430aebf3925b27b03
3
+ metadata.gz: 3e185047e44e6f2725b74df836dbe0b2de830e53dd5d85b1a6faef00a58875ef
4
+ data.tar.gz: cba3fa71759dc51d181472b7becc91f73b44b0c6fd16fc1076b75ae1186b9909
5
5
  SHA512:
6
- metadata.gz: 4fda4aa5fafa775c907d36b387f57641fafb0aef37035e572e0b5815a18f2930750eb01f4173e91dfc349b8b44dd8d1e76de91c3eb6d9a3076d46053eddf3435
7
- data.tar.gz: 9c3592ad307c795dc76af7efae9fc187b06d7779b3cb4aab32559bc5282f9a4b8896adaec8ace9926f0f773924f68b326e466be68c5b104ba80d071563b2b1bc
6
+ metadata.gz: ecdc6009aee99d99997ad0f81de1c54c64d51aa13dd731e2ed06cffda39e7e291002ec1cc22b871892cdf91ad33f0c36602613f19bc1b1e99850f5a912fedfcc
7
+ data.tar.gz: 663a414aa2886f6cdaeee31f499cfbadd56180d13a7e77ddcfeae32c0afb440516aea2646847212100b740ff85fb0f308ab3c88d7d10379ba7ea200d4c8ece5a
@@ -26,9 +26,10 @@ module AqaraLocalizable
26
26
  end
27
27
 
28
28
  def run
29
- puts '你妈是智障吧'
29
+ puts '如果多语言脚本插件有问题可以找zxf看看'.green
30
30
  target_path = Pathname.new(File.dirname(__FILE__)).realpath.parent.parent
31
31
  puts target_path
32
+ # system "pip3 install requests;pip3 install openpyxl"
32
33
  system "cd #{target_path}/script/ios_py_code;python3 ios_sp_str_generator.py #{@project_directory}"
33
34
  # system 'cd /lib/script/ios_py_code;python3 ios_sp_str_generator.py'
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module AqaraLocalizable
2
- VERSION = '0.0.1'.freeze unless defined? AqaraLocalizable::VERSION
2
+ VERSION = '0.0.4'.freeze unless defined? AqaraLocalizable::VERSION
3
3
  end
@@ -4,7 +4,7 @@ require 'Aqara_localizable'
4
4
  module Pod
5
5
  # hook
6
6
  @HooksManager = HooksManager
7
- @HooksManager.register('Aqara_Localizable', :post_install) do |_, _options|
7
+ @HooksManager.register('Aqara_localizable', :post_install) do |_, _options|
8
8
  args = ['gen', "--project-directory=#{Config.instance.installation_root}"]
9
9
 
10
10
  AqaraLocalizable::Command.run(args)
@@ -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')
@@ -84,64 +84,69 @@ def getfilter():
84
84
 
85
85
 
86
86
  if __name__ == '__main__':
87
- print('zxfdddddd'+sys.argv[1])
88
-
89
- # DownloadNewLanguage.UpdateSource_language()
90
- # filepath = '../source_language/hit_all_str.xlsx'
91
- #
92
- # platformUniteStrDict = file_util.readXlsxFileToDict(filepath)
93
- # print(len(platformUniteStrDict))
94
- # isIndexLan = False
95
- # if isIndexLan:
96
- # addIndex(platformUniteStrDict)
97
- #
98
- # dirname = '../output_file/ios'
99
- # iosStringListPath = string_repeat_filter.generateIOSStringPathList(dirname)
100
- #
101
- #
102
- # [os.makedirs(os.path.dirname(x)) for x in iosStringListPath if not os.path.exists(os.path.dirname(x))]
103
- #
104
- # # srcList = [cnXml, enXml,knXml,rnXml,twXml,hkXml,geXml,frXml,itXml,esXml]
105
- #
106
- # # se.valueList = [chinese_simp,english,korea,russia,chinese_tw,chinese_hk,german,french,itay,spain]
107
- #
108
- # iosFisList = [open(x,'w') for x in iosStringListPath]
109
- # for k in platformUniteStrDict:
110
- # item = platformUniteStrDict.get(k)
111
- # valueList = item.valueList
112
- # for str,ifis in zip(valueList,iosFisList):
113
- # # print(item.id)
114
- #
115
- # if str == None:
116
- # continue
117
- # if str.__contains__(r'""'):
118
- # str = str.replace(r'""', r'"')
119
- # if str.__contains__(r'\"'):
120
- # str = str.replace(r'\"', r'"')
121
- # if str.__contains__(r'""'):
122
- # str = str.replace(r'""', r'"')
123
- # if str.__contains__(r'"') :
124
- # str = str.replace(r'"', r'\"')
125
- #
126
- # if str.endswith('\\'):
127
- # str = str[0:-1]
128
- #
129
- # if str.endswith('\\'):
130
- # str = str[0:-1]
131
- # iosStr = f'\"{k}\" = \"{str}\";\n'
132
- # ifis.write(iosStr)
133
- #
134
- # for ifs in iosFisList:
135
- # # afis.write('</resources>')
136
- # # afis.close()
137
- # ifs.close()
138
- #
139
- # codePath = f'../../AqaraHome/AqaraHome/Common/Frameworks/LMFramework.bundle'
140
- # zxfcodePath = f'../../AqaraHome_app/AqaraHome/Common/Frameworks/LMFramework.bundle'
141
- # if os.path.exists(codePath):
142
- # copyLocalizedToDestPath(iosStringListPath,codePath)
143
- # elif os.path.exists(zxfcodePath):
144
- # copyLocalizedToDestPath(iosStringListPath, zxfcodePath)
87
+
88
+ localizable_path = sys.argv[1]
89
+ target_path = f'{localizable_path}/AqaraHome'
90
+ DownloadNewLanguage.UpdateSource_language(target_path)
91
+ filepath = f'{target_path}/hit_all_str.xlsx'
92
+
93
+ platformUniteStrDict = file_util.readXlsxFileToDict(filepath)
94
+ print(len(platformUniteStrDict))
95
+ isIndexLan = False
96
+ if isIndexLan:
97
+ addIndex(platformUniteStrDict)
98
+
99
+ dirname = f'{target_path}/output_file/ios'
100
+ iosStringListPath = string_repeat_filter.generateIOSStringPathList(dirname)
101
+
102
+
103
+ [os.makedirs(os.path.dirname(x)) for x in iosStringListPath if not os.path.exists(os.path.dirname(x))]
104
+
105
+ # srcList = [cnXml, enXml,knXml,rnXml,twXml,hkXml,geXml,frXml,itXml,esXml]
106
+
107
+ # se.valueList = [chinese_simp,english,korea,russia,chinese_tw,chinese_hk,german,french,itay,spain]
108
+
109
+ iosFisList = [open(x,'w') for x in iosStringListPath]
110
+ for k in platformUniteStrDict:
111
+ item = platformUniteStrDict.get(k)
112
+ valueList = item.valueList
113
+ for str,ifis in zip(valueList,iosFisList):
114
+ # print(item.id)
115
+
116
+ if str == None:
117
+ continue
118
+ if str.__contains__(r'""'):
119
+ str = str.replace(r'""', r'"')
120
+ if str.__contains__(r'\"'):
121
+ str = str.replace(r'\"', r'"')
122
+ if str.__contains__(r'""'):
123
+ str = str.replace(r'""', r'"')
124
+ if str.__contains__(r'"') :
125
+ str = str.replace(r'"', r'\"')
126
+
127
+ if str.endswith('\\'):
128
+ str = str[0:-1]
129
+
130
+ if str.endswith('\\'):
131
+ str = str[0:-1]
132
+ iosStr = f'\"{k}\" = \"{str}\";\n'
133
+ ifis.write(iosStr)
134
+
135
+ for ifs in iosFisList:
136
+ # afis.write('</resources>')
137
+ # afis.close()
138
+ ifs.close()
139
+
140
+ codePath = f'{localizable_path}/AqaraHome/Common/Frameworks/LMFramework.bundle'
141
+ print(f'校对下替换的位置是否正确====={codePath}')
142
+ if os.path.exists(codePath):
143
+ copyLocalizedToDestPath(iosStringListPath,codePath)
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
+
145
150
 
146
151
 
147
152
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Aqara_localizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan
@@ -146,11 +146,11 @@ files:
146
146
  - README.md
147
147
  - bin/Aqaralocalizable
148
148
  - lib/Aqara_localizable.rb
149
- - lib/Aqara_localizable/cocoapods_plugin.rb
150
149
  - lib/Aqara_localizable/command.rb
151
150
  - lib/Aqara_localizable/command/command_gen.rb
152
151
  - lib/Aqara_localizable/command/zxf.py
153
152
  - lib/Aqara_localizable/gem_version.rb
153
+ - lib/cocoapods_plugin.rb
154
154
  - lib/script/git_shell/addPrefix.sh
155
155
  - lib/script/git_shell/android_git_clean.sh
156
156
  - lib/script/git_shell/commit_push.sh
@@ -301,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  - !ruby/object:Gem::Version
302
302
  version: '0'
303
303
  requirements: []
304
- rubygems_version: 3.1.6
304
+ rubygems_version: 3.3.26
305
305
  signing_key:
306
306
  specification_version: 4
307
307
  summary: AqaraHome 多语言插件