contrib/locale/push_locale: more deterministic messages.pot (fs order)

Tries to remove differences caused by filesystem-order in the generated .pot file.

The crowdin activity stream is full of events:
```
SomberNight_CI_BOT changed the context of 126 strings
02:42
String	Previous context	New context	File	Time
{} blocks	#: electrum/gui/qt/channel_details.py:256 #: electrum/gui/qt/channel_details.py:257 electrum/gui/qt/network_dialog.py:514 	#: electrum/gui/qt/network_dialog.py:514 electrum/gui/qt/channel_details.py:256 #: electrum/gui/qt/channel_details.py:257 	messages.pot	02:42
[...]
```
^ i.e. on every CI push, the comments containing the file paths and line-numbers were getting mixed up randomly
This is undesirable noise.
This commit is contained in:
SomberNight
2026-02-14 08:10:26 +00:00
parent cd802c6e41
commit d20c9364ef
2 changed files with 19 additions and 20 deletions
-1
View File
@@ -14,7 +14,6 @@ env/
.buildozer .buildozer
.buildozer_*/ .buildozer_*/
bin/ bin/
/app.fil
.idea .idea
.mypy_cache .mypy_cache
.vscode .vscode
+19 -19
View File
@@ -6,6 +6,7 @@
# Dependencies: # Dependencies:
# $ sudo apt-get install python3-requests gettext qt6-l10n-tools # $ sudo apt-get install python3-requests gettext qt6-l10n-tools
import glob
import os import os
import subprocess import subprocess
import sys import sys
@@ -44,32 +45,31 @@ except (subprocess.CalledProcessError, OSError) as e1:
except (subprocess.CalledProcessError, OSError) as e2: except (subprocess.CalledProcessError, OSError) as e2:
raise Exception("missing Qt lupdate/convert tools. Maybe try 'apt install qt6-l10n-tools'") raise Exception("missing Qt lupdate/convert tools. Maybe try 'apt install qt6-l10n-tools'")
# create build dir
cmd = "find electrum -type f -name '*.py' -o -name '*.kv'"
files = subprocess.check_output(cmd, shell=True)
with open("app.fil", "wb") as f:
f.write(files)
print("Found {} files to translate".format(len(files.splitlines())))
# Generate fresh translation template
build_dir = os.path.join(locale_dir, "build") build_dir = os.path.join(locale_dir, "build")
if not os.path.exists(build_dir): if not os.path.exists(build_dir):
os.mkdir(build_dir) os.mkdir(build_dir)
# add .py files
files_list = glob.glob("electrum/**/*.py", recursive=True)
files_list = sorted(files_list) # makes output deterministic across CI runs
with open(f"{build_dir}/app.fil", "w", encoding="utf-8") as f:
for item in files_list:
f.writelines(item + "\n")
print("Found {} .py files to translate".format(len(files_list)))
# Generate fresh translation template
print('Generating template...') print('Generating template...')
cmd = ["xgettext", "-s", "--from-code", "UTF-8", "--language", "Python", "--no-wrap", "-f", "app.fil", f"--output={build_dir}/messages_gettext.pot"] cmd = ["xgettext", "-s", "--from-code", "UTF-8", "--language", "Python", "--no-wrap", "-f", f"{build_dir}/app.fil", f"--output={build_dir}/messages_gettext.pot"]
subprocess.check_output(cmd) subprocess.check_output(cmd)
# add QML translations # add QML translations
cmd = "find electrum/gui/qml -type f -name '*.qml'" files_list = glob.glob("electrum/gui/qml/**/*.qml", recursive=True)
files = subprocess.check_output(cmd, shell=True) files_list = sorted(files_list) # makes output deterministic across CI runs
with open(f"{build_dir}/qml.lst", "w", encoding="utf-8") as f:
with open(f"{build_dir}/qml.lst", "wb") as f: for item in files_list:
f.write(files) f.write(item + "\n")
print("Found {} QML files to translate".format(len(files_list)))
print("Found {} QML files to translate".format(len(files.splitlines())))
# note: lupdate writes relative paths into its output .ts file, relative to the .ts file itself :/ # note: lupdate writes relative paths into its output .ts file, relative to the .ts file itself :/
cmd = [QT_LUPDATE, f"@{build_dir}/qml.lst","-ts", f"{build_dir}/qml.ts"] cmd = [QT_LUPDATE, f"@{build_dir}/qml.lst","-ts", f"{build_dir}/qml.ts"]