Browse Source

feat: release GVLK in different languages

dev
Dnomd343 2 years ago
parent
commit
9303315ce0
  1. 24
      gvlk/config.yml
  2. 0
      gvlk/data.json
  3. 9
      gvlk/fetch.py
  4. 41
      gvlk/release.py

24
gvlk/config.yml

@ -2,3 +2,27 @@ lang:
- en-us
- zh-cn
- zh-tw
path: ../assets/gvlk/
win:
- 'windows-vista'
- 'windows-7'
- 'windows-8'
- 'windows-81'
- 'windows-11-and-windows-10-semi-annual-channel-versions'
- 'windows-10-ltsb-2015'
- 'windows-10-ltsb-2016'
- 'windows-10-ltsc-2021-and-2019'
win-server:
- 'windows-server-version-1709'
- 'windows-server-version-1803'
- 'windows-server-versions-20h2-2004-1909-1903-and-1809'
- 'windows-server-2016'
- 'windows-server-2019'
- 'windows-server-2022'
- 'windows-server-2012-r2'
- 'windows-server-2012'
- 'windows-server-2008-r2'
- 'windows-server-2008'

0
gvlk/ok.json → gvlk/data.json

9
gvlk/fetch.py

@ -71,8 +71,7 @@ def combineGvlk(rawData: dict) -> dict: # merge multiple languages
return result
gvlkData = combineGvlk({x: fetchGvlk(x) for x in LANG})
with open('raw.json', 'w') as fp: # output as `raw.json`
fp.write(json.dumps(gvlkData, indent = 2, ensure_ascii = False))
fp.write('\n')
if __name__ == '__main__':
gvlkData = combineGvlk({x: fetchGvlk(x) for x in LANG})
with open('raw.json', 'w') as fp: # output as `raw.json`
fp.write(json.dumps(gvlkData, indent = 2, ensure_ascii = False) + '\n')

41
gvlk/release.py

@ -0,0 +1,41 @@
#!/usr/bin/env python3
import os
import json
import yaml
Config = yaml.full_load(open('config.yml').read())
AllGvlkData = json.loads(open('data.json').read())
def dumpItem(lang: str, version: str) -> tuple[str, dict]:
gvlkData = AllGvlkData[version]
verName = gvlkData['name'][lang]
return verName, {x['name'][lang]: x['key'] for x in gvlkData['content']}
def dumpGroup(lang: str, versions: str) -> dict:
result = {}
for version in versions:
name, data = dumpItem(lang, version)
result[name] = data
return result
def dumpGvlk(lang: str) -> str:
return json.dumps({
'win': dumpGroup(lang, Config['win']),
'win-server': dumpGroup(lang, Config['win-server']),
}, indent = 2, ensure_ascii = False)
def release(path: str) -> None:
for lang in Config['lang']:
with open(os.path.join(path, '%s.json' % lang), 'w') as fp:
fp.write(dumpGvlk(lang) + '\n')
if __name__ == '__main__':
if not os.path.exists(Config['path']):
os.makedirs(Config['path'])
release(Config['path'])
Loading…
Cancel
Save