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 ```
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user