@@ -363,7 +363,6 @@ def _convert(self, project: QgsProject) -> None: # noqa: PLR0912, PLR0915
363363 for additional_project_file in additional_project_files:
364364 additional_project_file_path = Path(additional_project_file)
365365 additional_project_file_name = additional_project_file_path.name
366-
367366 additional_project_file_relative_path = (
368367 additional_project_file_path.relative_to(project_path)
369368 )
@@ -373,22 +372,33 @@ def _convert(self, project: QgsProject) -> None: # noqa: PLR0912, PLR0915
373372 ).resolve()
374373 destination_file.parent.mkdir(parents=True, exist_ok=True)
375374
375+ # Project plugins and translation files require for their file name
376+ # to match that of their associated project file (e.g myproject.qgs,
377+ # myproject_bg.qm for a translation file and myproject.qml for a
378+ # project plugin). We must therefore adapt these file names to match
379+ # the generated project file name
380+ original_project_filename_without_extension = str(
381+ self.original_filename
382+ )[:-4]
383+ export_project_filename_without_extension = str(
384+ export_project_filename.name
385+ )[:-4]
376386 if (
377387 str(additional_project_file_path)
378- == f"{str(self.original_filename)[:-4] }.qml"
388+ == f"{original_project_filename_without_extension }.qml"
379389 ):
380390 destination_file = destination_file.parent.joinpath(
381- f"{str(export_project_filename.name)[:-4] }.qml"
391+ f"{export_project_filename_without_extension }.qml"
382392 )
383393
384394 elif additional_project_file_name.endswith(".qm"):
385395 match = re.match(
386- rf"^{re.escape(str(self.original_filename)[:-4]) }(_[A-Za-z][A-Za-z] \.qm)$",
396+ rf"^{re.escape(original_project_filename_without_extension) }(_[A-Za-z]{{2}} \.qm)$",
387397 str(additional_project_file_path),
388398 )
389399 if match:
390400 destination_file = destination_file.parent.joinpath(
391- f"{str(export_project_filename.name)[:-4] }{match.group(1)}"
401+ f"{export_project_filename_without_extension }{match.group(1)}"
392402 )
393403
394404 shutil.copy(additional_project_file, str(destination_file))
0 commit comments