From 950658183c549688391d6a071df1050ad2a573bf Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 11 Apr 2025 18:08:00 +0000 Subject: [PATCH] contrib: push_locale.py: fix relative paths in messages_qml.pot The Qt lupdate tool that extracts translatable strings from .qml files writes paths relative to its output .ts file into the .ts file. These paths are then retained as-is when converted to .pot format. The last few commits moved around the working directory of the lupdate tool (from electrum/locale to electrum/locale/build), which resulted in a change of all relative paths in the final messages.pot we upload to crowdin. E.g. from: ``` #: ../gui/qml/components/Addresses.qml:64 ``` to: ``` #: ../../gui/qml/components/Addresses.qml:64 ``` I think a change like this does not invalidate the translations. Still, it is annoying. This commit adds an extra processing step to "fix" these strings to: ``` #: electrum/gui/qml/components/Addresses.qml:64 ``` --- contrib/locale/push_locale.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/locale/push_locale.py b/contrib/locale/push_locale.py index 86b855434..18eb18f24 100755 --- a/contrib/locale/push_locale.py +++ b/contrib/locale/push_locale.py @@ -71,6 +71,7 @@ with open(f"{build_dir}/qml.lst", "wb") as f: 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 :/ cmd = [QT_LUPDATE, f"@{build_dir}/qml.lst","-ts", f"{build_dir}/qml.ts"] print('Collecting strings') subprocess.check_output(cmd) @@ -79,6 +80,12 @@ cmd = [QT_LCONVERT, "-of", "po", "-o", f"{build_dir}/messages_qml.pot", f"{build print('Convert to gettext') subprocess.check_output(cmd) +print("Fixing some paths in messages_qml.pot") +# sed from " ../../gui/qml/" +# to " electrum/gui/qml/" +cmd = ["sed", "-i", r"s/ ..\/..\/gui\/qml\// electrum\/gui\/qml\//g", f"{build_dir}/messages_qml.pot"] +subprocess.check_output(cmd) + cmd = ["msgcat", "-u", "-o", f"{build_dir}/messages.pot", f"{build_dir}/messages_gettext.pot", f"{build_dir}/messages_qml.pot"] print('Generate template') subprocess.check_output(cmd)