Update build.py

This commit is contained in:
Klemek
2021-02-26 13:31:16 +01:00
committed by GitHub
parent b0d4f4fdeb
commit 465e730962
+21 -11
View File
@@ -1,17 +1,22 @@
from os import listdir, remove from os import listdir, remove
# get last version of french file # get last version of french file
inp = sorted([f for f in listdir() if f.startswith('usinfr')])[-1] inp = sorted([f for f in listdir() if f.startswith('usinfr')])[-1]
out = 'usinen' + inp[6:]
# delete english layout
for f in sorted([f for f in listdir() if f.startswith('usinen')]): def convert(code, name, localeid, localename):
out = 'usin' + code + inp[6:]
# delete english layout
for f in sorted([f for f in listdir() if f.startswith('usin' + code)]):
remove(f) remove(f)
lines = [] lines = []
# copy file and add changes # copy file and add changes
with open(inp, encoding='utf8', mode='r') as finp: with open(inp, encoding='utf8', mode='r') as finp:
with open(out, encoding='utf8', mode='w') as fout: with open(out, encoding='utf8', mode='w') as fout:
for line in finp: for line in finp:
line = line.strip() line = line.strip()
@@ -19,14 +24,19 @@ with open(inp, encoding='utf8', mode='r') as finp:
if line.startswith('KBD'): if line.startswith('KBD'):
line = line[:4] + out[:8] + '\t"EN' + line[16:] line = line[:4] + out[:8] + '\t"EN' + line[16:]
elif line.startswith('LOCALENAME'): elif line.startswith('LOCALENAME'):
line = 'LOCALENAME\t"en-US"' line = 'LOCALENAME\t"' + localename + '"'
elif line.startswith('LOCALEID'): elif line.startswith('LOCALEID'):
line = 'LOCALEID\t"00000409"' line = 'LOCALEID\t"' + localeid + '"'
elif line.startswith('0409\tFrench'): elif line.startswith('0409\tFrench'):
line = '0409\tEnglish (United States)' line = '0409\t' + name
fout.write(line+'\r\n') fout.write(line+'\r\n')
# rewrite input with CRLF # rewrite input with CRLF
with open(inp, encoding='utf8', mode='w') as fout: with open(inp, encoding='utf8', mode='w') as fout:
for line in lines: for line in lines:
fout.write(line+'\r\n') fout.write(line+'\r\n')
convert("us", "English (United States)", "00000409", "en-US")
convert("gb", "English (United Kingdom)", "00000809", "en-GB")