forked from NinjaCheetah/NUSGet
Added guide for translation and new script to build translations
This commit is contained in:
26
build_translations.py
Normal file
26
build_translations.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# "build_translations.py", licensed under the MIT license
|
||||
# Copyright 2024 NinjaCheetah
|
||||
# This script exists to work around an issue in PySide6 where the "pyside6-project build" command incorrectly places
|
||||
# translation files in the root of the project directory while building.
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
|
||||
LRELEASE_CMD = "pyside6-lrelease"
|
||||
|
||||
|
||||
pyproject_file = pathlib.Path("NUSGet.pyproject")
|
||||
pyproject = json.load(open(pyproject_file, "r"))
|
||||
files = []
|
||||
for key in pyproject["files"]:
|
||||
files.append(pathlib.Path(key))
|
||||
ts_files = []
|
||||
for file in files:
|
||||
if file.suffix == ".ts":
|
||||
ts_files.append(file)
|
||||
|
||||
for translation in ts_files:
|
||||
cmd = [LRELEASE_CMD] + [translation] + ["-qm"] + [translation.with_suffix(".qm")]
|
||||
subprocess.run(cmd, cwd=str(pyproject_file.parent))
|
||||
Reference in New Issue
Block a user