| 1 |
#! /usr/bin/python3 |
| 2 |
|
| 3 |
import sys, os, zipfile |
| 4 |
from glob import glob |
| 5 |
|
| 6 |
if len(sys.argv) < 2: |
| 7 |
print(f"""Usage: {sys.argv[0]} <language code> |
| 8 |
example: {sys.argv[0]} hi |
| 9 |
this will create a file /tmp/translate-to-hi.zip |
| 10 |
with a translation kit for Hindi language, and last |
| 11 |
updated contents from the git repository.""") |
| 12 |
sys.exit(1) |
| 13 |
|
| 14 |
lang=sys.argv[1] |
| 15 |
|
| 16 |
if not os.path.exists(os.path.join("ExpEYES17","UserManual",lang)): |
| 17 |
print(f"Error: the directory ExpEYES17/UserManual/{lang} is missing") |
| 18 |
sys.exit(1) |
| 19 |
|
| 20 |
tsFile=os.path.join("eyes17","lang",f"{lang}.ts") |
| 21 |
if not os.path.exists(tsFile): |
| 22 |
print(f"Error: the file {tsFile} is missing") |
| 23 |
sys.exit(1) |
| 24 |
|
| 25 |
with zipfile.ZipFile(f"/tmp/translate-to-{lang}.zip", mode="w") as myzip: |
| 26 |
for rstFile in glob(f"ExpEYES17/UserManual/{lang}/rst/exp/*.rst"): |
| 27 |
myzip.write(rstFile) |
| 28 |
for schem in glob(f"ExpEYES17/UserManual/{lang}/rst/exp/schematics/*.svg"): |
| 29 |
myzip.write(schem) |
| 30 |
for pic in glob(f"ExpEYES17/UserManual/{lang}/rst/exp/pics/*"): |
| 31 |
myzip.write(pic) |
| 32 |
myzip.write(tsFile) |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
print(f"[DONE] Check the contents of /tmp/translate-to-{lang}.zip") |