Update build.py
This commit is contained in:
@@ -1,32 +1,42 @@
|
|||||||
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')]):
|
|
||||||
remove(f)
|
|
||||||
|
|
||||||
lines = []
|
def convert(code, name, localeid, localename):
|
||||||
|
out = 'usin' + code + inp[6:]
|
||||||
|
|
||||||
# copy file and add changes
|
# delete english layout
|
||||||
with open(inp, encoding='utf8', mode='r') as finp:
|
for f in sorted([f for f in listdir() if f.startswith('usin' + code)]):
|
||||||
with open(out, encoding='utf8', mode='w') as fout:
|
remove(f)
|
||||||
for line in finp:
|
|
||||||
line = line.strip()
|
lines = []
|
||||||
lines += [line]
|
|
||||||
if line.startswith('KBD'):
|
# copy file and add changes
|
||||||
line = line[:4] + out[:8] + '\t"EN' + line[16:]
|
with open(inp, encoding='utf8', mode='r') as finp:
|
||||||
elif line.startswith('LOCALENAME'):
|
with open(out, encoding='utf8', mode='w') as fout:
|
||||||
line = 'LOCALENAME\t"en-US"'
|
for line in finp:
|
||||||
elif line.startswith('LOCALEID'):
|
line = line.strip()
|
||||||
line = 'LOCALEID\t"00000409"'
|
lines += [line]
|
||||||
elif line.startswith('0409\tFrench'):
|
if line.startswith('KBD'):
|
||||||
line = '0409\tEnglish (United States)'
|
line = line[:4] + out[:8] + '\t"EN' + line[16:]
|
||||||
|
elif line.startswith('LOCALENAME'):
|
||||||
|
line = 'LOCALENAME\t"' + localename + '"'
|
||||||
|
elif line.startswith('LOCALEID'):
|
||||||
|
line = 'LOCALEID\t"' + localeid + '"'
|
||||||
|
elif line.startswith('0409\tFrench'):
|
||||||
|
line = '0409\t' + name
|
||||||
|
fout.write(line+'\r\n')
|
||||||
|
|
||||||
|
# rewrite input with CRLF
|
||||||
|
with open(inp, encoding='utf8', mode='w') as fout:
|
||||||
|
for line in lines:
|
||||||
fout.write(line+'\r\n')
|
fout.write(line+'\r\n')
|
||||||
|
|
||||||
# rewrite input with CRLF
|
|
||||||
with open(inp, encoding='utf8', mode='w') as fout:
|
convert("us", "English (United States)", "00000409", "en-US")
|
||||||
for line in lines:
|
convert("gb", "English (United Kingdom)", "00000809", "en-GB")
|
||||||
fout.write(line+'\r\n')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user