mirror of
https://github.com/thetasoft/wulkplot-translations.git
synced 2026-03-28 16:14:48 +00:00
Feat: Add translation tools
This commit is contained in:
35
tools/compile_translations.py
Normal file
35
tools/compile_translations.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import subprocess
|
||||
import glob
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
TRANSLATIONS_DIR = Path(__file__).resolve().parent.parent
|
||||
print(TRANSLATIONS_DIR)
|
||||
|
||||
ts_files = glob.glob(str(TRANSLATIONS_DIR / "*.ts"))
|
||||
success = []
|
||||
failed = []
|
||||
|
||||
print("Compiling .ts files to .qm:")
|
||||
|
||||
for ts_file in ts_files:
|
||||
qm_file = ts_file.replace(".ts", ".qm")
|
||||
cmd = ["qt6-tools", "lrelease", ts_file]
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"[Compiled]:\t {os.path.basename(ts_file)} → {os.path.basename(qm_file)}")
|
||||
success.append(qm_file)
|
||||
else:
|
||||
print(f"[Failed]:\t {os.path.basename(ts_file)}")
|
||||
print(result.stderr)
|
||||
failed.append(ts_file)
|
||||
|
||||
print("\n--- Summary ---")
|
||||
print(f"{len(success)} succeeded")
|
||||
print(f"{len(failed)} failed")
|
||||
|
||||
if failed:
|
||||
print("\nFailed files:")
|
||||
for f in failed:
|
||||
print(" -", f)
|
||||
Reference in New Issue
Block a user