262 @return menu names |
263 @return menu names |
263 @rtype list of str |
264 @rtype list of str |
264 """ |
265 """ |
265 return list(self.__menus.keys()) |
266 return list(self.__menus.keys()) |
266 |
267 |
|
268 def registerOpenHook(self): |
|
269 """ |
|
270 Public method to register the open hook to open a translations file |
|
271 in a translations editor. |
|
272 """ |
|
273 if self.__hooksInstalled: |
|
274 editor = self.__plugin.getPreferences("TranslationsEditor") |
|
275 if editor: |
|
276 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
277 "open", self.openPOEditor, |
|
278 self.tr("Open with {0}").format( |
|
279 os.path.basename(editor))) |
|
280 else: |
|
281 self.__translationsBrowser.removeHookMethod("open") |
|
282 |
|
283 def projectOpenedHooks(self): |
|
284 """ |
|
285 Public method to add our hook methods. |
|
286 """ |
|
287 if self.__e5project.getProjectType() == "Flask": |
|
288 ## self.__formsBrowser = ( |
|
289 ## e5App().getObject("ProjectBrowser") |
|
290 ## .getProjectBrowser("forms")) |
|
291 ## self.__formsBrowser.addHookMethodAndMenuEntry( |
|
292 ## "newForm", self.newForm, self.tr("New template...")) |
|
293 ## |
|
294 if self.flaskBabelAvailable(): |
|
295 self.__e5project.projectLanguageAddedByCode.connect( |
|
296 self.__projectLanguageAdded) |
|
297 self.__translationsBrowser = ( |
|
298 e5App().getObject("ProjectBrowser") |
|
299 .getProjectBrowser("translations")) |
|
300 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
301 "extractMessages", self.extractMessages, |
|
302 self.tr("Extract Messages")) |
|
303 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
304 "releaseAll", self.compileCatalogs, |
|
305 self.tr("Compile All Catalogs")) |
|
306 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
307 "releaseSelected", self.compileSelectedCatalogs, |
|
308 self.tr("Compile Selected Catalogs")) |
|
309 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
310 "generateAll", self.updateCatalogs, |
|
311 self.tr("Update All Catalogs")) |
|
312 self.__translationsBrowser.addHookMethodAndMenuEntry( |
|
313 "generateSelected", self.updateSelectedCatalogs, |
|
314 self.tr("Update Selected Catalogs")) |
|
315 |
|
316 self.__hooksInstalled = True |
|
317 |
|
318 self.registerOpenHook() |
|
319 |
|
320 def projectClosedHooks(self): |
|
321 """ |
|
322 Public method to remove our hook methods. |
|
323 """ |
|
324 if self.__hooksInstalled: |
|
325 ## self.__formsBrowser.removeHookMethod("newForm") |
|
326 ## self.__formsBrowser = None |
|
327 ## |
|
328 self.__e5project.projectLanguageAddedByCode.disconnect( |
|
329 self.__projectLanguageAdded) |
|
330 self.__translationsBrowser.removeHookMethod("extractMessages") |
|
331 self.__translationsBrowser.removeHookMethod("releaseAll") |
|
332 self.__translationsBrowser.removeHookMethod("releaseSelected") |
|
333 self.__translationsBrowser.removeHookMethod("generateAll") |
|
334 self.__translationsBrowser.removeHookMethod("generateSelected") |
|
335 self.__translationsBrowser.removeHookMethod("open") |
|
336 self.__translationsBrowser = None |
|
337 |
|
338 self.__hooksInstalled = False |
|
339 |
267 ################################################################## |
340 ################################################################## |
268 ## slots below implement general functionality |
341 ## slots below implement general functionality |
269 ################################################################## |
342 ################################################################## |
270 |
343 |
271 def projectClosed(self): |
344 def projectClosed(self): |
581 Private slot showing the result of the database creation. |
652 Private slot showing the result of the database creation. |
582 """ |
653 """ |
583 dlg = FlaskCommandDialog(self) |
654 dlg = FlaskCommandDialog(self) |
584 if dlg.startCommand("init-db"): |
655 if dlg.startCommand("init-db"): |
585 dlg.exec() |
656 dlg.exec() |
|
657 |
|
658 ################################################################## |
|
659 ## slots and methods below implement i18n and l10n support |
|
660 ################################################################## |
|
661 |
|
662 def flaskBabelAvailable(self): |
|
663 """ |
|
664 Public method to check, if the 'flask-babel' package is available. |
|
665 |
|
666 @return flag indicating the availability of 'flask-babel' |
|
667 @rtype bool |
|
668 """ |
|
669 venvName = self.__plugin.getPreferences("VirtualEnvironmentNamePy3") |
|
670 interpreter = self.__virtualEnvManager.getVirtualenvInterpreter( |
|
671 venvName) |
|
672 if interpreter and Utilities.isinpath(interpreter): |
|
673 detector = os.path.join( |
|
674 os.path.dirname(__file__), "FlaskBabelDetector.py") |
|
675 proc = QProcess() |
|
676 proc.setProcessChannelMode(QProcess.MergedChannels) |
|
677 proc.start(interpreter, [detector]) |
|
678 finished = proc.waitForFinished(30000) |
|
679 if finished and proc.exitCode() == 0: |
|
680 return True |
|
681 |
|
682 return False |
|
683 |
|
684 def __projectLanguageAdded(self, code): |
|
685 # TODO: implement this with pybabel ... |
|
686 pass |
|
687 |
|
688 def openPOEditor(self): |
|
689 # TODO: implement this with pybabel ... |
|
690 pass |
|
691 |
|
692 def extractMessages(self): |
|
693 # TODO: implement this with pybabel ... |
|
694 pass |
|
695 |
|
696 def compileCatalogs(self): |
|
697 # TODO: implement this with pybabel ... |
|
698 pass |
|
699 |
|
700 def compileSelectedCatalogs(self): |
|
701 # TODO: implement this with pybabel ... |
|
702 pass |
|
703 |
|
704 def updateCatalogs(self): |
|
705 # TODO: implement this with pybabel ... |
|
706 pass |
|
707 |
|
708 def updateSelectedCatalogs(self): |
|
709 # TODO: implement this with pybabel ... |
|
710 pass |