View Single Post
Old 01-07-2019, 05:02 AM   #3
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 930
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by kovidgoyal View Post
First for language, you want:

Code:
if language[0] in ("pt_BR", "pt_PT", "pt")
Thanks for the tip! This is the first time I ever used python, so I do a lot of things in a weird way. lol

Quote:
Originally Posted by kovidgoyal View Post
more generally speaking you can eventually setup proper translations for the plugin, via Transifex.
Sure. I'll prepare the code for extracting the strings and use POEDIT.
Just one question: supose I have the POT (and PO/MO) file, how do I add it to Transifex?

Quote:
Originally Posted by kovidgoyal View Post
Now for the config dialog , you have to link up the config menu item to some code to actually open the dialog, like this, in main.py:

Code:
    def do_config(self):
        from calibre.gui2.widgets2 import Dialog
        from calibre.gui2.tweak_book import tprefs
        from PyQt5.Qt import QVBoxLayout
        from calibre_plugins.ACE.config import ConfigWidget
        tool = self

        class ConfigDialog(Dialog):

            def __init__(self):
                Dialog.__init__(self, 'Configure ACE', 'plugin-ace-config-dialog', parent=tool.gui, prefs=tprefs)

            def setup_ui(self):
                self.l = QVBoxLayout(self)
                self.w = ConfigWidget()
                self.l.addWidget(self.w)

            def accept(self):
                if self.w.validate():
                    self.w.save_settings()
                    Dialog.accept(self)

        d = ConfigDialog()
        d.exec_()
link it up to you action like this:

Code:
            config_menu_item.triggered.connect(self.do_config)
It worked perfectly. Thank you very much, Kovid! You are great.
thiago.eec is online now   Reply With Quote