contrib/locale/push_locale: more deterministic messages.pot (fs order)
What changed, and why it matters
This commit is a build-script cleanup. It changes how Electrum's translation system collects source files so the generated translation template is produced in a consistent, sorted order instead of depending on unpredictable filesystem ordering. There is no user-facing bug fix or security change.
No security action needed. Treat as routine build/CI hygiene.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies contrib/locale/push_locale.py to replace shell find commands with Python glob.glob(…, recursive=True) and sorted() when building lists of .py and .qml source files. It also moves the temporary app.fil and qml.lst files into a build subdirectory and removes the top-level /app.fil entry from .gitignore. The stated goal is to make the generated messages.pot deterministic across CI runs, eliminating noisy but non-functional reordering of file/line reference comments in Crowdin. No cryptographic, network, parsing, or privilege code is touched.
Changed components
contrib/locale/push_locale.py.gitignoreInspect captured patch +19 / −20
diff --git a/.gitignore b/.gitignore
index e33d0cd..3ef1b05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,7 +14,6 @@ env/
.buildozer
.buildozer_*/
bin/
-/app.fil
.idea
.mypy_cache
.vscode
diff --git a/contrib/locale/push_locale.py b/contrib/locale/push_locale.py
index 18eb18f..da7e84f 100755
--- a/contrib/locale/push_locale.py
+++ b/contrib/locale/push_locale.py
@@ -6,6 +6,7 @@
# Dependencies:
# $ sudo apt-get install python3-requests gettext qt6-l10n-tools
+import glob
import os
import subprocess
import sys
@@ -44,32 +45,31 @@ except (subprocess.CalledProcessError, OSError) as e1:
except (subprocess.CalledProcessError, OSError) as e2:
raise Exception("missing Qt lupdate/convert tools. Maybe try 'apt install qt6-l10n-tools'")
-
-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
+# create build dir
build_dir = os.path.join(locale_dir, "build")
if not os.path.exists(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...')
-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)
-
# add QML translations
-cmd = "find electrum/gui/qml -type f -name '*.qml'"
-files = subprocess.check_output(cmd, shell=True)
-
-with open(f"{build_dir}/qml.lst", "wb") as f:
- f.write(files)
-
-print("Found {} QML files to translate".format(len(files.splitlines())))
+files_list = glob.glob("electrum/gui/qml/**/*.qml", recursive=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:
+ for item in files_list:
+ f.write(item + "\n")
+print("Found {} QML files to translate".format(len(files_list)))
# 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"]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.