@@ -366,7 +366,6 @@ def _convert(self, project: QgsProject) -> None: # noqa: PLR0912, PLR0915
366366 for additional_project_file in additional_project_files :
367367 additional_project_file_path = Path (additional_project_file )
368368 additional_project_file_name = additional_project_file_path .name
369-
370369 additional_project_file_relative_path = (
371370 additional_project_file_path .relative_to (project_path )
372371 )
@@ -376,22 +375,33 @@ def _convert(self, project: QgsProject) -> None: # noqa: PLR0912, PLR0915
376375 ).resolve ()
377376 destination_file .parent .mkdir (parents = True , exist_ok = True )
378377
378+ # Project plugins and translation files require for their file name
379+ # to match that of their associated project file (e.g myproject.qgs,
380+ # myproject_bg.qm for a translation file and myproject.qml for a
381+ # project plugin). We must therefore adapt these file names to match
382+ # the generated project file name
383+ original_project_filename_without_extension = str (
384+ self .original_filename
385+ )[:- 4 ]
386+ export_project_filename_without_extension = str (
387+ export_project_filename .name
388+ )[:- 4 ]
379389 if (
380390 str (additional_project_file_path )
381- == f"{ str ( self . original_filename )[: - 4 ] } .qml"
391+ == f"{ original_project_filename_without_extension } .qml"
382392 ):
383393 destination_file = destination_file .parent .joinpath (
384- f"{ str ( export_project_filename . name )[: - 4 ] } .qml"
394+ f"{ export_project_filename_without_extension } .qml"
385395 )
386396
387397 elif additional_project_file_name .endswith (".qm" ):
388398 match = re .match (
389- rf"^{ re .escape (str ( self . original_filename )[: - 4 ]) } (_[A-Za-z][A-Za-z] \.qm)$" ,
399+ rf"^{ re .escape (original_project_filename_without_extension ) } (_[A-Za-z]{{2}} \.qm)$" ,
390400 str (additional_project_file_path ),
391401 )
392402 if match :
393403 destination_file = destination_file .parent .joinpath (
394- f"{ str ( export_project_filename . name )[: - 4 ] } { match .group (1 )} "
404+ f"{ export_project_filename_without_extension } { match .group (1 )} "
395405 )
396406
397407 shutil .copy (additional_project_file , str (destination_file ))
0 commit comments