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