| 1 |
# SOME DESCRIPTIVE TITLE. |
| 2 |
# Copyright (C) Kovid Goyal |
| 3 |
# This file is distributed under the same license as the calibre package. |
| 4 |
# |
| 5 |
# Translators: |
| 6 |
msgid "" |
| 7 |
msgstr "" |
| 8 |
"Project-Id-Version: calibre\n" |
| 9 |
"Report-Msgid-Bugs-To: \n" |
| 10 |
"POT-Creation-Date: 2022-02-03 02:30+0000\n" |
| 11 |
"PO-Revision-Date: 2022-01-21 05:29+0000\n" |
| 12 |
"Last-Translator: Kovid Goyal <[email protected]>\n" |
| 13 |
"Language-Team: Malayalam (http://www.transifex.com/calibre/calibre/language/ml/)\n" |
| 14 |
"MIME-Version: 1.0\n" |
| 15 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 16 |
"Content-Transfer-Encoding: 8bit\n" |
| 17 |
"Language: ml\n" |
| 18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
| 19 |
|
| 20 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:4 |
| 21 |
msgid "Writing your own plugins to extend calibre's functionality" |
| 22 |
msgstr "" |
| 23 |
|
| 24 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:6 |
| 25 |
msgid "" |
| 26 |
"calibre has a very modular design. Almost all functionality in calibre comes" |
| 27 |
" in the form of plugins. Plugins are used for conversion, for downloading " |
| 28 |
"news (though these are called recipes), for various components of the user " |
| 29 |
"interface, to connect to different devices, to process files when adding " |
| 30 |
"them to calibre and so on. You can get a complete list of all the built-in " |
| 31 |
"plugins in calibre by going to :guilabel:`Preferences->Advanced->Plugins`." |
| 32 |
msgstr "" |
| 33 |
|
| 34 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:8 |
| 35 |
msgid "" |
| 36 |
"Here, we will teach you how to create your own plugins to add new features " |
| 37 |
"to calibre." |
| 38 |
msgstr "" |
| 39 |
|
| 40 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:13 |
| 41 |
msgid "Contents" |
| 42 |
msgstr "" |
| 43 |
|
| 44 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:15 |
| 45 |
msgid "This only applies to calibre releases >= 0.8.60" |
| 46 |
msgstr "" |
| 47 |
|
| 48 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:18 |
| 49 |
msgid "Anatomy of a calibre plugin" |
| 50 |
msgstr "" |
| 51 |
|
| 52 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:20 |
| 53 |
msgid "" |
| 54 |
"A calibre plugin is very simple, it's just a ZIP file that contains some " |
| 55 |
"Python code and any other resources like image files needed by the plugin. " |
| 56 |
"Without further ado, let's see a basic example." |
| 57 |
msgstr "" |
| 58 |
|
| 59 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:24 |
| 60 |
msgid "" |
| 61 |
"Suppose you have an installation of calibre that you are using to self " |
| 62 |
"publish various e-documents in EPUB and MOBI formats. You would like all " |
| 63 |
"files generated by calibre to have their publisher set as \"Hello world\", " |
| 64 |
"here's how to do it. Create a file named :file:`__init__.py` (this is a " |
| 65 |
"special name and must always be used for the main file of your plugin) and " |
| 66 |
"enter the following Python code into it:" |
| 67 |
msgstr "" |
| 68 |
|
| 69 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:32 |
| 70 |
msgid "" |
| 71 |
"That's all. To add this code to calibre as a plugin, simply run the " |
| 72 |
"following in the folder in which you created :file:`__init__.py`::" |
| 73 |
msgstr "" |
| 74 |
|
| 75 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:38 |
| 76 |
msgid "" |
| 77 |
"On macOS, the command line tools are inside the calibre bundle, for example," |
| 78 |
" if you installed calibre in :file:`/Applications` the command line tools " |
| 79 |
"are in :file:`/Applications/calibre.app/Contents/MacOS/`." |
| 80 |
msgstr "" |
| 81 |
|
| 82 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:42 |
| 83 |
msgid "" |
| 84 |
"You can download the Hello World plugin from " |
| 85 |
":download_file:`helloworld_plugin.zip`." |
| 86 |
msgstr "" |
| 87 |
|
| 88 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:45 |
| 89 |
msgid "" |
| 90 |
"Every time you use calibre to convert a book, the plugin's :meth:`run` " |
| 91 |
"method will be called and the converted book will have its publisher set to " |
| 92 |
"\"Hello World\". This is a trivial plugin, lets move on to a more complex " |
| 93 |
"example that actually adds a component to the user interface." |
| 94 |
msgstr "" |
| 95 |
|
| 96 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:50 |
| 97 |
msgid "A User Interface plugin" |
| 98 |
msgstr "" |
| 99 |
|
| 100 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:52 |
| 101 |
msgid "" |
| 102 |
"This plugin will be spread over a few files (to keep the code clean). It " |
| 103 |
"will show you how to get resources (images or data files) from the plugin " |
| 104 |
"ZIP file, allow users to configure your plugin, how to create elements in " |
| 105 |
"the calibre user interface and how to access and query the books database in" |
| 106 |
" calibre." |
| 107 |
msgstr "" |
| 108 |
|
| 109 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:57 |
| 110 |
msgid "" |
| 111 |
"You can download this plugin from :download_file:`interface_demo_plugin.zip`" |
| 112 |
msgstr "" |
| 113 |
|
| 114 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:61 |
| 115 |
msgid "" |
| 116 |
"The first thing to note is that this ZIP file has a lot more files in it, " |
| 117 |
"explained below, pay particular attention to ``plugin-import-name-" |
| 118 |
"interface_demo.txt``." |
| 119 |
msgstr "" |
| 120 |
|
| 121 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:77 |
| 122 |
msgid "**plugin-import-name-interface_demo.txt**" |
| 123 |
msgstr "" |
| 124 |
|
| 125 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:65 |
| 126 |
msgid "" |
| 127 |
"An empty text file used to enable the multi-file plugin magic. This file " |
| 128 |
"must be present in all plugins that use more than one .py file. It should be" |
| 129 |
" empty and its filename must be of the form: ``plugin-import-" |
| 130 |
"name-**some_name**.txt``. The presence of this file allows you to import " |
| 131 |
"code from the .py files present inside the ZIP file, using a statement " |
| 132 |
"like::" |
| 133 |
msgstr "" |
| 134 |
|
| 135 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:71 |
| 136 |
msgid "" |
| 137 |
"The prefix ``calibre_plugins`` must always be present. ``some_name`` comes " |
| 138 |
"from the filename of the empty text file. ``some_module`` refers to " |
| 139 |
":file:`some_module.py` file inside the ZIP file. Note that this importing is" |
| 140 |
" just as powerful as regular Python imports. You can create packages and " |
| 141 |
"subpackages of .py modules inside the ZIP file, just like you would normally" |
| 142 |
" (by defining __init__.py in each sub-folder), and everything should \"just " |
| 143 |
"work\"." |
| 144 |
msgstr "" |
| 145 |
|
| 146 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:76 |
| 147 |
msgid "" |
| 148 |
"The name you use for ``some_name`` enters a global namespace shared by all " |
| 149 |
"plugins, **so make it as unique as possible**. But remember that it must be " |
| 150 |
"a valid Python identifier (only alphabets, numbers and the underscore)." |
| 151 |
msgstr "" |
| 152 |
|
| 153 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:80 |
| 154 |
msgid "**__init__.py**" |
| 155 |
msgstr "" |
| 156 |
|
| 157 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:80 |
| 158 |
msgid "As before, the file that defines the plugin class" |
| 159 |
msgstr "" |
| 160 |
|
| 161 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:83 |
| 162 |
msgid "**main.py**" |
| 163 |
msgstr "" |
| 164 |
|
| 165 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:83 |
| 166 |
msgid "This file contains the actual code that does something useful" |
| 167 |
msgstr "" |
| 168 |
|
| 169 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:86 |
| 170 |
msgid "**ui.py**" |
| 171 |
msgstr "" |
| 172 |
|
| 173 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:86 |
| 174 |
msgid "This file defines the interface part of the plugin" |
| 175 |
msgstr "" |
| 176 |
|
| 177 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:89 |
| 178 |
msgid "**images/icon.png**" |
| 179 |
msgstr "" |
| 180 |
|
| 181 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:89 |
| 182 |
msgid "The icon for this plugin" |
| 183 |
msgstr "" |
| 184 |
|
| 185 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:92 |
| 186 |
msgid "**about.txt**" |
| 187 |
msgstr "" |
| 188 |
|
| 189 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:92 |
| 190 |
msgid "A text file with information about the plugin" |
| 191 |
msgstr "" |
| 192 |
|
| 193 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:97 |
| 194 |
msgid "**translations**" |
| 195 |
msgstr "" |
| 196 |
|
| 197 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:95 |
| 198 |
msgid "" |
| 199 |
"A folder containing .mo files with the translations of the user interface of" |
| 200 |
" your plugin into different languages. See below for details." |
| 201 |
msgstr "" |
| 202 |
|
| 203 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:99 |
| 204 |
msgid "Now let's look at the code." |
| 205 |
msgstr "" |
| 206 |
|
| 207 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:102 |
| 208 |
msgid "__init__.py" |
| 209 |
msgstr "" |
| 210 |
|
| 211 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:104 |
| 212 |
msgid "First, the obligatory ``__init__.py`` to define the plugin metadata:" |
| 213 |
msgstr "" |
| 214 |
|
| 215 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:109 |
| 216 |
msgid "" |
| 217 |
"The only noteworthy feature is the field :attr:`actual_plugin`. Since " |
| 218 |
"calibre has both command line and GUI interfaces, GUI plugins like this one " |
| 219 |
"should not load any GUI libraries in __init__.py. The actual_plugin field " |
| 220 |
"does this for you, by telling calibre that the actual plugin is to be found " |
| 221 |
"in another file inside your ZIP archive, which will only be loaded in a GUI " |
| 222 |
"context." |
| 223 |
msgstr "" |
| 224 |
|
| 225 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:114 |
| 226 |
msgid "" |
| 227 |
"Remember that for this to work, you must have a plugin-import-name-" |
| 228 |
"some_name.txt file in your plugin ZIP file, as discussed above." |
| 229 |
msgstr "" |
| 230 |
|
| 231 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:117 |
| 232 |
msgid "" |
| 233 |
"Also there are a couple of methods for enabling user configuration of the " |
| 234 |
"plugin. These are discussed below." |
| 235 |
msgstr "" |
| 236 |
|
| 237 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:120 |
| 238 |
msgid "ui.py" |
| 239 |
msgstr "" |
| 240 |
|
| 241 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:122 |
| 242 |
msgid "" |
| 243 |
"Now let's look at ui.py which defines the actual GUI plugin. The source code" |
| 244 |
" is heavily commented and should be self explanatory:" |
| 245 |
msgstr "" |
| 246 |
|
| 247 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:128 |
| 248 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:212 |
| 249 |
msgid "main.py" |
| 250 |
msgstr "" |
| 251 |
|
| 252 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:130 |
| 253 |
msgid "The actual logic to implement the Interface Plugin Demo dialog." |
| 254 |
msgstr "" |
| 255 |
|
| 256 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:136 |
| 257 |
msgid "Getting resources from the plugin ZIP file" |
| 258 |
msgstr "" |
| 259 |
|
| 260 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:138 |
| 261 |
msgid "" |
| 262 |
"calibre's plugin loading system defines a couple of built-in functions that " |
| 263 |
"allow you to conveniently get files from the plugin ZIP file." |
| 264 |
msgstr "" |
| 265 |
|
| 266 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:145 |
| 267 |
msgid "**get_resources(name_or_list_of_names)**" |
| 268 |
msgstr "" |
| 269 |
|
| 270 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:141 |
| 271 |
msgid "" |
| 272 |
"This function should be called with a list of paths to files inside the ZIP " |
| 273 |
"file. For example to access the file icon.png in the folder images in the " |
| 274 |
"ZIP file, you would use: ``images/icon.png``. Always use a forward slash as " |
| 275 |
"the path separator, even on Windows. When you pass in a single name, the " |
| 276 |
"function will return the raw bytes of that file or None if the name was not " |
| 277 |
"found in the ZIP file. If you pass in more than one name then it returns a " |
| 278 |
"dict mapping the names to bytes. If a name is not found, it will not be " |
| 279 |
"present in the returned dict." |
| 280 |
msgstr "" |
| 281 |
|
| 282 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:149 |
| 283 |
msgid "**get_icons(name_or_list_of_names)**" |
| 284 |
msgstr "" |
| 285 |
|
| 286 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:148 |
| 287 |
msgid "" |
| 288 |
"A convenience wrapper for get_resources() that creates QIcon objects from " |
| 289 |
"the raw bytes returned by get_resources. If a name is not found in the ZIP " |
| 290 |
"file the corresponding QIcon will be null." |
| 291 |
msgstr "" |
| 292 |
|
| 293 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:152 |
| 294 |
msgid "Enabling user configuration of your plugin" |
| 295 |
msgstr "" |
| 296 |
|
| 297 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:154 |
| 298 |
msgid "" |
| 299 |
"To allow users to configure your plugin, you must define three methods in " |
| 300 |
"your base plugin class, **is_customizable**, **config_widget** and " |
| 301 |
"**save_settings** as shown below:" |
| 302 |
msgstr "" |
| 303 |
|
| 304 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:165 |
| 305 |
msgid "" |
| 306 |
"calibre has many different ways to store configuration data (a legacy of its" |
| 307 |
" long history). The recommended way is to use the **JSONConfig** class, " |
| 308 |
"which stores your configuration information in a .json file." |
| 309 |
msgstr "" |
| 310 |
|
| 311 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:167 |
| 312 |
msgid "" |
| 313 |
"The code to manage configuration data in the demo plugin is in config.py:" |
| 314 |
msgstr "" |
| 315 |
|
| 316 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:172 |
| 317 |
msgid "" |
| 318 |
"The ``prefs`` object is now available throughout the plugin code by a " |
| 319 |
"simple::" |
| 320 |
msgstr "" |
| 321 |
|
| 322 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:177 |
| 323 |
msgid "You can see the ``prefs`` object being used in main.py:" |
| 324 |
msgstr "" |
| 325 |
|
| 326 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:184 |
| 327 |
msgid "Edit book plugins" |
| 328 |
msgstr "" |
| 329 |
|
| 330 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:186 |
| 331 |
msgid "" |
| 332 |
"Now let's change gears for a bit and look at creating a plugin to add tools " |
| 333 |
"to the calibre book editor. The plugin is available here: " |
| 334 |
":download_file:`editor_demo_plugin.zip`." |
| 335 |
msgstr "" |
| 336 |
|
| 337 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:190 |
| 338 |
msgid "" |
| 339 |
"The first step, as for all plugins is to create the import name empty txt " |
| 340 |
"file, as described :ref:`above <import_name_txt>`. We shall name the file " |
| 341 |
"``plugin-import-name-editor_plugin_demo.txt``." |
| 342 |
msgstr "" |
| 343 |
|
| 344 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:194 |
| 345 |
msgid "" |
| 346 |
"Now we create the mandatory ``__init__.py`` file that contains metadata " |
| 347 |
"about the plugin -- its name, author, version, etc." |
| 348 |
msgstr "" |
| 349 |
|
| 350 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:200 |
| 351 |
msgid "" |
| 352 |
"A single editor plugin can provide multiple tools each tool corresponds to a" |
| 353 |
" single button in the toolbar and entry in the :guilabel:`Plugins` menu in " |
| 354 |
"the editor. These can have sub-menus in case the tool has multiple related " |
| 355 |
"actions." |
| 356 |
msgstr "" |
| 357 |
|
| 358 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:204 |
| 359 |
msgid "" |
| 360 |
"The tools must all be defined in the file ``main.py`` in your plugin. Every " |
| 361 |
"tool is a class that inherits from the " |
| 362 |
":class:`calibre.gui2.tweak_book.plugin.Tool` class. Let's look at " |
| 363 |
"``main.py`` from the demo plugin, the source code is heavily commented and " |
| 364 |
"should be self-explanatory. Read the API documents of the " |
| 365 |
":class:`calibre.gui2.tweak_book.plugin.Tool` class for more details." |
| 366 |
msgstr "" |
| 367 |
|
| 368 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:214 |
| 369 |
msgid "" |
| 370 |
"Here we will see the definition of a single tool that will multiply all font" |
| 371 |
" sizes in the book by a number provided by the user. This tool demonstrates " |
| 372 |
"various important concepts that you will need in developing your own " |
| 373 |
"plugins, so you should read the (heavily commented) source code carefully." |
| 374 |
msgstr "" |
| 375 |
|
| 376 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:222 |
| 377 |
msgid "" |
| 378 |
"Let's break down ``main.py``. We see that it defines a single tool, named " |
| 379 |
"*Magnify fonts*. This tool will ask the user for a number and multiply all " |
| 380 |
"font sizes in the book by that number." |
| 381 |
msgstr "" |
| 382 |
|
| 383 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:226 |
| 384 |
msgid "" |
| 385 |
"The first important thing is the tool name which you must set to some " |
| 386 |
"relatively unique string as it will be used as the key for this tool." |
| 387 |
msgstr "" |
| 388 |
|
| 389 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:229 |
| 390 |
msgid "" |
| 391 |
"The next important entry point is the " |
| 392 |
":meth:`calibre.gui2.tweak_book.plugin.Tool.create_action`. This method " |
| 393 |
"creates the QAction objects that appear in the plugins toolbar and plugin " |
| 394 |
"menu. It also, optionally, assigns a keyboard shortcut that the user can " |
| 395 |
"customize. The triggered signal from the QAction is connected to the " |
| 396 |
"ask_user() method that asks the user for the font size multiplier, and then " |
| 397 |
"runs the magnification code." |
| 398 |
msgstr "" |
| 399 |
|
| 400 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:237 |
| 401 |
msgid "" |
| 402 |
"The magnification code is well commented and fairly simple. The main things " |
| 403 |
"to note are that you get a reference to the editor window as ``self.gui`` " |
| 404 |
"and the editor *Boss* as ``self.boss``. The *Boss* is the object that " |
| 405 |
"controls the editor user interface. It has many useful methods, that are " |
| 406 |
"documented in the :class:`calibre.gui2.tweak_book.boss.Boss` class." |
| 407 |
msgstr "" |
| 408 |
|
| 409 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:243 |
| 410 |
msgid "" |
| 411 |
"Finally, there is ``self.current_container`` which is a reference to the " |
| 412 |
"book being edited as a " |
| 413 |
":class:`calibre.ebooks.oeb.polish.container.Container` object. This " |
| 414 |
"represents the book as a collection of its constituent HTML/CSS/image files " |
| 415 |
"and has convenience methods for doing many useful things. The container " |
| 416 |
"object and various useful utility functions that can be reused in your " |
| 417 |
"plugin code are documented in :ref:`polish_api`." |
| 418 |
msgstr "" |
| 419 |
|
| 420 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:252 |
| 421 |
msgid "Running User Interface plugins in a separate process" |
| 422 |
msgstr "" |
| 423 |
|
| 424 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:254 |
| 425 |
msgid "" |
| 426 |
"If you are writing a user interface plugin that needs to make use of Qt " |
| 427 |
"WebEngine, it cannot be run in the main calibre process as it is not " |
| 428 |
"possible to use WebEngine there. Instead you can copy the data your plugin " |
| 429 |
"needs to a temporary folder and run the plugin with that data in a separate " |
| 430 |
"process. A simple example plugin follows that shows how to do this." |
| 431 |
msgstr "" |
| 432 |
|
| 433 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:261 |
| 434 |
msgid "" |
| 435 |
"You can download the plugin from :download_file:`webengine_demo_plugin.zip`." |
| 436 |
msgstr "" |
| 437 |
|
| 438 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:264 |
| 439 |
msgid "The important part of the plugin is in two functions:" |
| 440 |
msgstr "" |
| 441 |
|
| 442 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:273 |
| 443 |
msgid "" |
| 444 |
"The ``show_demo()`` function asks the user for a URL and then runs the " |
| 445 |
"``main()`` function passing it that URL. The ``main()`` function displays " |
| 446 |
"the URL in a ``QWebEngineView``." |
| 447 |
msgstr "" |
| 448 |
|
| 449 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:279 |
| 450 |
msgid "Adding translations to your plugin" |
| 451 |
msgstr "" |
| 452 |
|
| 453 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:281 |
| 454 |
msgid "" |
| 455 |
"You can have all the user interface strings in your plugin translated and " |
| 456 |
"displayed in whatever language is set for the main calibre user interface." |
| 457 |
msgstr "" |
| 458 |
|
| 459 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:284 |
| 460 |
msgid "" |
| 461 |
"The first step is to go through your plugin's source code and mark all user " |
| 462 |
"visible strings as translatable, by surrounding them in _(). For example::" |
| 463 |
msgstr "" |
| 464 |
|
| 465 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:289 |
| 466 |
msgid "" |
| 467 |
"Then use some program to generate .po files from your plugin source code. " |
| 468 |
"There should be one .po file for every language you want to translate into. " |
| 469 |
"For example: de.po for German, fr.po for French and so on. You can use the " |
| 470 |
"`Poedit <https://poedit.net/>`_ program for this." |
| 471 |
msgstr "" |
| 472 |
|
| 473 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:294 |
| 474 |
msgid "" |
| 475 |
"Send these .po files to your translators. Once you get them back, compile " |
| 476 |
"them into .mo files. You can again use Poedit for that, or just do::" |
| 477 |
msgstr "" |
| 478 |
|
| 479 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:299 |
| 480 |
msgid "Put the .mo files into the ``translations`` folder in your plugin." |
| 481 |
msgstr "" |
| 482 |
|
| 483 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:301 |
| 484 |
msgid "" |
| 485 |
"The last step is to simply call the function `load_translations()` at the " |
| 486 |
"top of your plugin's .py files. For performance reasons you should only call" |
| 487 |
" this function in those .py files that actually have translatable strings. " |
| 488 |
"So in a typical User Interface plugin you would call it at the top of " |
| 489 |
"``ui.py`` but not ``__init__.py``." |
| 490 |
msgstr "" |
| 491 |
|
| 492 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:307 |
| 493 |
msgid "" |
| 494 |
"You can test the translations of your plugins by changing the user interface" |
| 495 |
" language in calibre under :guilabel:`Preferences->Interface->Look & feel` " |
| 496 |
"or by running calibre like this::" |
| 497 |
msgstr "" |
| 498 |
|
| 499 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:313 |
| 500 |
msgid "" |
| 501 |
"Replace ``de`` with the language code of the language you want to test." |
| 502 |
msgstr "" |
| 503 |
|
| 504 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:316 |
| 505 |
msgid "The plugin API" |
| 506 |
msgstr "" |
| 507 |
|
| 508 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:318 |
| 509 |
msgid "" |
| 510 |
"As you may have noticed above, a plugin in calibre is a class. There are " |
| 511 |
"different classes for the different types of plugins in calibre. Details on " |
| 512 |
"each class, including the base class of all plugins can be found in " |
| 513 |
":ref:`plugins`." |
| 514 |
msgstr "" |
| 515 |
|
| 516 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:321 |
| 517 |
msgid "" |
| 518 |
"Your plugin is almost certainly going to use code from calibre. To learn how" |
| 519 |
" to find various bits of functionality in the calibre code base, read the " |
| 520 |
"section on the calibre :ref:`code_layout`." |
| 521 |
msgstr "" |
| 522 |
|
| 523 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:326 |
| 524 |
msgid "Debugging plugins" |
| 525 |
msgstr "" |
| 526 |
|
| 527 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:328 |
| 528 |
msgid "" |
| 529 |
"The first, most important step is to run calibre in debug mode. You can do " |
| 530 |
"this from the command line with::" |
| 531 |
msgstr "" |
| 532 |
|
| 533 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:332 |
| 534 |
msgid "" |
| 535 |
"Or from within calibre by right-clicking the :guilabel:`Preferences` button " |
| 536 |
"or using the :kbd:`Ctrl+Shift+R` keyboard shortcut." |
| 537 |
msgstr "" |
| 538 |
|
| 539 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:334 |
| 540 |
msgid "" |
| 541 |
"When running from the command line, debug output will be printed to the " |
| 542 |
"console, when running from within calibre the output will go to a txt file." |
| 543 |
msgstr "" |
| 544 |
|
| 545 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:336 |
| 546 |
msgid "" |
| 547 |
"You can insert print statements anywhere in your plugin code, they will be " |
| 548 |
"output in debug mode. Remember, this is Python, you really shouldn't need " |
| 549 |
"anything more than print statements to debug ;) I developed all of calibre " |
| 550 |
"using just this debugging technique." |
| 551 |
msgstr "" |
| 552 |
|
| 553 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:338 |
| 554 |
msgid "" |
| 555 |
"You can quickly test changes to your plugin by using the following command " |
| 556 |
"line::" |
| 557 |
msgstr "" |
| 558 |
|
| 559 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:343 |
| 560 |
msgid "" |
| 561 |
"This will shutdown a running calibre, wait for the shutdown to complete, " |
| 562 |
"then update your plugin in calibre and relaunch calibre." |
| 563 |
msgstr "" |
| 564 |
|
| 565 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:346 |
| 566 |
msgid "More plugin examples" |
| 567 |
msgstr "" |
| 568 |
|
| 569 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:348 |
| 570 |
msgid "" |
| 571 |
"You can find a list of many sophisticated calibre plugins `here " |
| 572 |
"<https://www.mobileread.com/forums/showthread.php?t=118764>`_." |
| 573 |
msgstr "" |
| 574 |
|
| 575 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:351 |
| 576 |
msgid "Sharing your plugins with others" |
| 577 |
msgstr "" |
| 578 |
|
| 579 |
#: ../../__w/calibre/calibre/manual/creating_plugins.rst:353 |
| 580 |
msgid "" |
| 581 |
"If you would like to share the plugins you have created with other users of " |
| 582 |
"calibre, post your plugin in a new thread in the `calibre plugins forum " |
| 583 |
"<https://www.mobileread.com/forums/forumdisplay.php?f=237>`_." |
| 584 |
msgstr "" |