mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 04:12:20 +08:00
lang.py for auto translate complete
This commit is contained in:
parent
176045468f
commit
16ba58aad3
29
lang.py
Normal file
29
lang.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import glob
|
||||
|
||||
def get_lang(lang):
|
||||
out = {}
|
||||
for ln in open('./src/lang/%s.rs'%lang):
|
||||
ln = ln.strip()
|
||||
if ln.startswith('("'):
|
||||
toks = ln.split('", "')
|
||||
assert(len(toks) == 2)
|
||||
a = toks[0][2:]
|
||||
b = toks[1][:-3]
|
||||
out[a] = b
|
||||
return out
|
||||
|
||||
def main():
|
||||
cn = get_lang('cn')
|
||||
for fn in glob.glob('./src/lang/*'):
|
||||
lang = os.path.basename(fn)[:-3]
|
||||
if lang == 'cn': continue
|
||||
not_transated = (set(cn.keys()) - set(get_lang(lang).keys()))
|
||||
extra = '\n'.join(map(lambda x: ' ("%s", ""),'%x, not_transated))
|
||||
endstr = '].iter().cloned().collect();'
|
||||
text = open(fn).read().replace(endstr, extra + '\n' + endstr)
|
||||
with open(fn, 'wt') as fh:
|
||||
fh.write(text)
|
||||
|
||||
|
||||
main()
|
Loading…
Reference in New Issue
Block a user