ProjectFlask/FlaskBabelExtension/PyBabelProjectExtension.py

branch
eric7
changeset 85
fcb5126077b1
parent 84
f39230b845e4
child 87
075f7667f69d
equal deleted inserted replaced
84:f39230b845e4 85:fcb5126077b1
38 38
39 @param plugin reference to the plugin object 39 @param plugin reference to the plugin object
40 @type ProjectFlaskPlugin 40 @type ProjectFlaskPlugin
41 @param project reference to the project object 41 @param project reference to the project object
42 @type Project 42 @type Project
43 @param parent parent 43 @param parent reference to the parent widget
44 @type QObject 44 @type QWidget
45 """ 45 """
46 super().__init__(parent) 46 super().__init__(parent)
47 47
48 self.__plugin = plugin 48 self.__plugin = plugin
49 self.__project = project 49 self.__project = project
50 self.__ui = parent
50 51
51 self.__ericProject = ericApp().getObject("Project") 52 self.__ericProject = ericApp().getObject("Project")
52 53
53 self.__hooksInstalled = False 54 self.__hooksInstalled = False
54 55
276 Private slot to show a dialog to edit the pybabel configuration. 277 Private slot to show a dialog to edit the pybabel configuration.
277 """ 278 """
278 from .PyBabelConfigDialog import PyBabelConfigDialog 279 from .PyBabelConfigDialog import PyBabelConfigDialog
279 280
280 config = self.__project.getData("flask-babel", "") 281 config = self.__project.getData("flask-babel", "")
281 dlg = PyBabelConfigDialog(config) 282 dlg = PyBabelConfigDialog(config, parent=self.__ui)
282 if dlg.exec() == QDialog.DialogCode.Accepted: 283 if dlg.exec() == QDialog.DialogCode.Accepted:
283 config = dlg.getConfiguration() 284 config = dlg.getConfiguration()
284 self.__project.setData("flask-babel", "", config) 285 self.__project.setData("flask-babel", "", config)
285 286
286 self.__ericProject.setTranslationPattern( 287 self.__ericProject.setTranslationPattern(
478 for marker in self.__project.getData("flask-babel", "markersList"): 479 for marker in self.__project.getData("flask-babel", "markersList"):
479 args += ["-k", marker] 480 args += ["-k", marker]
480 args += ["-o", os.path.relpath(potFile, workdir), "."] 481 args += ["-o", os.path.relpath(potFile, workdir), "."]
481 482
482 dlg = PyBabelCommandDialog( 483 dlg = PyBabelCommandDialog(
483 self, title, msgSuccess=self.tr("\nMessages extracted successfully.") 484 self,
485 title,
486 msgSuccess=self.tr("\nMessages extracted successfully."),
487 parent=self.__ui,
484 ) 488 )
485 res = dlg.startCommand("extract", args, workdir) 489 res = dlg.startCommand("extract", args, workdir)
486 if res: 490 if res:
487 dlg.exec() 491 dlg.exec()
488 self.__ericProject.appendFile(potFile) 492 self.__ericProject.appendFile(potFile)
514 518
515 dlg = PyBabelCommandDialog( 519 dlg = PyBabelCommandDialog(
516 self, 520 self,
517 title, 521 title,
518 msgSuccess=self.tr("\nMessage catalog initialized successfully."), 522 msgSuccess=self.tr("\nMessage catalog initialized successfully."),
523 parent=self.__ui,
519 ) 524 )
520 res = dlg.startCommand("init", args, workdir) 525 res = dlg.startCommand("init", args, workdir)
521 if res: 526 if res:
522 dlg.exec() 527 dlg.exec()
523 528
549 554
550 dlg = PyBabelCommandDialog( 555 dlg = PyBabelCommandDialog(
551 self, 556 self,
552 title, 557 title,
553 msgSuccess=self.tr("\nMessage catalogs compiled successfully."), 558 msgSuccess=self.tr("\nMessage catalogs compiled successfully."),
559 parent=self.__ui,
554 ) 560 )
555 res = dlg.startCommand("compile", args, workdir) 561 res = dlg.startCommand("compile", args, workdir)
556 if res: 562 if res:
557 dlg.exec() 563 dlg.exec()
558 564
604 610
605 dlg = PyBabelCommandDialog( 611 dlg = PyBabelCommandDialog(
606 self, 612 self,
607 title=title, 613 title=title,
608 msgSuccess=self.tr("\nMessage catalogs compiled successfully."), 614 msgSuccess=self.tr("\nMessage catalogs compiled successfully."),
615 parent=self.__ui,
609 ) 616 )
610 res = dlg.startBatchCommand(argsList, workdir) 617 res = dlg.startBatchCommand(argsList, workdir)
611 if res: 618 if res:
612 dlg.exec() 619 dlg.exec()
613 620
649 656
650 dlg = PyBabelCommandDialog( 657 dlg = PyBabelCommandDialog(
651 self, 658 self,
652 title, 659 title,
653 msgSuccess=self.tr("\nMessage catalogs updated successfully."), 660 msgSuccess=self.tr("\nMessage catalogs updated successfully."),
661 parent=self.__ui,
654 ) 662 )
655 res = dlg.startCommand("update", args, workdir) 663 res = dlg.startCommand("update", args, workdir)
656 if res: 664 if res:
657 dlg.exec() 665 dlg.exec()
658 666
712 720
713 dlg = PyBabelCommandDialog( 721 dlg = PyBabelCommandDialog(
714 self, 722 self,
715 title=title, 723 title=title,
716 msgSuccess=self.tr("\nMessage catalogs updated successfully."), 724 msgSuccess=self.tr("\nMessage catalogs updated successfully."),
725 parent=self.__ui,
717 ) 726 )
718 res = dlg.startBatchCommand(argsList, workdir) 727 res = dlg.startBatchCommand(argsList, workdir)
719 if res: 728 if res:
720 dlg.exec() 729 dlg.exec()
721 730

eric ide

mercurial