Tools: Add workaround for lupdate missing source

lupdate requires at least one C++ source file to be present in order
to process the project file. In cases where a workbench is Python-only,
this resulted in incorrect or missing extraction of strings in ui files.
Those files should have been processed by lupdate, but were not.
pyludate was not configured to process them. To work around this, the
updatets.py script is modified to create a dummy *.cpp file before
running qmake.
This commit is contained in:
Chris Hennes
2022-01-01 15:20:43 -06:00
parent 175ceb2d12
commit 3e75db0d58

View File

@@ -153,6 +153,7 @@ def update_translation(entry):
tsBasename = os.path.join(entry["tsdir"],entry["tsname"])
execline = []
execline.append (f"touch dummy_cpp_file_for_lupdate.cpp") #lupdate requires at least one source file to process the UI files
execline.append (f"{QMAKE} -project -o {project_filename}")
execline.append (f"sed 's/<translation.*>.*<\/translation>/<translation type=\"unfinished\"><\/translation>/g' {tsBasename}.ts > {tsBasename}.ts.temp")
execline.append (f"touch {tsBasename}.ts") # In case it didn't get created above
@@ -161,6 +162,7 @@ def update_translation(entry):
execline.append (f"{PYLUPDATE} `find ./ -name \"*.py\"` -ts {tsBasename}py.ts {log_redirect}")
execline.append (f"{LCONVERT} -i {tsBasename}py.ts {tsBasename}.ts -o {tsBasename}.ts {log_redirect}")
execline.append (f"rm {tsBasename}py.ts")
execline.append (f"rm dummy_cpp_file_for_lupdate.cpp")
print(f"Executing special commands in {entry['workingdir']}:")
for line in execline:
print (line)