make some language lists at snap build time

This commit is contained in:
Michael Hudson-Doyle 2020-05-07 12:47:09 +12:00
parent 8628cbb0b8
commit 5cb37acefc
2 changed files with 39 additions and 0 deletions

30
scripts/make-language-lists Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/python3
import glob
import gzip
import os
translations = set()
for fname in glob.glob('po/*.po'):
translations.add(os.path.splitext(os.path.basename(fname))[0])
print('found translations', translations)
console_langs = open('languagelist-console', 'w')
ssh_langs = open('languagelist-ssh', 'w')
data = gzip.open('/usr/share/localechooser/languagelist.data.gz', mode='rt')
for line in data:
level, code, name, desc = line.strip().split(':')
if code not in translations:
continue
level = int(level)
new_line = "{}:{}\n".format(code, desc)
ssh_langs.write(new_line)
if level <= 2:
console_langs.write(new_line)
console_langs.close()
ssh_langs.close()
data.close()

View File

@ -124,6 +124,15 @@ parts:
font/subiquity.psf: subiquity.psf
stage:
- subiquity.psf
languagelists:
plugin: nil
build-packages:
- localechooser-data
override-build: |
scripts/make-language-lists
stage:
- languagelist-console
- languagelist-ssh
probert:
plugin: python
build-packages: [python-setuptools, libnl-3-dev, libnl-genl-3-dev, libnl-route-3-dev]