760 @pyqtSlot() |
762 @pyqtSlot() |
761 def __initDatabase(self): |
763 def __initDatabase(self): |
762 """ |
764 """ |
763 Private slot showing the result of the database creation. |
765 Private slot showing the result of the database creation. |
764 """ |
766 """ |
765 from .FlaskCommandDialog import FlaskCommandDialog |
|
766 |
|
767 dlg = FlaskCommandDialog(self) |
767 dlg = FlaskCommandDialog(self) |
768 if dlg.startCommand("init-db"): |
768 if dlg.startFlaskCommand("init-db"): |
769 dlg.exec() |
769 dlg.exec() |
770 |
770 |
771 ################################################################## |
771 ################################################################## |
772 ## slots and methods below implement i18n and l10n support |
772 ## slots and methods below implement i18n and l10n support |
773 ################################################################## |
773 ################################################################## |
880 |
880 |
881 def __projectLanguageAdded(self, code): |
881 def __projectLanguageAdded(self, code): |
882 # TODO: implement this with pybabel ... |
882 # TODO: implement this with pybabel ... |
883 pass |
883 pass |
884 |
884 |
885 def openPOEditor(self): |
885 def openPOEditor(self, poFile): |
886 # TODO: implement this with pybabel ... |
886 """ |
887 pass |
887 Public method to edit the given file in an external .po editor. |
|
888 |
|
889 @param poFile name of the .po file |
|
890 @type str |
|
891 """ |
|
892 editor = self.__plugin.getPreferences("TranslationsEditor") |
|
893 if poFile.endswith(".po") and editor: |
|
894 wd, _ = self.getApplication() |
|
895 started, pid = QProcess.startDetached(editor, [poFile], wd) |
|
896 if not started: |
|
897 E5MessageBox.critical( |
|
898 None, |
|
899 self.tr('Process Generation Error'), |
|
900 self.tr('The translations editor process ({0}) could' |
|
901 ' not be started.').format( |
|
902 os.path.basename(editor))) |
888 |
903 |
889 def extractMessages(self): |
904 def extractMessages(self): |
|
905 """ |
|
906 Public method to extract the messages catalog template file. |
|
907 """ |
|
908 title = self.tr("Extract messages") |
|
909 if self.__ensurePybabelConfigured(): |
|
910 potFile = self.__e5project.getAbsoluteUniversalPath( |
|
911 self.getData("pybabel", "catalogFile")) |
|
912 |
|
913 try: |
|
914 potFilePath = os.path.dirname(potFile) |
|
915 os.makedirs(potFilePath) |
|
916 except EnvironmentError: |
|
917 pass |
|
918 |
|
919 args = [ |
|
920 "-F", |
|
921 self.__e5project.getAbsoluteUniversalPath( |
|
922 self.getData("pybabel", "configFile")) |
|
923 ] |
|
924 if self.getData("pybabel", "markersList"): |
|
925 for marker in self.getData("pybabel", "markersList"): |
|
926 args += ["-k", marker] |
|
927 args += [ |
|
928 "-o", |
|
929 potFile, |
|
930 "." |
|
931 ] |
|
932 |
|
933 dlg = FlaskCommandDialog(self) |
|
934 res = dlg.startBabelCommand( |
|
935 "extract", args, title, |
|
936 msgSuccess=self.tr("\nMessages extracted successfully.") |
|
937 ) |
|
938 if res: |
|
939 dlg.exec() |
|
940 self.__e5project.appendFile(potFile) |
890 # TODO: implement this with pybabel ... |
941 # TODO: implement this with pybabel ... |
891 pass |
942 pass |
892 |
943 |
893 def compileCatalogs(self): |
944 def compileCatalogs(self): |
894 # TODO: implement this with pybabel ... |
945 # TODO: implement this with pybabel ... |