add a folder for useful scripts
This commit is contained in:
parent
33ed166ec9
commit
ac435adda3
3 changed files with 115 additions and 0 deletions
41
scripts/scdup.py
Normal file
41
scripts/scdup.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import sys
|
||||
import os
|
||||
import json
|
||||
|
||||
# load every key in the source language
|
||||
# check the keys in all translations
|
||||
# remove keys that only exist in translations
|
||||
|
||||
cwd = os.getcwd()
|
||||
langdir = cwd + '/../src/strings'
|
||||
langlst = os.listdir(langdir)
|
||||
|
||||
langlst.remove('en-us.json')
|
||||
print(langlst)
|
||||
input('press enter to continue')
|
||||
|
||||
keysus = []
|
||||
with open(langdir + '/' + 'en-us.json') as en:
|
||||
langus = json.load(en)
|
||||
for key in langus:
|
||||
keysus.append(key)
|
||||
|
||||
for lang in langlst:
|
||||
with open(langdir + '/' + lang, 'r') as f:
|
||||
inde = 2
|
||||
if '\n \"' in f.read():
|
||||
inde = 4
|
||||
f.close()
|
||||
with open(langdir + '/' + lang, 'r+') as f:
|
||||
langjson = json.load(f)
|
||||
langjnew = {}
|
||||
for key in langjson:
|
||||
if key in keysus:
|
||||
langjnew[key] = langjson[key]
|
||||
f.seek(0)
|
||||
f.write(json.dumps(langjnew, indent=inde, sort_keys=False, ensure_ascii=False))
|
||||
f.write('\n')
|
||||
f.truncate()
|
||||
f.close()
|
||||
|
||||
print('DONE')
|
Loading…
Add table
Add a link
Reference in a new issue