| 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 |
# Anders Jonsson <[email protected]>, 2022 |
| 7 |
# efef6ec5b435a041fce803c7f8af77d2_2341d43, 2018,2020 |
| 8 |
# efef6ec5b435a041fce803c7f8af77d2_2341d43, 2020 |
| 9 |
# Jonatan Nyberg, 2026 |
| 10 |
# Jonatan Nyberg, 2016-2017,2021-2026 |
| 11 |
# Jonatan Nyberg, 2018-2021 |
| 12 |
# efef6ec5b435a041fce803c7f8af77d2_2341d43, 2018 |
| 13 |
# Jonatan Nyberg, 2026 |
| 14 |
# Merarom <[email protected]>, 2014-2015,2017 |
| 15 |
msgid "" |
| 16 |
msgstr "" |
| 17 |
"Project-Id-Version: calibre\n" |
| 18 |
"Report-Msgid-Bugs-To: \n" |
| 19 |
"POT-Creation-Date: 2026-09-16 15:05+0000\n" |
| 20 |
"PO-Revision-Date: 2014-06-17 08:35+0000\n" |
| 21 |
"Last-Translator: Jonatan Nyberg, 2026\n" |
| 22 |
"Language-Team: Swedish (http://app.transifex.com/calibre/calibre/language/sv/)\n" |
| 23 |
"MIME-Version: 1.0\n" |
| 24 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 25 |
"Content-Transfer-Encoding: 8bit\n" |
| 26 |
"Language: sv\n" |
| 27 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
| 28 |
|
| 29 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:4 |
| 30 |
msgid "Writing your own plugins to extend calibre's functionality" |
| 31 |
msgstr "Skriv egna insticksmoduler för att utöka calibres funktioner" |
| 32 |
|
| 33 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:6 |
| 34 |
msgid "" |
| 35 |
"calibre has a very modular design. Almost all functionality in calibre comes" |
| 36 |
" in the form of plugins. Plugins are used for conversion, for downloading " |
| 37 |
"news (though these are called recipes), for various components of the user " |
| 38 |
"interface, to connect to different devices, to process files when adding " |
| 39 |
"them to calibre and so on. You can get a complete list of all the built-in " |
| 40 |
"plugins in calibre by going to :guilabel:`Preferences->Advanced->Plugins`." |
| 41 |
msgstr "calibre är modulärt uppbyggt. Nästan alla funktioner i calibre finns i form av insticksmoduler. Insticksmoduler används för konvertering, för hämtning av nyheter (även om dessa kallas recept), för olika delar av användargränssnittet, för anslutning till olika enheter, för bearbetning av filer när de läggs till i calibre och så vidare. Du kan få en komplett lista över alla inbyggda insticksmoduler i calibre genom att gå till :guilabel:`Inställningar->Avancerat->Insticksmoduler`." |
| 42 |
|
| 43 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:8 |
| 44 |
msgid "" |
| 45 |
"Here, we will teach you how to create your own plugins to add new features " |
| 46 |
"to calibre." |
| 47 |
msgstr "Här kommer vi att lära dig att skapa dina egna insticksmoduler för att lägga till nya funktioner i calibre." |
| 48 |
|
| 49 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:13 |
| 50 |
msgid "Contents" |
| 51 |
msgstr "Innehåll" |
| 52 |
|
| 53 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:15 |
| 54 |
msgid "This only applies to calibre releases >= 0.8.60" |
| 55 |
msgstr "Detta gäller bara calibre-utgåvor >= 0.8.60" |
| 56 |
|
| 57 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:18 |
| 58 |
msgid "Anatomy of a calibre plugin" |
| 59 |
msgstr "Så är en calibre-insticksmodul uppbyggd" |
| 60 |
|
| 61 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:20 |
| 62 |
msgid "" |
| 63 |
"A calibre plugin is very simple, it's just a ZIP file that contains some " |
| 64 |
"Python code and any other resources like image files needed by the plugin. " |
| 65 |
"Without further ado, let's see a basic example." |
| 66 |
msgstr "En calibre-insticksmodul är mycket enkel: en ZIP-fil som innehåller Python-kod och andra resurser som insticksmodulen behöver, såsom bildfiler. Låt oss titta på ett grundläggande exempel." |
| 67 |
|
| 68 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:24 |
| 69 |
msgid "" |
| 70 |
"Suppose you have an installation of calibre that you are using to self " |
| 71 |
"publish various e-documents in EPUB and MOBI formats. You would like all " |
| 72 |
"files generated by calibre to have their publisher set as \"Hello world\", " |
| 73 |
"here's how to do it. Create a file named :file:`__init__.py` (this is a " |
| 74 |
"special name and must always be used for the main file of your plugin) and " |
| 75 |
"enter the following Python code into it:" |
| 76 |
msgstr "Anta att du har en installation av calibre som du använder för att själv publicera olika e-dokument i EPUB- och MOBI-format. Du vill att alla filer som calibre skapar ska ha utgivaren inställd på \"Hello world\". Så här gör du: skapa en fil med namnet :file:`__init__.py` (detta är ett särskilt namn som alltid måste användas för insticksmodulens huvudfil) och skriv följande Python-kod i den:" |
| 77 |
|
| 78 |
#: ../../../__w/calibre/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 folder in which you created :file:`__init__.py`::" |
| 82 |
msgstr "Det är allt. För att lägga till den här koden i calibre som en insticksmodul, kör helt enkelt följande i mappen där du skapade :file:`__init__.py`::" |
| 83 |
|
| 84 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:38 |
| 85 |
msgid "" |
| 86 |
"On macOS, the command line tools are inside the calibre bundle, for example," |
| 87 |
" if you installed calibre in :file:`/Applications` the command line tools " |
| 88 |
"are in :file:`/Applications/calibre.app/Contents/MacOS/`." |
| 89 |
msgstr "I macOS finns kommandoradsverktygen inuti calibre-paketet. Om du till exempel har installerat calibre i :file:`/Applications`, finns kommandoradsverktygen i :file:`/Applications/calibre.app/Contents/MacOS/`." |
| 90 |
|
| 91 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:42 |
| 92 |
msgid "" |
| 93 |
"You can download the Hello World plugin from " |
| 94 |
":download_file:`helloworld_plugin.zip`." |
| 95 |
msgstr "Du kan hämta insticksmodulen Hello World från :download_file:`helloworld_plugin.zip`." |
| 96 |
|
| 97 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:45 |
| 98 |
msgid "" |
| 99 |
"Every time you use calibre to convert a book, the plugin's :meth:`run` " |
| 100 |
"method will be called and the converted book will have its publisher set to " |
| 101 |
"\"Hello World\". This is a trivial plugin, let's move on to a more complex " |
| 102 |
"example that actually adds a component to the user interface." |
| 103 |
msgstr "Varje gång du använder calibre för att konvertera en bok anropas insticksmodulens :meth:`run`-metod, och den konverterade boken får utgivaren inställd på \"Hello World\". Detta är en mycket enkel insticksmodul. Låt oss gå vidare till ett mer komplext exempel som lägger till en komponent i användargränssnittet." |
| 104 |
|
| 105 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:50 |
| 106 |
msgid "A User Interface plugin" |
| 107 |
msgstr "En insticksmodul för användargränssnittet" |
| 108 |
|
| 109 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:52 |
| 110 |
msgid "" |
| 111 |
"This plugin will be spread over a few files (to keep the code clean). It " |
| 112 |
"will show you how to get resources (images or data files) from the plugin " |
| 113 |
"ZIP file, allow users to configure your plugin, how to create elements in " |
| 114 |
"the calibre user interface and how to access and query the books database in" |
| 115 |
" calibre." |
| 116 |
msgstr "Denna insticksmodul fördelas över några filer (för att hålla koden lättöverskådlig). Den visar hur du hämtar resurser (bilder eller datafiler) från insticksmodulens ZIP-fil, låter användare anpassa insticksmodulen, skapar element i calibres användargränssnitt samt får åtkomst till och söker i calibres bokdatabas." |
| 117 |
|
| 118 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:57 |
| 119 |
msgid "" |
| 120 |
"You can download this plugin from :download_file:`interface_demo_plugin.zip`" |
| 121 |
msgstr "Du kan hämta denna insticksmodul från :download_file:`interface_demo_plugin.zip`" |
| 122 |
|
| 123 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:61 |
| 124 |
msgid "" |
| 125 |
"The first thing to note is that this ZIP file has a lot more files in it, " |
| 126 |
"explained below, pay particular attention to ``plugin-import-name-" |
| 127 |
"interface_demo.txt``." |
| 128 |
msgstr "Observera först att denna ZIP-fil innehåller många fler filer, som förklaras nedan. Lägg särskilt märke till ``plugin-import-name-interface_demo.txt``." |
| 129 |
|
| 130 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:64 |
| 131 |
msgid "**plugin-import-name-interface_demo.txt**" |
| 132 |
msgstr "**plugin-import-name-interface_demo.txt**" |
| 133 |
|
| 134 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:65 |
| 135 |
msgid "" |
| 136 |
"An empty text file used to enable the multi-file plugin magic. This file " |
| 137 |
"must be present in all plugins that use more than one .py file. It should be" |
| 138 |
" empty and its filename must be of the form: ``plugin-import-" |
| 139 |
"name-**some_name**.txt``. The presence of this file allows you to import " |
| 140 |
"code from the .py files present inside the ZIP file, using a statement " |
| 141 |
"like::" |
| 142 |
msgstr "En tom textfil som används för att aktivera insticksmodulsmagin för flera filer. Den här filen måste finnas i alla insticksmoduler som använder mer än en .py-fil. Den ska vara tom och filnamnet måste ha formen: ``plugin-import-name-**some_name**.txt``. Förekomsten av den här filen låter dig importera kod från .py-filerna som finns i ZIP-filen med en sats som::" |
| 143 |
|
| 144 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:71 |
| 145 |
msgid "" |
| 146 |
"The prefix ``calibre_plugins`` must always be present. ``some_name`` comes " |
| 147 |
"from the filename of the empty text file. ``some_module`` refers to " |
| 148 |
":file:`some_module.py` file inside the ZIP file. Note that this importing is" |
| 149 |
" just as powerful as regular Python imports. You can create packages and " |
| 150 |
"subpackages of .py modules inside the ZIP file, just like you would normally" |
| 151 |
" (by defining __init__.py in each sub-folder), and everything should \"just " |
| 152 |
"work\"." |
| 153 |
msgstr "Prefixet ``calibre_plugins`` måste alltid finnas. ``some_name`` kommer från filnamnet på den tomma textfilen. ``some_module`` refererar till :file:`some_module.py`-filen inuti ZIP-filen. Observera att denna import är lika kraftfull som vanlig Python-import. Du kan skapa paket och underpaket av .py-moduler inuti ZIP-filen, precis som du normalt skulle göra (genom att definiera __init__.py i varje undermapp), och allt borde \"bara fungera\"." |
| 154 |
|
| 155 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:76 |
| 156 |
msgid "" |
| 157 |
"The name you use for ``some_name`` enters a global namespace shared by all " |
| 158 |
"plugins, **so make it as unique as possible**. But remember that it must be " |
| 159 |
"a valid Python identifier (only alphabets, numbers and the underscore)." |
| 160 |
msgstr "Namnet du använder för ``some_name`` ingår i en global namnrymd som delas av alla insticksmoduler, **så gör det så unikt som möjligt**. Kom dock ihåg att det måste vara en giltig Python-identifierare (endast bokstäver, siffror och understreck)." |
| 161 |
|
| 162 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:79 |
| 163 |
msgid "**__init__.py**" |
| 164 |
msgstr "**__init__.py**" |
| 165 |
|
| 166 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:80 |
| 167 |
msgid "As before, the file that defines the plugin class" |
| 168 |
msgstr "Som tidigare, filen som definierar insticksmodulsklassen" |
| 169 |
|
| 170 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:82 |
| 171 |
msgid "**main.py**" |
| 172 |
msgstr "**main.py**" |
| 173 |
|
| 174 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:83 |
| 175 |
msgid "This file contains the actual code that does something useful" |
| 176 |
msgstr "Den här filen innehåller den faktiska koden som gör något användbart" |
| 177 |
|
| 178 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:85 |
| 179 |
msgid "**ui.py**" |
| 180 |
msgstr "**ui.py**" |
| 181 |
|
| 182 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:86 |
| 183 |
msgid "This file defines the interface part of the plugin" |
| 184 |
msgstr "Denna fil definierar gränssnittsdelen av insticksmodulen" |
| 185 |
|
| 186 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:88 |
| 187 |
msgid "**images/icon.png**" |
| 188 |
msgstr "**images/icon.png**" |
| 189 |
|
| 190 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:89 |
| 191 |
msgid "The icon for this plugin" |
| 192 |
msgstr "Ikonen för denna insticksmodul" |
| 193 |
|
| 194 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:91 |
| 195 |
msgid "**about.txt**" |
| 196 |
msgstr "**about.txt**" |
| 197 |
|
| 198 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:92 |
| 199 |
msgid "A text file with information about the plugin" |
| 200 |
msgstr "En textfil med information om insticksmodulen" |
| 201 |
|
| 202 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:94 |
| 203 |
msgid "**translations**" |
| 204 |
msgstr "**translations**" |
| 205 |
|
| 206 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:95 |
| 207 |
msgid "" |
| 208 |
"A folder containing .mo files with the translations of the user interface of" |
| 209 |
" your plugin into different languages. See below for details." |
| 210 |
msgstr "En mapp som innehåller .mo-filer med översättningar av insticksmodulens användargränssnitt till olika språk. Se nedan för detaljer." |
| 211 |
|
| 212 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:99 |
| 213 |
msgid "Now let's look at the code." |
| 214 |
msgstr "Låt oss nu titta på koden." |
| 215 |
|
| 216 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:102 |
| 217 |
msgid "__init__.py" |
| 218 |
msgstr "__init__.py" |
| 219 |
|
| 220 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:104 |
| 221 |
msgid "First, the obligatory ``__init__.py`` to define the plugin metadata:" |
| 222 |
msgstr "Först den obligatoriska filen ``__init__.py``, som definierar insticksmodulens metadata:" |
| 223 |
|
| 224 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:109 |
| 225 |
msgid "" |
| 226 |
"The only noteworthy feature is the field :attr:`actual_plugin`. Since " |
| 227 |
"calibre has both command line and GUI interfaces, GUI plugins like this one " |
| 228 |
"should not load any GUI libraries in __init__.py. The actual_plugin field " |
| 229 |
"does this for you, by telling calibre that the actual plugin is to be found " |
| 230 |
"in another file inside your ZIP archive, which will only be loaded in a GUI " |
| 231 |
"context." |
| 232 |
msgstr "Den enda anmärkningsvärda funktionen är fältet :attr:`actual_plugin`. Eftersom calibre har både ett kommandoradsgränssnitt och ett grafiskt gränssnitt bör GUI-insticksmoduler som denna inte läsa in några GUI-bibliotek i __init__.py. Fältet actual_plugin hanterar detta genom att tala om för calibre att den egentliga insticksmodulen finns i en annan fil i ZIP-arkivet. Den filen läses endast in i ett GUI-sammanhang." |
| 233 |
|
| 234 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:114 |
| 235 |
msgid "" |
| 236 |
"Remember that for this to work, you must have a plugin-import-name-" |
| 237 |
"some_name.txt file in your plugin ZIP file, as discussed above." |
| 238 |
msgstr "Kom ihåg att du måste ha en fil med namnet plugin-import-name-some_name.txt i insticksmodulens ZIP-fil för att detta ska fungera, som beskrivits ovan." |
| 239 |
|
| 240 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:117 |
| 241 |
msgid "" |
| 242 |
"Also there are a couple of methods for enabling user configuration of the " |
| 243 |
"plugin. These are discussed below." |
| 244 |
msgstr "Det finns också ett par metoder som låter användaren anpassa insticksmodulen. Dessa diskuteras nedan." |
| 245 |
|
| 246 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:120 |
| 247 |
msgid "ui.py" |
| 248 |
msgstr "ui.py" |
| 249 |
|
| 250 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:122 |
| 251 |
msgid "" |
| 252 |
"Now let's look at ui.py which defines the actual GUI plugin. The source code" |
| 253 |
" is heavily commented and should be self explanatory:" |
| 254 |
msgstr "Låt oss nu titta på ui.py, som definierar själva insticksmodulen för användargränssnittet. Källkoden är utförligt kommenterad och bör vara självförklarande:" |
| 255 |
|
| 256 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:128 |
| 257 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:220 |
| 258 |
msgid "main.py" |
| 259 |
msgstr "main.py" |
| 260 |
|
| 261 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:130 |
| 262 |
msgid "The actual logic to implement the Interface Plugin Demo dialog." |
| 263 |
msgstr "Den faktiska logiken som implementerar dialogrutan Interface Plugin Demo." |
| 264 |
|
| 265 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:136 |
| 266 |
msgid "Getting resources from the plugin ZIP file" |
| 267 |
msgstr "Få resurser från insticksmodulens ZIP-fil" |
| 268 |
|
| 269 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:138 |
| 270 |
msgid "" |
| 271 |
"calibre's plugin loading system defines a couple of built-in functions that " |
| 272 |
"allow you to conveniently get files from the plugin ZIP file." |
| 273 |
msgstr "calibres system för inläsning av insticksmoduler definierar ett par inbyggda funktioner som gör det enkelt att hämta filer från insticksmodulens ZIP-fil." |
| 274 |
|
| 275 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:140 |
| 276 |
msgid "**get_resources(name_or_list_of_names)**" |
| 277 |
msgstr "**get_resources(name_or_list_of_names)**" |
| 278 |
|
| 279 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:141 |
| 280 |
msgid "" |
| 281 |
"This function should be called with a list of paths to files inside the ZIP " |
| 282 |
"file. For example to access the file :file:`icon.png` in the folder images " |
| 283 |
"in the ZIP file, you would use: ``images/icon.png``. Always use a forward " |
| 284 |
"slash as the path separator, even on Windows. When you pass in a single " |
| 285 |
"name, the function will return the raw bytes of that file or None if the " |
| 286 |
"name was not found in the ZIP file. If you pass in more than one name then " |
| 287 |
"it returns a dictionary mapping the names to bytes. If a name is not found," |
| 288 |
" it will not be present in the returned dictionary." |
| 289 |
msgstr "Den här funktionen ska anropas med en lista över sökvägar till filer i ZIP-filen. För att till exempel komma åt filen :file:`icon.png` i mappen images i ZIP-filen använder du ``images/icon.png``. Använd alltid snedstreck som sökvägsavskiljare, även i Windows. Om du skickar in ett enda namn returnerar funktionen filens råa byte, eller None om namnet inte hittas i ZIP-filen. Om du skickar in mer än ett namn returnerar den en uppslagstabell som kopplar namnen till byte. Om ett namn inte hittas finns det inte med i den returnerade uppslagstabellen." |
| 290 |
|
| 291 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:150 |
| 292 |
msgid "**get_icons(name_or_list_of_names, plugin_name='')**" |
| 293 |
msgstr "**get_icons(name_or_list_of_names, plugin_name='')**" |
| 294 |
|
| 295 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:151 |
| 296 |
msgid "" |
| 297 |
"A wrapper for get_resources() that creates QIcon objects from the raw bytes " |
| 298 |
"returned by get_resources. If a name is not found in the ZIP file the " |
| 299 |
"corresponding QIcon will be null. In order to support icon theme-ing, pass " |
| 300 |
"in the human friendly name of your plugin as ``plugin_name``. If the user is" |
| 301 |
" using an icon theme with icons for your plugin, they will be loaded " |
| 302 |
"preferentially." |
| 303 |
msgstr "En omslutande funktion för get_resources() som skapar QIcon-objekt från de råa byte som get_resources returnerar. Om ett namn inte hittas i ZIP-filen blir motsvarande QIcon null. För att stödja ikonteman ska du skicka in insticksmodulens namn i läsbar form som ``plugin_name``. Om användaren använder ett ikontema med ikoner för din insticksmodul prioriteras dessa vid inläsningen." |
| 304 |
|
| 305 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:160 |
| 306 |
msgid "Enabling user configuration of your plugin" |
| 307 |
msgstr "Aktivera användarkonfiguration för din insticksmodul" |
| 308 |
|
| 309 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:162 |
| 310 |
msgid "" |
| 311 |
"To allow users to configure your plugin, you must define three methods in " |
| 312 |
"your base plugin class, **is_customizable**, **config_widget** and " |
| 313 |
"**save_settings** as shown below:" |
| 314 |
msgstr "För att låta användare anpassa din insticksmodul måste du definiera tre metoder i insticksmodulens basklass: **is_customizable**, **config_widget** och **save_settings**, enligt nedan:" |
| 315 |
|
| 316 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:173 |
| 317 |
msgid "" |
| 318 |
"calibre has many different ways to store configuration data (a legacy of its" |
| 319 |
" long history). The recommended way is to use the **JSONConfig** class, " |
| 320 |
"which stores your configuration information in a .json file." |
| 321 |
msgstr "calibre har många olika sätt att lagra konfigurationsdata (ett arv från dess långa historia). Det rekommenderade sättet är att använda klassen **JSONConfig**, som lagrar konfigurationsinformationen i en .json-fil." |
| 322 |
|
| 323 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:175 |
| 324 |
msgid "" |
| 325 |
"The code to manage configuration data in the demo plugin is in config.py:" |
| 326 |
msgstr "Koden för att hantera konfigurationsdata i demo-insticksmodulen finns i config.py:" |
| 327 |
|
| 328 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:180 |
| 329 |
msgid "" |
| 330 |
"The ``prefs`` object is now available throughout the plugin code by a " |
| 331 |
"simple::" |
| 332 |
msgstr "Objektet ``prefs`` är nu tillgängligt i hela insticksmodulens kod med en enkel sats::" |
| 333 |
|
| 334 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:185 |
| 335 |
msgid "You can see the ``prefs`` object being used in main.py:" |
| 336 |
msgstr "Du kan se hur objektet ``prefs`` används i main.py:" |
| 337 |
|
| 338 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:192 |
| 339 |
msgid "Edit book plugins" |
| 340 |
msgstr "Insticksmoduler för bokredigeraren" |
| 341 |
|
| 342 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:194 |
| 343 |
msgid "" |
| 344 |
"Now let's change gears for a bit and look at creating a plugin to add tools " |
| 345 |
"to the calibre book editor. The plugin is available here: " |
| 346 |
":download_file:`editor_demo_plugin.zip`." |
| 347 |
msgstr "Nu byter vi ämne en stund och tittar på hur du skapar en insticksmodul som lägger till verktyg i calibres bokredigerare. Insticksmodulen finns här: :download_file:`editor_demo_plugin.zip`." |
| 348 |
|
| 349 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:198 |
| 350 |
msgid "" |
| 351 |
"The first step, as for all plugins is to create the import name empty txt " |
| 352 |
"file, as described :ref:`above <import_name_txt>`. We shall name the file " |
| 353 |
"``plugin-import-name-editor_plugin_demo.txt``." |
| 354 |
msgstr "Precis som för alla insticksmoduler är det första steget att skapa den tomma textfilen som anger importnamnet, enligt beskrivningen :ref:`ovan <import_name_txt>`. Vi kallar filen ``plugin-import-name-editor_plugin_demo.txt``." |
| 355 |
|
| 356 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:202 |
| 357 |
msgid "" |
| 358 |
"Now we create the mandatory ``__init__.py`` file that contains metadata " |
| 359 |
"about the plugin -- its name, author, version, etc." |
| 360 |
msgstr "Nu skapar vi den obligatoriska filen ``__init__.py``, som innehåller metadata om insticksmodulen -- namn, upphovsperson, version osv." |
| 361 |
|
| 362 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:208 |
| 363 |
msgid "" |
| 364 |
"A single editor plugin can provide multiple tools each tool corresponds to a" |
| 365 |
" single button in the toolbar and entry in the :guilabel:`Plugins` menu in " |
| 366 |
"the editor. These can have sub-menus in case the tool has multiple related " |
| 367 |
"actions." |
| 368 |
msgstr "En enda insticksmodul för redigeraren kan tillhandahålla flera verktyg. Varje verktyg motsvarar en knapp i verktygsfältet och ett alternativ i redigerarens meny :guilabel:`Insticksmoduler`. Dessa kan ha undermenyer om verktyget har flera relaterade åtgärder." |
| 369 |
|
| 370 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:212 |
| 371 |
msgid "" |
| 372 |
"The tools must all be defined in the file ``main.py`` in your plugin. Every " |
| 373 |
"tool is a class that inherits from the " |
| 374 |
":class:`calibre.gui2.tweak_book.plugin.Tool` class. Let's look at " |
| 375 |
"``main.py`` from the demo plugin, the source code is heavily commented and " |
| 376 |
"should be self-explanatory. Read the API documents of the " |
| 377 |
":class:`calibre.gui2.tweak_book.plugin.Tool` class for more details." |
| 378 |
msgstr "Alla verktyg måste definieras i filen ``main.py`` i din insticksmodul. Varje verktyg är en klass som ärver från klassen :class:`calibre.gui2.tweak_book.plugin.Tool`. Låt oss titta på ``main.py`` från demoinsticksmodulen. Källkoden är utförligt kommenterad och bör vara självförklarande. Läs API-dokumentationen för klassen :class:`calibre.gui2.tweak_book.plugin.Tool` för mer information." |
| 379 |
|
| 380 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:222 |
| 381 |
msgid "" |
| 382 |
"Here we will see the definition of a single tool that will multiply all font" |
| 383 |
" sizes in the book by a number provided by the user. This tool demonstrates " |
| 384 |
"various important concepts that you will need in developing your own " |
| 385 |
"plugins, so you should read the (heavily commented) source code carefully." |
| 386 |
msgstr "Här definierar vi ett verktyg som multiplicerar alla teckensnittsstorlekar i boken med ett tal som användaren anger. Verktyget visar flera viktiga begrepp som du behöver när du utvecklar egna insticksmoduler, så läs den utförligt kommenterade källkoden noggrant." |
| 387 |
|
| 388 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:230 |
| 389 |
msgid "" |
| 390 |
"Let's break down ``main.py``. We see that it defines a single tool, named " |
| 391 |
"*Magnify fonts*. This tool will ask the user for a number and multiply all " |
| 392 |
"font sizes in the book by that number." |
| 393 |
msgstr "Låt oss gå igenom ``main.py``. Vi ser att filen definierar ett enda verktyg, med namnet *Magnify fonts*. Verktyget ber användaren om ett tal och multiplicerar alla teckensnittsstorlekar i boken med detta tal." |
| 394 |
|
| 395 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:234 |
| 396 |
msgid "" |
| 397 |
"The first important thing is the tool name which you must set to some " |
| 398 |
"relatively unique string as it will be used as the key for this tool." |
| 399 |
msgstr "Det första viktiga är verktygsnamnet som du måste ställa in till någon relativt unik sträng eftersom det kommer att användas som nyckel för detta verktyg." |
| 400 |
|
| 401 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:237 |
| 402 |
msgid "" |
| 403 |
"The next important entry point is the " |
| 404 |
":meth:`calibre.gui2.tweak_book.plugin.Tool.create_action`. This method " |
| 405 |
"creates the QAction objects that appear in the plugins toolbar and plugin " |
| 406 |
"menu. It also, optionally, assigns a keyboard shortcut that the user can " |
| 407 |
"customize. The triggered signal from the QAction is connected to the " |
| 408 |
"ask_user() method that asks the user for the font size multiplier, and then " |
| 409 |
"runs the magnification code." |
| 410 |
msgstr "Nästa viktiga ingångspunkt är :meth:`calibre.gui2.tweak_book.plugin.Tool.create_action`. Denna metod skapar de QAction-objekt som visas i verktygsfältet och menyn för insticksmoduler. Den kan också tilldela ett kortkommando som användaren kan anpassa. Signalen triggered från QAction kopplas till metoden ask_user(), som frågar användaren efter multiplikatorn för teckensnittsstorlekarna och sedan kör förstoringskoden." |
| 411 |
|
| 412 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:245 |
| 413 |
msgid "" |
| 414 |
"The magnification code is well commented and fairly simple. The main things " |
| 415 |
"to note are that you get a reference to the editor window as ``self.gui`` " |
| 416 |
"and the editor *Boss* as ``self.boss``. The *Boss* is the object that " |
| 417 |
"controls the editor user interface. It has many useful methods, that are " |
| 418 |
"documented in the :class:`calibre.gui2.tweak_book.boss.Boss` class." |
| 419 |
msgstr "Förstoringskoden är väl kommenterad och ganska enkel. Det viktigaste att observera är att du får en referens till redigeringsfönstret som ``self.gui`` och till redigerarens *Boss* som ``self.boss``. *Boss* är objektet som styr redigerarens användargränssnitt. Det har många användbara metoder, som dokumenteras i klassen :class:`calibre.gui2.tweak_book.boss.Boss`." |
| 420 |
|
| 421 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:251 |
| 422 |
msgid "" |
| 423 |
"Finally, there is ``self.current_container`` which is a reference to the " |
| 424 |
"book being edited as a " |
| 425 |
":class:`calibre.ebooks.oeb.polish.container.Container` object. This " |
| 426 |
"represents the book as a collection of its constituent HTML/CSS/image files " |
| 427 |
"and has convenience methods for doing many useful things. The container " |
| 428 |
"object and various useful utility functions that can be reused in your " |
| 429 |
"plugin code are documented in :ref:`polish_api`." |
| 430 |
msgstr "Slutligen finns ``self.current_container``, som är en referens till boken som redigeras i form av ett :class:`calibre.ebooks.oeb.polish.container.Container`-objekt. Det representerar boken som en samling av de HTML-, CSS- och bildfiler som ingår i den och har hjälpmetoder för många användbara uppgifter. Behållarobjektet och olika användbara hjälpfunktioner som du kan återanvända i insticksmodulens kod dokumenteras i :ref:`polish_api`." |
| 431 |
|
| 432 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:259 |
| 433 |
msgid "Adding translations to your plugin" |
| 434 |
msgstr "Lägga till översättningar i din insticksmodul" |
| 435 |
|
| 436 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:261 |
| 437 |
msgid "" |
| 438 |
"You can have all the user interface strings in your plugin translated and " |
| 439 |
"displayed in whatever language is set for the main calibre user interface." |
| 440 |
msgstr "Du kan översätta alla gränssnittstexter i insticksmodulen och visa dem på det språk som är inställt för calibres huvudsakliga användargränssnitt." |
| 441 |
|
| 442 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:264 |
| 443 |
msgid "" |
| 444 |
"The first step is to go through your plugin's source code and mark all user " |
| 445 |
"visible strings as translatable, by surrounding them in _(). For example::" |
| 446 |
msgstr "Det första steget är att gå igenom insticksmodulens källkod och markera alla strängar som användaren ser som översättningsbara genom att omge dem med _(). Till exempel::" |
| 447 |
|
| 448 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:269 |
| 449 |
msgid "" |
| 450 |
"Then use some program to generate .po files from your plugin source code. " |
| 451 |
"There should be one .po file for every language you want to translate into. " |
| 452 |
"For example: de.po for German, fr.po for French and so on. You can use the " |
| 453 |
"`Poedit <https://poedit.net/>`_ program for this." |
| 454 |
msgstr "Använd sedan något program för att skapa .po-filer från din insticksmodulskällkod. Det bör finnas en .po-fil för varje språk du vill översätta till. Till exempel: de.po för tyska, fr.po för franska och så vidare. Du kan använda programmet `Poedit <https://poedit.net/>`_ för detta." |
| 455 |
|
| 456 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:274 |
| 457 |
msgid "" |
| 458 |
"Send these .po files to your translators. Once you get them back, compile " |
| 459 |
"them into .mo files. You can again use Poedit for that, or just do::" |
| 460 |
msgstr "Skicka dessa .po-filer till dina översättare. När du får tillbaka dem kompilerar du dem till .mo-filer. Du kan använda Poedit även för detta, eller helt enkelt köra::" |
| 461 |
|
| 462 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:279 |
| 463 |
msgid "Put the .mo files into the ``translations`` folder in your plugin." |
| 464 |
msgstr "Placera .mo-filer i ``translations``-mappen i din insticksmodul." |
| 465 |
|
| 466 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:281 |
| 467 |
msgid "" |
| 468 |
"The last step is to simply call the function `load_translations()` at the " |
| 469 |
"top of your plugin's .py files. For performance reasons you should only call" |
| 470 |
" this function in those .py files that actually have translatable strings. " |
| 471 |
"So in a typical User Interface plugin you would call it at the top of " |
| 472 |
"``ui.py`` but not ``__init__.py``." |
| 473 |
msgstr "Det sista steget är att anropa funktionen `load_translations()` överst i insticksmodulens .py-filer. Av prestandaskäl bör du bara anropa funktionen i de .py-filer som faktiskt har översättningsbara strängar. I en typisk insticksmodul för användargränssnittet anropar du den alltså överst i ``ui.py`` men inte i ``__init__.py``." |
| 474 |
|
| 475 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:287 |
| 476 |
msgid "" |
| 477 |
"You can test the translations of your plugins by changing the user interface" |
| 478 |
" language in calibre under :guilabel:`Preferences->Interface->Look & feel` " |
| 479 |
"or by running calibre with the ``CALIBRE_OVERRIDE_LANG`` environment " |
| 480 |
"variable set. For example::" |
| 481 |
msgstr "Du kan testa översättningarna av dina insticksmoduler genom att ändra gränssnittsspråket i calibre under :guilabel:`Inställningar->Gränssnitt->Utseende & känsla` eller genom att köra calibre med miljövariabeln ``CALIBRE_OVERRIDE_LANG`` angiven. Till exempel::" |
| 482 |
|
| 483 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:293 |
| 484 |
msgid "" |
| 485 |
"Replace ``de`` with the language code of the language you want to test." |
| 486 |
msgstr "Ersätt ``de`` med språkkoden för det språk som du vill testa." |
| 487 |
|
| 488 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:295 |
| 489 |
msgid "" |
| 490 |
"For translations with plurals, use the ``ngettext()`` function instead of " |
| 491 |
"``_()``. For example::" |
| 492 |
msgstr "För översättningar med plural, använd funktionen ``ngettext()`` i stället för ``_()``. Till exempel::" |
| 493 |
|
| 494 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:301 |
| 495 |
msgid "The plugin API" |
| 496 |
msgstr "API för insticksmoduler" |
| 497 |
|
| 498 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:303 |
| 499 |
msgid "" |
| 500 |
"As you may have noticed above, a plugin in calibre is a class. There are " |
| 501 |
"different classes for the different types of plugins in calibre. Details on " |
| 502 |
"each class, including the base class of all plugins can be found in " |
| 503 |
":ref:`plugins`." |
| 504 |
msgstr "Som du kanske har märkt ovan är en insticksmodul i calibre en klass. Det finns olika klasser för de olika typerna av insticksmoduler i calibre. Information om varje klass, inklusive basklassen för alla insticksmoduler, finns i :ref:`plugins`." |
| 505 |
|
| 506 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:306 |
| 507 |
msgid "" |
| 508 |
"Your plugin is almost certainly going to use code from calibre. To learn how" |
| 509 |
" to find various bits of functionality in the calibre code base, read the " |
| 510 |
"section on the calibre :ref:`code_layout`." |
| 511 |
msgstr "Din insticksmodul kommer nästan säkert att använda kod från calibre. Läs avsnittet :ref:`code_layout` för att lära dig hur du hittar olika funktioner i calibres kodbas." |
| 512 |
|
| 513 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:311 |
| 514 |
msgid "Debugging plugins" |
| 515 |
msgstr "Felsöka insticksmoduler" |
| 516 |
|
| 517 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:313 |
| 518 |
msgid "" |
| 519 |
"The first, most important step is to run calibre in debug mode. You can do " |
| 520 |
"this from the command line with::" |
| 521 |
msgstr "Det första och viktigaste steget är att köra calibre i felsökningsläge. Du kan göra det från kommandoraden med::" |
| 522 |
|
| 523 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:317 |
| 524 |
msgid "" |
| 525 |
"Or from within calibre by right-clicking the :guilabel:`Preferences` button " |
| 526 |
"or using the :kbd:`Ctrl+Shift+R` keyboard shortcut." |
| 527 |
msgstr "Eller inifrån calibre genom att högerklicka på knappen :guilabel:`Inställningar` eller använda kortkommandot :kbd:`Ctrl+Skift+R`." |
| 528 |
|
| 529 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:319 |
| 530 |
msgid "" |
| 531 |
"When running from the command line, debug output will be printed to the " |
| 532 |
"console, when running from within calibre the output will go to a txt file." |
| 533 |
msgstr "När du kör från kommandoraden skrivs felsökningsutmatningen till konsolen. När du kör inifrån calibre skrivs den till en txt-fil." |
| 534 |
|
| 535 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:321 |
| 536 |
msgid "" |
| 537 |
"You can insert print statements anywhere in your plugin code, they will be " |
| 538 |
"output in debug mode. Remember, this is Python, you really shouldn't need " |
| 539 |
"anything more than print statements to debug ;) I developed all of calibre " |
| 540 |
"using just this debugging technique." |
| 541 |
msgstr "Du kan infoga print-satser var som helst i insticksmodulens kod. Deras utmatning visas i felsökningsläge. Kom ihåg att detta är Python: du borde inte behöva något mer än print-satser för att felsöka ;) Jag utvecklade hela calibre med just denna felsökningsteknik." |
| 542 |
|
| 543 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:323 |
| 544 |
msgid "" |
| 545 |
"You can quickly test changes to your plugin by using the following command " |
| 546 |
"line::" |
| 547 |
msgstr "Du kan snabbt testa ändringar i din insticksmodul med hjälp av följande kommandorad::" |
| 548 |
|
| 549 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:328 |
| 550 |
msgid "" |
| 551 |
"This will shutdown a running calibre, wait for the shutdown to complete, " |
| 552 |
"then update your plugin in calibre and relaunch calibre." |
| 553 |
msgstr "Detta stänger en körande instans av calibre, väntar tills den har avslutats, uppdaterar sedan insticksmodulen i calibre och startar calibre igen." |
| 554 |
|
| 555 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:331 |
| 556 |
msgid "More plugin examples" |
| 557 |
msgstr "Fler exempel på insticksmoduler" |
| 558 |
|
| 559 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:333 |
| 560 |
msgid "" |
| 561 |
"You can find a list of many sophisticated calibre plugins `here " |
| 562 |
"<https://www.mobileread.com/forums/showthread.php?t=118764>`_." |
| 563 |
msgstr "Du kan hitta en lista med många sofistikerade calibre-insticksmoduler `här <https://www.mobileread.com/forums/showthread.php?t=118764>`_." |
| 564 |
|
| 565 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:336 |
| 566 |
msgid "Sharing your plugins with others" |
| 567 |
msgstr "Dela dina insticksmoduler med andra" |
| 568 |
|
| 569 |
#: ../../../__w/calibre/calibre/manual/creating_plugins.rst:338 |
| 570 |
msgid "" |
| 571 |
"If you would like to share the plugins you have created with other users of " |
| 572 |
"calibre, post your plugin in a new thread in the `calibre plugins forum " |
| 573 |
"<https://www.mobileread.com/forums/forumdisplay.php?f=237>`_." |
| 574 |
msgstr "Om du vill dela insticksmoduler som du har skapat med andra calibre-användare, lägg upp din insticksmodul i en ny tråd på `calibres insticksmodulsforum <https://www.mobileread.com/forums/forumdisplay.php?f=237>`_." |