-
-
Notifications
You must be signed in to change notification settings - Fork 4
Support packaging of project translation files #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
additional_project_file_name = additional_project_file_path.name | ||
|
||
additional_project_file_relative_path = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additional_project_file_name = additional_project_file_path.name | |
additional_project_file_relative_path = ( | |
additional_project_file_name = additional_project_file_path.name | |
additional_project_file_relative_path = ( |
Just wondering if this empty line was on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was on purpose, but let's remove it if you prefer it that way.
libqfieldsync/offline_converter.py
Outdated
|
||
elif additional_project_file_name.endswith(".qm"): | ||
match = re.match( | ||
rf"^{re.escape(str(self.original_filename)[:-4])}(_[A-Za-z][A-Za-z]\.qm)$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rf"^{re.escape(str(self.original_filename)[:-4])}(_[A-Za-z][A-Za-z]\.qm)$", | |
rf"^{re.escape(original_filename_stem}(_[A-Za-z]{2}\.qm)$", |
This is still convoluted, but slightly more readable. I would even go for:
rf"^{re.escape(str(self.original_filename)[:-4])}(_[A-Za-z][A-Za-z]\.qm)$", | |
"{}_[A-Za-z]{2}.qm".format( | |
re.escape(original_filename_stem), | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pre-commit force the re.escape back inside the rf"..." over here, so seems like the gods want it that way.
I did however change to [A-Za-z]{{2}} , and I'm using a variable for the original file path without the extension suffix, so we're mostly there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice functionality, +1 for the tests.
Code looks good. A few tiny comments on readability. Feel free to merge.
Do you consider this "QFieldCloud sensitive files", such as the plugins? Shall we add them here:
https://github.com/opengisch/QFieldCloud/blob/master/docker-app/qfieldcloud/filestorage/utils.py#L69
@suricactus , review addressed thanks. Regarding "sensitive files", I wouldn't flag the translations as being sensitive. If you have a strong feeling about it, we can add it into the above-mentioned function. |
This unlocks translated projects on QFieldCloud by insuring that {project name}_{2-letter language code}.qm files are copied into the packaged project directory.
The PR also insures that sidecar translations and project plugin files properly adopt the exported project name (i.e. myproject.qgs -> myproject_cloud.qgs means the project plugin file will become myproject_cloud.qml and translation files would be myproject_de.qm, myproject_fr.qm, etc.).
Test coverage included.