| 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: 2024-11-21 15:47+0000\n" |
| 11 |
"PO-Revision-Date: 2014-06-17 08:34+0000\n" |
| 12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 13 |
"Language-Team: English (Australia) (http://app.transifex.com/calibre/calibre/language/en_AU/)\n" |
| 14 |
"MIME-Version: 1.0\n" |
| 15 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 16 |
"Content-Transfer-Encoding: 8bit\n" |
| 17 |
"Language: en_AU\n" |
| 18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
| 19 |
|
| 20 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:4 |
| 21 |
msgid "The calibre template language" |
| 22 |
msgstr "The calibre template language" |
| 23 |
|
| 24 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:6 |
| 25 |
msgid "" |
| 26 |
"The calibre template language is a calibre-specific language used throughout" |
| 27 |
" calibre for tasks such as specifying file paths, formatting values, and " |
| 28 |
"computing the value for user-specified columns. Examples:" |
| 29 |
msgstr "" |
| 30 |
|
| 31 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:8 |
| 32 |
msgid "" |
| 33 |
"Specify the folder structure and file names when saving files from the " |
| 34 |
"calibre library to the disk or e-book reader." |
| 35 |
msgstr "" |
| 36 |
|
| 37 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:9 |
| 38 |
msgid "Define rules for adding icons and colors to the calibre book list." |
| 39 |
msgstr "" |
| 40 |
|
| 41 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:10 |
| 42 |
msgid "Define `virtual columns` that contain data from other columns." |
| 43 |
msgstr "" |
| 44 |
|
| 45 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:11 |
| 46 |
msgid "Advanced library searching." |
| 47 |
msgstr "" |
| 48 |
|
| 49 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:12 |
| 50 |
msgid "Advanced metadata search and replace." |
| 51 |
msgstr "" |
| 52 |
|
| 53 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:14 |
| 54 |
msgid "" |
| 55 |
"The language is built around the notion of a `template`, which specifies " |
| 56 |
"which book metadata to use, computations on that metadata, and how it is to " |
| 57 |
"be formatted." |
| 58 |
msgstr "" |
| 59 |
|
| 60 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:17 |
| 61 |
msgid "Basic templates" |
| 62 |
msgstr "" |
| 63 |
|
| 64 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:19 |
| 65 |
msgid "" |
| 66 |
"A basic template consists one or more ``template expressions``. A ``template" |
| 67 |
" expression`` consists of text and names in curly brackets (``{}``) that is " |
| 68 |
"replaced by the corresponding metadata from the book being processed. For " |
| 69 |
"example, the default template in calibre used for saving books to device has" |
| 70 |
" 4 ``template expressions``::" |
| 71 |
msgstr "" |
| 72 |
|
| 73 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:23 |
| 74 |
msgid "For the book \"The Foundation\" by \"Isaac Asimov\" the will become::" |
| 75 |
msgstr "" |
| 76 |
|
| 77 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:27 |
| 78 |
msgid "" |
| 79 |
"The slashes are not ``template expressions`` because they are in between in " |
| 80 |
"``{}``. Such text is left where it appears. For example, if the template " |
| 81 |
"is::" |
| 82 |
msgstr "" |
| 83 |
|
| 84 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:31 |
| 85 |
msgid "then for \"The Foundation\" the template produces::" |
| 86 |
msgstr "" |
| 87 |
|
| 88 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:35 |
| 89 |
msgid "" |
| 90 |
"A ``template expression`` can access all the metadata available in calibre, " |
| 91 |
"including custom columns (columns you create yourself), by using a column's " |
| 92 |
"``lookup name``. To find the lookup name for a `column` (sometimes called " |
| 93 |
"`fields`), hover your mouse over the column header in calibre's book list. " |
| 94 |
"Lookup names for custom columns always begin with ``#``. For series type " |
| 95 |
"columns there is an additional field named ``#lookup name_index`` that is " |
| 96 |
"the series index for that book in the series. For example, if you have a " |
| 97 |
"custom series column named ``#myseries``, there will also be a column named " |
| 98 |
"``#myseries_index``. The standard series column's index is named " |
| 99 |
"``series_index``." |
| 100 |
msgstr "" |
| 101 |
|
| 102 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:37 |
| 103 |
msgid "In addition to the standard column based fields, you also can use:" |
| 104 |
msgstr "" |
| 105 |
|
| 106 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:39 |
| 107 |
msgid "" |
| 108 |
"``{formats}`` - A list of formats available in the calibre library for a " |
| 109 |
"book" |
| 110 |
msgstr "" |
| 111 |
|
| 112 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:40 |
| 113 |
msgid "``{identifiers:select(isbn)}`` - The ISBN of the book" |
| 114 |
msgstr "" |
| 115 |
|
| 116 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:42 |
| 117 |
msgid "" |
| 118 |
"If the metadata for the field for a given book is not defined then the field" |
| 119 |
" in the template is replaced by the empty string (``''``). For example, " |
| 120 |
"consider the following template::" |
| 121 |
msgstr "" |
| 122 |
|
| 123 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:46 |
| 124 |
msgid "" |
| 125 |
"If Asimov's book \"Second Foundation\" is in the series \"Foundation\" then " |
| 126 |
"the template produces::" |
| 127 |
msgstr "" |
| 128 |
|
| 129 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:50 |
| 130 |
msgid "" |
| 131 |
"If a series has not been entered for the book then the template produces::" |
| 132 |
msgstr "" |
| 133 |
|
| 134 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:54 |
| 135 |
msgid "" |
| 136 |
"The template processor automatically removes multiple slashes and leading or" |
| 137 |
" trailing spaces." |
| 138 |
msgstr "" |
| 139 |
|
| 140 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:57 |
| 141 |
msgid "Advanced formatting" |
| 142 |
msgstr "" |
| 143 |
|
| 144 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:59 |
| 145 |
msgid "" |
| 146 |
"In addition to metadata substitution, templates can conditionally include " |
| 147 |
"additional text and control how substituted data is formatted." |
| 148 |
msgstr "" |
| 149 |
|
| 150 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:61 |
| 151 |
msgid "**Conditionally including text**" |
| 152 |
msgstr "" |
| 153 |
|
| 154 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:63 |
| 155 |
msgid "" |
| 156 |
"Sometimes you want text to appear in the output only if a field is not " |
| 157 |
"empty. A common case is ``series`` and ``series_index`` where you want " |
| 158 |
"either nothing or the two values separated by a hyphen. calibre handles this" |
| 159 |
" case using a special ``template expression`` syntax." |
| 160 |
msgstr "" |
| 161 |
|
| 162 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:65 |
| 163 |
msgid "" |
| 164 |
"For example and using the above Foundation example, assume you want the " |
| 165 |
"template to produce `Foundation - 3 - Second Foundation`. This template " |
| 166 |
"produces that output:" |
| 167 |
msgstr "" |
| 168 |
|
| 169 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:67 |
| 170 |
msgid "``{series} - {series_index} - {title}``" |
| 171 |
msgstr "" |
| 172 |
|
| 173 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:69 |
| 174 |
msgid "" |
| 175 |
"However, if a book has no series the template will produce `- - the title`, " |
| 176 |
"which is probably not what you want. Generally, people want the result be " |
| 177 |
"the title without the extraneous hyphens. You can accomplish this using the " |
| 178 |
"following template syntax:" |
| 179 |
msgstr "" |
| 180 |
|
| 181 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:71 |
| 182 |
msgid "``{field:|prefix_text|suffix_text}``" |
| 183 |
msgstr "" |
| 184 |
|
| 185 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:73 |
| 186 |
msgid "" |
| 187 |
"This ``template expression`` says that if ``field`` has the value `XXXX` " |
| 188 |
"then the result will be `prefix_textXXXXXsuffix_text`. If ``field`` is empty" |
| 189 |
" (has no value) then the result will be the empty string (nothing) because " |
| 190 |
"the prefix and suffix are ignored. The prefix and suffix can contain blanks." |
| 191 |
msgstr "" |
| 192 |
|
| 193 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:75 |
| 194 |
msgid "" |
| 195 |
"**Do not use subtemplates (`{ ... }`) or functions (see below) in the prefix" |
| 196 |
" or the suffix.**" |
| 197 |
msgstr "" |
| 198 |
|
| 199 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:77 |
| 200 |
msgid "" |
| 201 |
"Using this syntax, we can solve the above no-series problem with the " |
| 202 |
"template::" |
| 203 |
msgstr "" |
| 204 |
|
| 205 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:81 |
| 206 |
msgid "" |
| 207 |
"The hyphens will be included only if the book has a series index, which it " |
| 208 |
"has only if it has a series. Continuing the Foundation example again, the " |
| 209 |
"template will produce `Foundation - 1 - Second Foundation`." |
| 210 |
msgstr "" |
| 211 |
|
| 212 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:83 |
| 213 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:289 |
| 214 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:438 |
| 215 |
msgid "Notes:" |
| 216 |
msgstr "" |
| 217 |
|
| 218 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:85 |
| 219 |
msgid "" |
| 220 |
"You must include the colon after the ``lookup name`` if you are using a " |
| 221 |
"prefix or a suffix." |
| 222 |
msgstr "" |
| 223 |
|
| 224 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:86 |
| 225 |
msgid "" |
| 226 |
"You must either use either no or both ``|`` characters. Using one, as in " |
| 227 |
"``{field:| - }``, is not allowed." |
| 228 |
msgstr "" |
| 229 |
|
| 230 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:87 |
| 231 |
msgid "" |
| 232 |
"It is OK to provide no text for either the prefix or the suffix, such as in " |
| 233 |
"``{series:|| - }``. The template ``{title:||}`` is the same as ``{title}``." |
| 234 |
msgstr "" |
| 235 |
|
| 236 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:89 |
| 237 |
msgid "**Formatting**" |
| 238 |
msgstr "" |
| 239 |
|
| 240 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:91 |
| 241 |
msgid "" |
| 242 |
"Suppose you want the ``series_index`` to be formatted as three digits with " |
| 243 |
"leading zeros. This does the trick:" |
| 244 |
msgstr "" |
| 245 |
|
| 246 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:93 |
| 247 |
msgid "``{series_index:0>3s}`` - Three digits with leading zeros" |
| 248 |
msgstr "" |
| 249 |
|
| 250 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:95 |
| 251 |
msgid "For trailing zeros, use:" |
| 252 |
msgstr "" |
| 253 |
|
| 254 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:97 |
| 255 |
msgid "``{series_index:0<3s}`` - Three digits with trailing zeros" |
| 256 |
msgstr "" |
| 257 |
|
| 258 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:99 |
| 259 |
msgid "" |
| 260 |
"If you use series indices with fractional values, e.g., 1.1, you might want " |
| 261 |
"the decimal points to line up. For example, you might want the indices 1 and" |
| 262 |
" 2.5 to appear as 01.00 and 02.50 so that they will sort correctly on a " |
| 263 |
"device that does lexical sorting. To do this, use:" |
| 264 |
msgstr "" |
| 265 |
|
| 266 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:101 |
| 267 |
msgid "" |
| 268 |
"``{series_index:0>5.2f}`` - Five characters consisting of two digits with " |
| 269 |
"leading zeros, a decimal point, then 2 digits after the decimal point." |
| 270 |
msgstr "" |
| 271 |
|
| 272 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:103 |
| 273 |
msgid "If you want only the first two letters of the data, use:" |
| 274 |
msgstr "" |
| 275 |
|
| 276 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:105 |
| 277 |
msgid "" |
| 278 |
"``{author_sort:.2}`` - Only the first two letters of the author sort name" |
| 279 |
msgstr "" |
| 280 |
|
| 281 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:107 |
| 282 |
msgid "" |
| 283 |
"Much of the calibre template language formatting comes from Python. For more" |
| 284 |
" details on the syntax of these advanced formatting operations see the " |
| 285 |
"`Python documentation " |
| 286 |
"<https://docs.python.org/3/library/string.html#formatstrings>`_." |
| 287 |
msgstr "" |
| 288 |
|
| 289 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:111 |
| 290 |
msgid "Using templates to define custom columns" |
| 291 |
msgstr "" |
| 292 |
|
| 293 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:113 |
| 294 |
msgid "" |
| 295 |
"Templates can be used to display information that isn't in calibre metadata," |
| 296 |
" or to display metadata differently from calibre's normal format. For " |
| 297 |
"example, you might want to show the ``ISBN``, a field that calibre does not " |
| 298 |
"display. You can accomplish this creating a custom column with the type " |
| 299 |
"`Column built from other columns` (hereafter called `composite columns`) and" |
| 300 |
" providing a template to generate the displayed text. The column will " |
| 301 |
"display the result of evaluating the template. For example, to display the " |
| 302 |
"ISBN, create the column and enter ``{identifiers:select(isbn)}`` in the " |
| 303 |
"template box. To display a column containing the values of two series custom" |
| 304 |
" columns, separated by a comma, use ``{#series1:||,}{#series2}``." |
| 305 |
msgstr "" |
| 306 |
|
| 307 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:115 |
| 308 |
msgid "Composite columns can use any template option, including formatting." |
| 309 |
msgstr "" |
| 310 |
|
| 311 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:117 |
| 312 |
msgid "" |
| 313 |
"Note: You cannot edit the data displayed in a composite column. Instead you " |
| 314 |
"edit the source columns. If you edit a composite column, for example by " |
| 315 |
"double-clicking it, calibre will open the template for editing, not the " |
| 316 |
"underlying data." |
| 317 |
msgstr "" |
| 318 |
|
| 319 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:121 |
| 320 |
msgid "Templates and plugboards" |
| 321 |
msgstr "" |
| 322 |
|
| 323 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:123 |
| 324 |
msgid "" |
| 325 |
"Plugboards are used for changing the metadata written into books during " |
| 326 |
"send-to-device and save-to-disk operations. A plugboard permits you to " |
| 327 |
"specify a template to provide the data to write into the book's metadata. " |
| 328 |
"You can use plugboards to modify the following fields: authors, author_sort," |
| 329 |
" language, publisher, tags, title, title_sort. This feature helps people who" |
| 330 |
" want to use different metadata in books on devices to solve sorting or " |
| 331 |
"display issues." |
| 332 |
msgstr "" |
| 333 |
|
| 334 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:125 |
| 335 |
msgid "" |
| 336 |
"When you create a plugboard, you specify the format and device for which the" |
| 337 |
" plugboard is to be used. A special device is provided, ``save_to_disk``, " |
| 338 |
"that is used when saving formats (as opposed to sending them to a device). " |
| 339 |
"Once you have chosen the format and device, you choose the metadata fields " |
| 340 |
"to change, providing templates to supply the new values. These templates are" |
| 341 |
" `connected` to their destination fields, hence the name `plugboards`. You " |
| 342 |
"can of course use composite columns in these templates." |
| 343 |
msgstr "" |
| 344 |
|
| 345 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:127 |
| 346 |
msgid "" |
| 347 |
"Plugboards are quite flexible and can be written in Single Function Mode, " |
| 348 |
"Template Program Mode, General Program Mode, or Python Template mode." |
| 349 |
msgstr "" |
| 350 |
|
| 351 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:129 |
| 352 |
msgid "" |
| 353 |
"When a plugboard might apply (Content server, save to disk, or send to " |
| 354 |
"device), calibre searches the defined plugboards to choose the correct one " |
| 355 |
"for the given format and device. For example, to find the appropriate " |
| 356 |
"plugboard for an EPUB book being sent to an ANDROID device, calibre searches" |
| 357 |
" the plugboards using the following search order:" |
| 358 |
msgstr "" |
| 359 |
|
| 360 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:133 |
| 361 |
msgid "" |
| 362 |
"a plugboard with an exact match on format and device, e.g., ``EPUB`` and " |
| 363 |
"``ANDROID``" |
| 364 |
msgstr "" |
| 365 |
|
| 366 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:134 |
| 367 |
msgid "" |
| 368 |
"a plugboard with an exact match on format and the special ``any device`` " |
| 369 |
"choice, e.g., ``EPUB`` and ``any device``" |
| 370 |
msgstr "" |
| 371 |
|
| 372 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:135 |
| 373 |
msgid "" |
| 374 |
"a plugboard with the special ``any format`` choice and an exact match on " |
| 375 |
"device, e.g., ``any format`` and ``ANDROID``" |
| 376 |
msgstr "" |
| 377 |
|
| 378 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:136 |
| 379 |
msgid "a plugboard with ``any format`` and ``any device``" |
| 380 |
msgstr "" |
| 381 |
|
| 382 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:138 |
| 383 |
msgid "" |
| 384 |
"The tags and authors fields have special treatment, because both of these " |
| 385 |
"fields can hold more than one item. A book can have many tags and many " |
| 386 |
"authors. When you specify that one of these two fields is to be changed, the" |
| 387 |
" template's result is examined to see if more than one item is there. For " |
| 388 |
"tags, the result is cut apart wherever calibre finds a comma. For example, " |
| 389 |
"if the template produces the value ``Thriller, Horror``, then the result " |
| 390 |
"will be two tags, ``Thriller`` and ``Horror``. There is no way to put a " |
| 391 |
"comma in the middle of a tag." |
| 392 |
msgstr "" |
| 393 |
|
| 394 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:141 |
| 395 |
msgid "" |
| 396 |
"The same thing happens for authors, but using a different character for the " |
| 397 |
"cut, a `&` (ampersand) instead of a comma. For example, if the template " |
| 398 |
"produces the value ``Blogs, Joe&Posts, Susan``, then the book will end up " |
| 399 |
"with two authors, ``Blogs, Joe`` and ``Posts, Susan``. If the template " |
| 400 |
"produces the value ``Blogs, Joe;Posts, Susan``, then the book will have one " |
| 401 |
"author with a rather strange name." |
| 402 |
msgstr "" |
| 403 |
|
| 404 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:143 |
| 405 |
msgid "" |
| 406 |
"Plugboards affect the metadata written into the book when it is saved to " |
| 407 |
"disk or written to the device. Plugboards do not affect the metadata used by" |
| 408 |
" ``save to disk`` and ``send to device`` to create the file names. Instead, " |
| 409 |
"file names are constructed using the templates entered on the appropriate " |
| 410 |
"preferences window." |
| 411 |
msgstr "" |
| 412 |
|
| 413 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:148 |
| 414 |
msgid "Using functions in templates - Single Function Mode" |
| 415 |
msgstr "" |
| 416 |
|
| 417 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:150 |
| 418 |
msgid "" |
| 419 |
"Suppose you want to display the value of a field in upper case when that " |
| 420 |
"field is normally in title case. You can do this using `template functions`." |
| 421 |
" For example, to display the title in upper case use the ``uppercase`` " |
| 422 |
"function, as in ``{title:uppercase()}``. To display it in title case, use " |
| 423 |
"``{title:titlecase()}``." |
| 424 |
msgstr "" |
| 425 |
|
| 426 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:152 |
| 427 |
msgid "" |
| 428 |
"Functions go into the format part of the template, after the ``:`` and " |
| 429 |
"before the first ``|`` or the closing ``}`` if no prefix/suffix is used. If " |
| 430 |
"you have both a format and a function reference, the function comes after a " |
| 431 |
"second ``:``. Functions return the value of the column specified in the " |
| 432 |
"template, suitably modified." |
| 433 |
msgstr "" |
| 434 |
|
| 435 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:154 |
| 436 |
msgid "The syntax for using functions is one of::" |
| 437 |
msgstr "" |
| 438 |
|
| 439 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:161 |
| 440 |
msgid "" |
| 441 |
"Function names must always be followed by opening and closing parentheses. " |
| 442 |
"Some functions require extra values (arguments), and these go inside the " |
| 443 |
"parentheses. Arguments are separated by commas. Literal commas (commas as " |
| 444 |
"text, not argument separators) must be preceded by a backslash (``\\``) . " |
| 445 |
"The last (or only) argument cannot contain a textual closing parenthesis." |
| 446 |
msgstr "" |
| 447 |
|
| 448 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:163 |
| 449 |
msgid "" |
| 450 |
"Functions are evaluated before format specifications and the prefix/suffix. " |
| 451 |
"See further down for an example of using both a format and a function." |
| 452 |
msgstr "" |
| 453 |
|
| 454 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:165 |
| 455 |
msgid "" |
| 456 |
"**Important**: If you have programming experience, please note that the " |
| 457 |
"syntax in `Single Function Mode` is not what you expect. Strings are not " |
| 458 |
"quoted and spaces are significant. All arguments are considered to be " |
| 459 |
"constants; there are no expressions." |
| 460 |
msgstr "" |
| 461 |
|
| 462 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:167 |
| 463 |
msgid "" |
| 464 |
"**Do not use subtemplates (`{ ... }`) as function arguments.** Instead, use " |
| 465 |
":ref:`Template Program Mode <template_mode>` and :ref:`General Program Mode " |
| 466 |
"<general_mode>`." |
| 467 |
msgstr "" |
| 468 |
|
| 469 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:169 |
| 470 |
msgid "Notes on calling functions in Single Function Mode:" |
| 471 |
msgstr "" |
| 472 |
|
| 473 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:171 |
| 474 |
msgid "" |
| 475 |
"When functions are used in Single Function Mode, the first parameter, " |
| 476 |
"``value``, is automatically replaced by the content of the field specified " |
| 477 |
"in the template. For example, when the template ``{title:capitalize()}`` is " |
| 478 |
"processed, the content of the ``title`` field is passed as the parameter " |
| 479 |
"``value`` to the capitalize function." |
| 480 |
msgstr "" |
| 481 |
|
| 482 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:172 |
| 483 |
msgid "" |
| 484 |
"In the function documentation, the notation ``[something]*`` means that " |
| 485 |
"``something`` can be repeated zero or more times. The notation " |
| 486 |
"``[something]+`` means that the ``something`` is repeated one or more times " |
| 487 |
"(must exist at least one time)." |
| 488 |
msgstr "" |
| 489 |
|
| 490 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:173 |
| 491 |
msgid "" |
| 492 |
"Some functions use regular expressions. In the template language regular " |
| 493 |
"expression matching is case-insensitive." |
| 494 |
msgstr "" |
| 495 |
|
| 496 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:175 |
| 497 |
msgid "" |
| 498 |
"Functions are documented in :ref:`template_functions_reference`. The " |
| 499 |
"documentation tells you what arguments the functions require and what the " |
| 500 |
"functions do. For example, here is the documentation of the " |
| 501 |
":ref:`ff_ifempty` function." |
| 502 |
msgstr "" |
| 503 |
|
| 504 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:179 |
| 505 |
msgid "" |
| 506 |
"You see that the function requires two arguments, ``value`` and " |
| 507 |
"``text_if_empty``. However, because we are using Single Function Mode, we " |
| 508 |
"omit the ``value`` argument, passing only ``text_if_empty``. For example, " |
| 509 |
"this template::" |
| 510 |
msgstr "" |
| 511 |
|
| 512 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:183 |
| 513 |
msgid "" |
| 514 |
"shows the tags for a book, if any. If it has no tags then it show `No tags " |
| 515 |
"on this book`." |
| 516 |
msgstr "" |
| 517 |
|
| 518 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:185 |
| 519 |
msgid "" |
| 520 |
"The following functions are usable in Single Function Mode because their " |
| 521 |
"first parameter is ``value``." |
| 522 |
msgstr "" |
| 523 |
|
| 524 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:225 |
| 525 |
msgid "**Using functions and formatting in the same template**" |
| 526 |
msgstr "" |
| 527 |
|
| 528 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:227 |
| 529 |
msgid "" |
| 530 |
"Suppose you have an integer custom column ``#myint`` that you want displayed" |
| 531 |
" with leading zeros, as in ``003``. One way to do this is to use a format of" |
| 532 |
" ``0>3s``. However, by default if a number (integer or float) equals zero " |
| 533 |
"then the value is displayed as the empty string so zero values will produce " |
| 534 |
"the empty string, not ``000``. If you want to see ``000`` values then you " |
| 535 |
"use both the format string and the ``ifempty`` function to change the empty " |
| 536 |
"value back to a zero. The template would be::" |
| 537 |
msgstr "" |
| 538 |
|
| 539 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:231 |
| 540 |
msgid "" |
| 541 |
"Note that you can use the prefix and suffix as well. If you want the number " |
| 542 |
"to appear as ``[003]`` or ``[000]``, then use the template::" |
| 543 |
msgstr "" |
| 544 |
|
| 545 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:238 |
| 546 |
msgid "General Program Mode" |
| 547 |
msgstr "" |
| 548 |
|
| 549 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:240 |
| 550 |
msgid "" |
| 551 |
"`General Program Mode` (`GPM`) replaces `template expressions` with a " |
| 552 |
"program written in the `template language`. The syntax of the language is " |
| 553 |
"defined by the following grammar::" |
| 554 |
msgstr "" |
| 555 |
|
| 556 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:291 |
| 557 |
msgid "" |
| 558 |
"a ``top_expression`` always has a value. The value of an ``expression_list``" |
| 559 |
" is the value of the last ``top_expression`` in the list. For example, the " |
| 560 |
"value of the expression list ``1;2;'foobar';3`` is ``3``." |
| 561 |
msgstr "" |
| 562 |
|
| 563 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:292 |
| 564 |
msgid "In a logical context, any non-empty value is ``True``" |
| 565 |
msgstr "" |
| 566 |
|
| 567 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:293 |
| 568 |
msgid "In a logical context, the empty value is ``False``" |
| 569 |
msgstr "" |
| 570 |
|
| 571 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:294 |
| 572 |
msgid "" |
| 573 |
"Strings and numbers can be used interchangeably. For example, ``10`` and " |
| 574 |
"``'10'`` are the same thing." |
| 575 |
msgstr "" |
| 576 |
|
| 577 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:295 |
| 578 |
msgid "" |
| 579 |
"Comments are lines starting with a '#' character. Comments beginning later " |
| 580 |
"in a line are not supported." |
| 581 |
msgstr "" |
| 582 |
|
| 583 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:297 |
| 584 |
msgid "**Operator precedence**" |
| 585 |
msgstr "" |
| 586 |
|
| 587 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:299 |
| 588 |
msgid "" |
| 589 |
"The operator precedence (order of evaluation) from highest (evaluated first)" |
| 590 |
" to lowest (evaluated last) is:" |
| 591 |
msgstr "" |
| 592 |
|
| 593 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:301 |
| 594 |
msgid "" |
| 595 |
"Function calls, constants, parenthesized expressions, statement expressions," |
| 596 |
" assignment expressions, field references." |
| 597 |
msgstr "" |
| 598 |
|
| 599 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:302 |
| 600 |
msgid "" |
| 601 |
"Unary plus (``+``) and minus (``-``). These operators evaluate right to " |
| 602 |
"left." |
| 603 |
msgstr "" |
| 604 |
|
| 605 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:304 |
| 606 |
msgid "" |
| 607 |
"These and all the other arithmetic operators return integers if the " |
| 608 |
"expression results in a fractional part equal to zero. For example, if an " |
| 609 |
"expression returns ``3.0`` it is changed to ``3``." |
| 610 |
msgstr "" |
| 611 |
|
| 612 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:305 |
| 613 |
msgid "" |
| 614 |
"Multiply (``*``) and divide (``/``). These operators are associative and " |
| 615 |
"evaluate left to right. Use parentheses if you want to change the order of " |
| 616 |
"evaluation." |
| 617 |
msgstr "" |
| 618 |
|
| 619 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:306 |
| 620 |
msgid "" |
| 621 |
"Add (``+``) and subtract (``-``). These operators are associative and " |
| 622 |
"evaluate left to right." |
| 623 |
msgstr "" |
| 624 |
|
| 625 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:307 |
| 626 |
msgid "" |
| 627 |
"Numeric and string comparisons. These operators return ``'1'`` if the " |
| 628 |
"comparison succeeds, otherwise the empty string (``''``). Comparisons are " |
| 629 |
"not associative: ``a < b < c`` is a syntax error." |
| 630 |
msgstr "" |
| 631 |
|
| 632 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:308 |
| 633 |
msgid "" |
| 634 |
"String concatenation (``&``). The ``&`` operator returns a string formed by " |
| 635 |
"concatenating the left-hand and right-hand expressions. Example: ``'aaa' & " |
| 636 |
"'bbb'`` returns ``'aaabbb'``. The operator is associative and evaluates left" |
| 637 |
" to right." |
| 638 |
msgstr "" |
| 639 |
|
| 640 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:309 |
| 641 |
msgid "" |
| 642 |
"Unary logical not (``!``). This operator returns ``'1'`` if the expression " |
| 643 |
"is False (evaluates to the empty string), otherwise ``''``." |
| 644 |
msgstr "" |
| 645 |
|
| 646 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:310 |
| 647 |
msgid "" |
| 648 |
"Logical and (``&&``). This operator returns '1' if both the left-hand and " |
| 649 |
"right-hand expressions are True, or the empty string ``''`` if either is " |
| 650 |
"False. It is associative, evaluates left to right, and does `short-" |
| 651 |
"circuiting <https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_." |
| 652 |
msgstr "" |
| 653 |
|
| 654 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:311 |
| 655 |
msgid "" |
| 656 |
"Logical or (``||``). This operator returns ``'1'`` if either the left-hand " |
| 657 |
"or right-hand expression is True, or ``''`` if both are False. It is " |
| 658 |
"associative, evaluates left to right, and does `short-circuiting " |
| 659 |
"<https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_. It is an " |
| 660 |
"`inclusive or`, returning ``'1'`` if both the left- and right-hand " |
| 661 |
"expressions are True." |
| 662 |
msgstr "" |
| 663 |
|
| 664 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:313 |
| 665 |
msgid "**Field references**" |
| 666 |
msgstr "" |
| 667 |
|
| 668 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:315 |
| 669 |
msgid "" |
| 670 |
"A ``field_reference`` evaluates to the value of the metadata field named by " |
| 671 |
"lookup name that follows the ``$`` or ``$$``. Using ``$`` is equivalent to " |
| 672 |
"using the :ref:`ff_field` function. Using ``$$`` is equivalent to using the " |
| 673 |
":ref:`ff_raw_field` function. Examples::" |
| 674 |
msgstr "" |
| 675 |
|
| 676 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:322 |
| 677 |
msgid "**If expressions**" |
| 678 |
msgstr "" |
| 679 |
|
| 680 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:324 |
| 681 |
msgid "" |
| 682 |
"``If`` expressions first evaluate the ``condition``. If the ``condition`` is" |
| 683 |
" True (a non-empty value) then the ``expression_list`` in the ``then`` " |
| 684 |
"clause is evaluated. If it is False then if present the ``expression_list`` " |
| 685 |
"in the ``elif`` or ``else`` clause is evaluated. The ``elif`` and ``else`` " |
| 686 |
"parts are optional. The words ``if``, ``then``, ``elif``, ``else``, and " |
| 687 |
"``fi`` are reserved; you cannot use them as identifier names. You can put " |
| 688 |
"newlines and white space wherever they make sense. The ``condition`` is a " |
| 689 |
"``top_expression`` not an ``expression_list``; semicolons are not allowed. " |
| 690 |
"The ``expression_lists`` are semicolon-separated sequences of " |
| 691 |
"``top_expressions``. An ``if`` expression returns the result of the last " |
| 692 |
"``top_expression`` in the evaluated ``expression_list``, or the empty string" |
| 693 |
" if no expression list was evaluated." |
| 694 |
msgstr "" |
| 695 |
|
| 696 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:326 |
| 697 |
msgid "Examples::" |
| 698 |
msgstr "" |
| 699 |
|
| 700 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:339 |
| 701 |
msgid "Nested ``if`` example::" |
| 702 |
msgstr "" |
| 703 |
|
| 704 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:352 |
| 705 |
msgid "" |
| 706 |
"As said above, an ``if`` produces a value. This means that all the following" |
| 707 |
" are equivalent::" |
| 708 |
msgstr "" |
| 709 |
|
| 710 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:358 |
| 711 |
msgid "" |
| 712 |
"For example, this program returns the value of the ``series`` column if the " |
| 713 |
"book has a series, otherwise the value of the ``title`` column::" |
| 714 |
msgstr "" |
| 715 |
|
| 716 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:362 |
| 717 |
msgid "**For expressions**" |
| 718 |
msgstr "" |
| 719 |
|
| 720 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:364 |
| 721 |
msgid "" |
| 722 |
"The ``for`` expression iterates over a list of values, processing them one " |
| 723 |
"at a time. The ``list_expression`` must evaluate either to a metadata field " |
| 724 |
"``lookup name`` e.g., ``tags`` or ``#genre``, or to a list of values. The " |
| 725 |
":ref:`ff_range` generates a list of numbers. If the result is a valid " |
| 726 |
"``lookup name`` then the field's value is fetched and the separator " |
| 727 |
"specified for that field type is used. If the result isn't a valid lookup " |
| 728 |
"name then it is assumed to be a list of values. The list is assumed to be " |
| 729 |
"separated by commas unless the optional keyword ``separator`` is supplied, " |
| 730 |
"in which case the list values must be separated by the result of evaluating " |
| 731 |
"the ``separator_expr``. A separator cannot be used if the list is generated " |
| 732 |
"by ``range()``. Each value in the list is assigned to the specified variable" |
| 733 |
" then the ``expression_list`` is evaluated. You can use ``break`` to jump " |
| 734 |
"out of the loop, and ``continue`` to jump to the beginning of the loop for " |
| 735 |
"the next iteration." |
| 736 |
msgstr "" |
| 737 |
|
| 738 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:366 |
| 739 |
msgid "" |
| 740 |
"Example: This template removes the first hierarchical name for each value in" |
| 741 |
" Genre (``#genre``), constructing a list with the new names::" |
| 742 |
msgstr "" |
| 743 |
|
| 744 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:376 |
| 745 |
msgid "" |
| 746 |
"If the original Genre is `History.Military, Science Fiction.Alternate " |
| 747 |
"History, ReadMe` then the template returns `Military, Alternate History, " |
| 748 |
"ReadMe`. You could use this template in calibre's :guilabel:`Edit metadata " |
| 749 |
"in bulk -> Search & replace` with :guilabel:`Search for` set to ``template``" |
| 750 |
" to strip off the first level of the hierarchy and assign the resulting " |
| 751 |
"value to Genre." |
| 752 |
msgstr "" |
| 753 |
|
| 754 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:379 |
| 755 |
msgid "" |
| 756 |
"Note: the last line in the template, ``new_tags``, isn't strictly necessary " |
| 757 |
"in this case because ``for`` returns the value of the last top_expression in" |
| 758 |
" the expression list. The value of an assignment is the value of its " |
| 759 |
"expression, so the value of the ``for`` statement is what was assigned to " |
| 760 |
"``new_tags``." |
| 761 |
msgstr "" |
| 762 |
|
| 763 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:381 |
| 764 |
msgid "**Function definition**" |
| 765 |
msgstr "" |
| 766 |
|
| 767 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:383 |
| 768 |
msgid "" |
| 769 |
"If you have repeated code in a template then you can put that code into a " |
| 770 |
"local function. The ``def`` keyword starts the definition. It is followed by" |
| 771 |
" the function name, the argument list, then the code in the function. The " |
| 772 |
"function definition ends with the ``fed`` keyword." |
| 773 |
msgstr "" |
| 774 |
|
| 775 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:385 |
| 776 |
msgid "" |
| 777 |
"Arguments are positional. When a function is called the supplied arguments " |
| 778 |
"are matched left to right against the defined parameters, with the value of " |
| 779 |
"the argument assigned to the parameter. It is an error to provide more " |
| 780 |
"arguments than defined parameters. Parameters can have default values, such " |
| 781 |
"as ``a = 25``. If an argument is not supplied for that parameter then the " |
| 782 |
"default value is used, otherwise the parameter is set to the empty string." |
| 783 |
msgstr "" |
| 784 |
|
| 785 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:387 |
| 786 |
msgid "The ``return`` statement can be used in a local function." |
| 787 |
msgstr "" |
| 788 |
|
| 789 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:389 |
| 790 |
msgid "A function must be defined before it can be used." |
| 791 |
msgstr "" |
| 792 |
|
| 793 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:391 |
| 794 |
msgid "" |
| 795 |
"Example: This template computes an approximate duration in years, months, " |
| 796 |
"and days from a number of days. The function ``to_plural()`` formats the " |
| 797 |
"computed values. Note that the example also uses the ``&`` operator::" |
| 798 |
msgstr "" |
| 799 |
|
| 800 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:406 |
| 801 |
msgid "**Relational operators**" |
| 802 |
msgstr "" |
| 803 |
|
| 804 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:408 |
| 805 |
msgid "" |
| 806 |
"Relational operators return ``'1'`` if the comparison is true, otherwise the" |
| 807 |
" empty string (``''``)." |
| 808 |
msgstr "" |
| 809 |
|
| 810 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:410 |
| 811 |
msgid "" |
| 812 |
"There are two forms of relational operators: string comparisons and numeric " |
| 813 |
"comparisons." |
| 814 |
msgstr "" |
| 815 |
|
| 816 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:412 |
| 817 |
msgid "" |
| 818 |
"String comparisons do case-insensitive string comparison using lexical " |
| 819 |
"order. The supported string comparison operators are ``==``, ``!=``, ``<``, " |
| 820 |
"``<=``, ``>``, ``>=``, ``in``, ``inlist``, and ``inlist_field``. For the " |
| 821 |
"``in`` operator, the result of the left hand expression is interpreted as a " |
| 822 |
"regular expression pattern. The ``in`` operator is True if the value of " |
| 823 |
"left-hand regular expression matches the value of the right hand expression." |
| 824 |
msgstr "" |
| 825 |
|
| 826 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:415 |
| 827 |
msgid "" |
| 828 |
"The ``inlist`` operator is true if the left hand regular expression matches " |
| 829 |
"any one of the items in the right hand list where the items in the list are " |
| 830 |
"separated by commas. The ``inlist_field`` operator is true if the left hand " |
| 831 |
"regular expression matches any of the items in the field (column) named by " |
| 832 |
"the right hand expression, using the separator defined for the field. NB: " |
| 833 |
"the ``inlist_field`` operator requires the right hand expression to evaluate" |
| 834 |
" to a field name, while the ``inlist`` operator requires the right hand " |
| 835 |
"expression to evaluate to a string containing a comma-separated list. " |
| 836 |
"Because of this difference, ``inlist_field`` is substantially faster than " |
| 837 |
"``inlist`` because no string conversions or list constructions are done. The" |
| 838 |
" regular expressions are case-insensitive." |
| 839 |
msgstr "" |
| 840 |
|
| 841 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:417 |
| 842 |
msgid "" |
| 843 |
"The numeric comparison operators are ``==#``, ``!=#``, ``<#``, ``<=#``, " |
| 844 |
"``>#``, ``>=#``. The left and right expressions must evaluate to numeric " |
| 845 |
"values with two exceptions: both the string value \"None\" (undefined field)" |
| 846 |
" and the empty string evaluate to the value zero." |
| 847 |
msgstr "" |
| 848 |
|
| 849 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:419 |
| 850 |
msgid "Examples:" |
| 851 |
msgstr "" |
| 852 |
|
| 853 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:421 |
| 854 |
msgid "" |
| 855 |
"``program: field('series') == 'foo'`` returns ``'1'`` if the book's series " |
| 856 |
"is `foo`, otherwise ``''``." |
| 857 |
msgstr "" |
| 858 |
|
| 859 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:422 |
| 860 |
msgid "" |
| 861 |
"``program: 'f.o' in field('series')`` returns ``'1'`` if the book's series " |
| 862 |
"matches the regular expression ``f.o`` (e.g., `foo`, `Off Onyx`, etc.), " |
| 863 |
"otherwise ``''``." |
| 864 |
msgstr "" |
| 865 |
|
| 866 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:423 |
| 867 |
msgid "" |
| 868 |
"``program: 'science' inlist $#genre`` returns ``'1'`` if any of the values " |
| 869 |
"retrieved from the book's genres match the regular expression ``science``, " |
| 870 |
"e.g., `Science`, `History of Science`, `Science Fiction` etc., otherwise " |
| 871 |
"``''``." |
| 872 |
msgstr "" |
| 873 |
|
| 874 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:424 |
| 875 |
msgid "" |
| 876 |
"``program: '^science$' inlist $#genre`` returns ``'1'`` if any of the book's" |
| 877 |
" genres exactly match the regular expression ``^science$``, e.g., `Science`," |
| 878 |
" otherwise ``''``. The genres `History of Science` and `Science Fiction` " |
| 879 |
"don't match." |
| 880 |
msgstr "" |
| 881 |
|
| 882 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:425 |
| 883 |
msgid "" |
| 884 |
"``program: 'asimov' inlist $authors`` returns ``'1'`` if any author matches " |
| 885 |
"the regular expression ``asimov``, e.g., `Asimov, Isaac` or `Isaac Asimov`, " |
| 886 |
"otherwise ``''``." |
| 887 |
msgstr "" |
| 888 |
|
| 889 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:426 |
| 890 |
msgid "" |
| 891 |
"``program: 'asimov' inlist_field 'authors'`` returns ``'1'`` if any author " |
| 892 |
"matches the regular expression ``asimov``, e.g., `Asimov, Isaac` or `Isaac " |
| 893 |
"Asimov`, otherwise ``''``." |
| 894 |
msgstr "" |
| 895 |
|
| 896 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:427 |
| 897 |
msgid "" |
| 898 |
"``program: 'asimov$' inlist_field 'authors'`` returns ``'1'`` if any author " |
| 899 |
"matches the regular expression ``asimov$``, e.g., `Isaac Asimov`, otherwise " |
| 900 |
"``''``. It doesn't match `Asimov, Isaac` because of the ``$`` anchor in the " |
| 901 |
"regular expression." |
| 902 |
msgstr "" |
| 903 |
|
| 904 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:428 |
| 905 |
msgid "" |
| 906 |
"``program: if field('series') != 'foo' then 'bar' else 'mumble' fi`` returns" |
| 907 |
" ``'bar'`` if the book's series is not `foo`. Otherwise it returns " |
| 908 |
"``'mumble'``." |
| 909 |
msgstr "" |
| 910 |
|
| 911 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:429 |
| 912 |
msgid "" |
| 913 |
"``program: if field('series') == 'foo' || field('series') == '1632' then " |
| 914 |
"'yes' else 'no' fi`` returns ``'yes'`` if series is either `foo` or `1632`, " |
| 915 |
"otherwise ``'no'``." |
| 916 |
msgstr "" |
| 917 |
|
| 918 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:430 |
| 919 |
msgid "" |
| 920 |
"``program: if '^(foo|1632)$' in field('series') then 'yes' else 'no' fi`` " |
| 921 |
"returns ``'yes'`` if series is either `foo` or `1632`, otherwise ``'no'``." |
| 922 |
msgstr "" |
| 923 |
|
| 924 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:431 |
| 925 |
msgid "" |
| 926 |
"``program: if 11 > 2 then 'yes' else 'no' fi`` returns ``'no'`` because the " |
| 927 |
"``>`` operator does a lexical comparison." |
| 928 |
msgstr "" |
| 929 |
|
| 930 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:432 |
| 931 |
msgid "" |
| 932 |
"``program: if 11 ># 2 then 'yes' else 'no' fi`` returns ``'yes'`` because " |
| 933 |
"the ``>#`` operator does a numeric comparison." |
| 934 |
msgstr "" |
| 935 |
|
| 936 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:434 |
| 937 |
msgid "**Functions in General Program Mode**" |
| 938 |
msgstr "" |
| 939 |
|
| 940 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:436 |
| 941 |
msgid "" |
| 942 |
"See :ref:`template_functions_reference` for the list of functions built into" |
| 943 |
" the template language." |
| 944 |
msgstr "" |
| 945 |
|
| 946 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:440 |
| 947 |
msgid "" |
| 948 |
"As opposed to :ref:`Single Function Mode <single_mode>`, in General Program " |
| 949 |
"Mode you must specify the first parameter ``value``." |
| 950 |
msgstr "" |
| 951 |
|
| 952 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:441 |
| 953 |
msgid "All parameters are expression_lists (see the grammar above)." |
| 954 |
msgstr "" |
| 955 |
|
| 956 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:446 |
| 957 |
msgid "More complex programs in template expressions - Template Program Mode" |
| 958 |
msgstr "" |
| 959 |
|
| 960 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:448 |
| 961 |
msgid "" |
| 962 |
"`Template Program Mode` (`TPM`) is a blend of :ref:`General Program Mode " |
| 963 |
"<general_mode>` and :ref:`Single Function Mode <single_mode>`. `TPM` differs" |
| 964 |
" from Single Function Mode in that it permits writing template expressions " |
| 965 |
"that refer to other metadata fields, use nested functions, modify variables," |
| 966 |
" and do arithmetic. It differs from `General Program Mode` in that the " |
| 967 |
"template is contained between ``{`` and ``}`` characters and doesn't begin " |
| 968 |
"with the word ``program:``. The program portion of the template is a General" |
| 969 |
" Program Mode expression list." |
| 970 |
msgstr "" |
| 971 |
|
| 972 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:451 |
| 973 |
msgid "" |
| 974 |
"Example: assume you want a template to show the series for a book if it has " |
| 975 |
"one, otherwise show the value of a custom field #genre. You cannot do this " |
| 976 |
"in the :ref:`Single Function Mode <single_mode>` because you cannot make " |
| 977 |
"reference to another metadata field within a template expression. In `TPM` " |
| 978 |
"you can, as the following expression demonstrates::" |
| 979 |
msgstr "" |
| 980 |
|
| 981 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:456 |
| 982 |
msgid "The example shows several things:" |
| 983 |
msgstr "" |
| 984 |
|
| 985 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:458 |
| 986 |
msgid "" |
| 987 |
"`TPM` is used if the expression begins with ``:'`` and ends with ``'}``. " |
| 988 |
"Anything else is assumed to be in :ref:`Single Function Mode <single_mode>`." |
| 989 |
msgstr "" |
| 990 |
|
| 991 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:460 |
| 992 |
msgid "" |
| 993 |
"If the template contains a prefix and suffix, the expression ends with " |
| 994 |
"``'|`` where the ``|`` is the delimiter for the prefix. Example::" |
| 995 |
msgstr "" |
| 996 |
|
| 997 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:464 |
| 998 |
msgid "" |
| 999 |
"Functions must be given all their arguments. For example, the standard " |
| 1000 |
"built-in functions must be given the initial parameter ``value``." |
| 1001 |
msgstr "" |
| 1002 |
|
| 1003 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:465 |
| 1004 |
msgid "" |
| 1005 |
"The variable ``$`` is usable as the ``value`` argument and stands for the " |
| 1006 |
"value of the field named in the template, ``series_index`` in this case." |
| 1007 |
msgstr "" |
| 1008 |
|
| 1009 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:466 |
| 1010 |
msgid "white space is ignored and can be used anywhere within the expression." |
| 1011 |
msgstr "" |
| 1012 |
|
| 1013 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:467 |
| 1014 |
msgid "" |
| 1015 |
"constant strings are enclosed in matching quotes, either ``'`` or ``\"``." |
| 1016 |
msgstr "" |
| 1017 |
|
| 1018 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:469 |
| 1019 |
msgid "" |
| 1020 |
"In `TPM`, using ``{`` and ``}`` characters in string literals can lead to " |
| 1021 |
"errors or unexpected results because they confuse the template processor. It" |
| 1022 |
" tries to treat them as template expression boundaries, not characters. In " |
| 1023 |
"some but not all cases you can replace a ``{`` with ``[[`` and a ``}`` with " |
| 1024 |
"`]]`. Generally, if your program contains ``{`` and ``}`` characters then " |
| 1025 |
"you should use `General Program Mode`." |
| 1026 |
msgstr "" |
| 1027 |
|
| 1028 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:474 |
| 1029 |
msgid "Python Template Mode" |
| 1030 |
msgstr "" |
| 1031 |
|
| 1032 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:476 |
| 1033 |
msgid "" |
| 1034 |
"Python Template Mode (PTM) lets you write templates using native Python and " |
| 1035 |
"the `calibre API <https://manual.calibre-ebook.com/develop.html#api-" |
| 1036 |
"documentation-for-various-parts-of-calibre>`_. The database API will be of " |
| 1037 |
"most use; further discussion is beyond the scope of this manual. PTM " |
| 1038 |
"templates are faster and can do more complicated operations but you must " |
| 1039 |
"know how to write code in Python using the calibre API." |
| 1040 |
msgstr "" |
| 1041 |
|
| 1042 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:478 |
| 1043 |
msgid "A PTM template begins with:" |
| 1044 |
msgstr "" |
| 1045 |
|
| 1046 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:496 |
| 1047 |
msgid "" |
| 1048 |
"You can add the above text to your template using the context menu, usually " |
| 1049 |
"accessed with a right click. The comments are not significant and can be " |
| 1050 |
"removed. You must use python indenting." |
| 1051 |
msgstr "" |
| 1052 |
|
| 1053 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:498 |
| 1054 |
msgid "" |
| 1055 |
"The context object supports ``str(context)`` that returns a string of the " |
| 1056 |
"context's contents, and ``context.attributes`` that returns a list of the " |
| 1057 |
"attribute names in the context." |
| 1058 |
msgstr "" |
| 1059 |
|
| 1060 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:500 |
| 1061 |
msgid "" |
| 1062 |
"The ``context.funcs`` attribute allows calling Built-in and User template " |
| 1063 |
"functions, and Stored GPM/Python templates, so that you can execute them " |
| 1064 |
"directly in your code. The functions are retrieved using their names. If the" |
| 1065 |
" name conflicts with a Python keyword, add an underscore to the end of the " |
| 1066 |
"name. Examples:" |
| 1067 |
msgstr "" |
| 1068 |
|
| 1069 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:507 |
| 1070 |
msgid "" |
| 1071 |
"Here is an example of a PTM template that produces a list of all the authors" |
| 1072 |
" for a series. The list is stored in a `Column built from other columns, " |
| 1073 |
"behaves like tags`. It shows in :guilabel:`Book details` and has the " |
| 1074 |
":guilabel:`on separate lines` checked (in :guilabel:`Preferences->Look & " |
| 1075 |
"feel->Book details`). That option requires the list to be comma-separated. " |
| 1076 |
"To satisfy that requirement the template converts commas in author names to " |
| 1077 |
"semicolons then builds a comma-separated list of authors. The authors are " |
| 1078 |
"then sorted, which is why the template uses author_sort." |
| 1079 |
msgstr "" |
| 1080 |
|
| 1081 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:528 |
| 1082 |
msgid "The output in :guilabel:`Book details` looks like this:" |
| 1083 |
msgstr "" |
| 1084 |
|
| 1085 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:530 |
| 1086 |
msgid "E-book conversion dialog" |
| 1087 |
msgstr "" |
| 1088 |
|
| 1089 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:536 |
| 1090 |
msgid "Stored templates" |
| 1091 |
msgstr "" |
| 1092 |
|
| 1093 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:538 |
| 1094 |
msgid "" |
| 1095 |
"Both :ref:`General Program Mode <general_mode>` and :ref:`Python Template " |
| 1096 |
"Mode <python_mode>` support saving templates and calling those templates " |
| 1097 |
"from another template, much like calling stored functions. You save " |
| 1098 |
"templates using :guilabel:`Preferences->Advanced->Template functions`. More " |
| 1099 |
"information is provided in that dialog. You call a template the same way you" |
| 1100 |
" call a function, passing positional arguments if desired. An argument can " |
| 1101 |
"be any expression. Examples of calling a template, assuming the stored " |
| 1102 |
"template is named ``foo``:" |
| 1103 |
msgstr "" |
| 1104 |
|
| 1105 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:540 |
| 1106 |
msgid "``foo()`` -- call the template passing no arguments." |
| 1107 |
msgstr "" |
| 1108 |
|
| 1109 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:541 |
| 1110 |
msgid "" |
| 1111 |
"``foo(a, b)`` call the template passing the values of the two variables " |
| 1112 |
"``a`` and ``b``." |
| 1113 |
msgstr "" |
| 1114 |
|
| 1115 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:542 |
| 1116 |
msgid "" |
| 1117 |
"``foo(if field('series') then field('series_index') else 0 fi)`` -- if the " |
| 1118 |
"book has a ``series`` then pass the ``series_index``, otherwise pass the " |
| 1119 |
"value ``0``." |
| 1120 |
msgstr "" |
| 1121 |
|
| 1122 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:544 |
| 1123 |
msgid "" |
| 1124 |
"In GPM you retrieve the arguments passed in the call to the stored template " |
| 1125 |
"using the ``arguments`` function. It both declares and initializes local " |
| 1126 |
"variables, effectively parameters. The variables are positional; they get " |
| 1127 |
"the value of the parameter given in the call in the same position. If the " |
| 1128 |
"corresponding parameter is not provided in the call then ``arguments`` " |
| 1129 |
"assigns that variable the provided default value. If there is no default " |
| 1130 |
"value then the variable is set to the empty string. For example, the " |
| 1131 |
"following ``arguments`` function declares 2 variables, ``key``, " |
| 1132 |
"``alternate``::" |
| 1133 |
msgstr "" |
| 1134 |
|
| 1135 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:548 |
| 1136 |
msgid "Examples, again assuming the stored template is named ``foo``:" |
| 1137 |
msgstr "" |
| 1138 |
|
| 1139 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:550 |
| 1140 |
msgid "" |
| 1141 |
"``foo('#myseries')`` -- argument ``key`` is assigned the value " |
| 1142 |
"``'myseries'`` and the argument ``alternate`` is assigned the default value " |
| 1143 |
"``'series'``." |
| 1144 |
msgstr "" |
| 1145 |
|
| 1146 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:551 |
| 1147 |
msgid "" |
| 1148 |
"``foo('series', '#genre')`` the variable ``key`` is assigned the value " |
| 1149 |
"``'series'`` and the variable ``alternate`` is assigned the value " |
| 1150 |
"``'#genre'``." |
| 1151 |
msgstr "" |
| 1152 |
|
| 1153 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:552 |
| 1154 |
msgid "" |
| 1155 |
"``foo()`` -- the variable ``key`` is assigned the empty string and the " |
| 1156 |
"variable ``alternate`` is assigned the value ``'series'``." |
| 1157 |
msgstr "" |
| 1158 |
|
| 1159 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:554 |
| 1160 |
msgid "" |
| 1161 |
"In PTM the arguments are passed in the ``arguments`` parameter, which is a " |
| 1162 |
"list of strings. There isn't any way to specify default values. You must " |
| 1163 |
"check the length of the ``arguments`` list to be sure that the number of " |
| 1164 |
"arguments is what you expect." |
| 1165 |
msgstr "" |
| 1166 |
|
| 1167 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:556 |
| 1168 |
msgid "" |
| 1169 |
"An easy way to test stored templates is using the ``Template tester`` " |
| 1170 |
"dialog. For ease of access give it a keyboard shortcut in " |
| 1171 |
":guilabel:`Preferences->Advanced->Keyboard shortcuts->Template tester`. " |
| 1172 |
"Giving the ``Stored templates`` dialog a shortcut will help switching more " |
| 1173 |
"rapidly between the tester and editing the stored template's source code." |
| 1174 |
msgstr "" |
| 1175 |
|
| 1176 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:559 |
| 1177 |
msgid "Providing additional information to templates" |
| 1178 |
msgstr "" |
| 1179 |
|
| 1180 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:561 |
| 1181 |
msgid "" |
| 1182 |
"A developer can choose to pass additional information to the template " |
| 1183 |
"processor, such as application-specific book metadata or information about " |
| 1184 |
"what the processor is being asked to do. A template can access this " |
| 1185 |
"information and use it during the evaluation." |
| 1186 |
msgstr "" |
| 1187 |
|
| 1188 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:563 |
| 1189 |
msgid "**Developer: how to pass additional information**" |
| 1190 |
msgstr "" |
| 1191 |
|
| 1192 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:565 |
| 1193 |
msgid "" |
| 1194 |
"The additional information is a Python dictionary containing pairs " |
| 1195 |
"``variable_name: variable_value`` where the values must be strings. The " |
| 1196 |
"template can access the dictionary, creating template local variables named " |
| 1197 |
"``variable_name`` containing the value ``variable_value``. The user cannot " |
| 1198 |
"change the name so it is best to use names that won't collide with other " |
| 1199 |
"template local variables, for example by prefixing the name with an " |
| 1200 |
"underscore." |
| 1201 |
msgstr "" |
| 1202 |
|
| 1203 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:567 |
| 1204 |
msgid "" |
| 1205 |
"This dictionary is passed to the template processor (the ``formatter``) " |
| 1206 |
"using the named parameter ``global_vars=your_dict``. The full method " |
| 1207 |
"signature is::" |
| 1208 |
msgstr "" |
| 1209 |
|
| 1210 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:575 |
| 1211 |
msgid "**Template writer: how to access the additional information**" |
| 1212 |
msgstr "" |
| 1213 |
|
| 1214 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:577 |
| 1215 |
msgid "" |
| 1216 |
"You access the additional information (the ``globals`` dictionary) in a " |
| 1217 |
"template using the template function::" |
| 1218 |
msgstr "" |
| 1219 |
|
| 1220 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:581 |
| 1221 |
msgid "" |
| 1222 |
"where ``id`` is any legal variable name. This function checks whether the " |
| 1223 |
"additional information provided by the developer contains the name. If it " |
| 1224 |
"does then the function assigns the provided value to a template local " |
| 1225 |
"variable with that name. If the name is not in the additional information " |
| 1226 |
"and if an ``expression`` is provided, the ``expression`` is evaluated and " |
| 1227 |
"the result is assigned to the local variable. If neither a value nor an " |
| 1228 |
"expression is provided, the function assigns the empty string (``''``) to " |
| 1229 |
"the local variable." |
| 1230 |
msgstr "" |
| 1231 |
|
| 1232 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:583 |
| 1233 |
msgid "" |
| 1234 |
"A template can set a value in the ``globals`` dictionary using the template " |
| 1235 |
"function::" |
| 1236 |
msgstr "" |
| 1237 |
|
| 1238 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:587 |
| 1239 |
msgid "" |
| 1240 |
"This function sets the ``globals`` dictionary key:value pair ``id:value`` " |
| 1241 |
"where ``value`` is the value of the template local variable ``id``. If that " |
| 1242 |
"local variable doesn't exist then ``value`` is set to the result of " |
| 1243 |
"evaluating ``expression``." |
| 1244 |
msgstr "" |
| 1245 |
|
| 1246 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:590 |
| 1247 |
msgid "Notes on the difference between modes" |
| 1248 |
msgstr "" |
| 1249 |
|
| 1250 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:592 |
| 1251 |
msgid "" |
| 1252 |
"The three program modes, :ref:`Single Function Mode <single_mode>` (SFM), " |
| 1253 |
":ref:`Template Program Mode <template_mode>` (`TPM`), and :ref:`General " |
| 1254 |
"Program Mode <general_mode>` (`GPM`), work differently. SFM is intended to " |
| 1255 |
"be 'simple' so it hides a lot of programming language bits." |
| 1256 |
msgstr "" |
| 1257 |
|
| 1258 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:594 |
| 1259 |
msgid "Differences:" |
| 1260 |
msgstr "" |
| 1261 |
|
| 1262 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:596 |
| 1263 |
msgid "" |
| 1264 |
"In SFM the value of the column is always passed as an 'invisible' first " |
| 1265 |
"argument to a function included in the template." |
| 1266 |
msgstr "" |
| 1267 |
|
| 1268 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:597 |
| 1269 |
msgid "" |
| 1270 |
"SFM doesn't support the difference between variables and strings; all values" |
| 1271 |
" are strings." |
| 1272 |
msgstr "" |
| 1273 |
|
| 1274 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:598 |
| 1275 |
msgid "" |
| 1276 |
"The following SFM template returns either the series name or the string \"no" |
| 1277 |
" series\"::" |
| 1278 |
msgstr "" |
| 1279 |
|
| 1280 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:602 |
| 1281 |
msgid "The equivalent template in `TPM` is ::" |
| 1282 |
msgstr "" |
| 1283 |
|
| 1284 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:606 |
| 1285 |
msgid "The equivalent template in `GPM` is::" |
| 1286 |
msgstr "" |
| 1287 |
|
| 1288 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:610 |
| 1289 |
msgid "" |
| 1290 |
"The first argument to ``ifempty`` is the value of the field ``series``. The " |
| 1291 |
"second argument is the string ``no series``. In SFM the first argument, the " |
| 1292 |
"value of the field, is automatically passed (the invisible argument)." |
| 1293 |
msgstr "" |
| 1294 |
|
| 1295 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:611 |
| 1296 |
msgid "" |
| 1297 |
"Several template functions, for example ``booksize()`` and " |
| 1298 |
"``current_library_name()``, take no arguments. Because of the 'invisible " |
| 1299 |
"argument' you cannot use these functions in SFM." |
| 1300 |
msgstr "" |
| 1301 |
|
| 1302 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:612 |
| 1303 |
msgid "" |
| 1304 |
"Nested functions, where a function calls another function to compute an " |
| 1305 |
"argument, cannot be used in SFM. For example this template, intended to " |
| 1306 |
"return the first 5 characters of the series value uppercased, won't work in " |
| 1307 |
"SFM::" |
| 1308 |
msgstr "" |
| 1309 |
|
| 1310 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:616 |
| 1311 |
msgid "" |
| 1312 |
"`TPM` and `GPM` support nested functions. The above template in `TPM` would " |
| 1313 |
"be::" |
| 1314 |
msgstr "" |
| 1315 |
|
| 1316 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:620 |
| 1317 |
msgid "In `GPM` it would be::" |
| 1318 |
msgstr "" |
| 1319 |
|
| 1320 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:624 |
| 1321 |
msgid "" |
| 1322 |
"As noted in the above :ref:`Template Program Mode <template_mode>` section, " |
| 1323 |
"using ``{`` and ``}`` characters in `TPM` string literals can lead to errors" |
| 1324 |
" or unexpected results because they confuse the template processor. It tries" |
| 1325 |
" to treat them as template boundaries, not characters. In some but not all " |
| 1326 |
"cases you can replace a ``{`` with ``[[`` and a ``}`` with `]]`. Generally, " |
| 1327 |
"if your program contains ``{`` and ``}`` characters then you should use " |
| 1328 |
"`General Program Mode`." |
| 1329 |
msgstr "" |
| 1330 |
|
| 1331 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:628 |
| 1332 |
msgid "User-defined Python template functions" |
| 1333 |
msgstr "" |
| 1334 |
|
| 1335 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:630 |
| 1336 |
msgid "" |
| 1337 |
"You can add your own Python functions to the template processor. Such " |
| 1338 |
"functions can be used in any of the three template programming modes. The " |
| 1339 |
"functions are added by going to :guilabel:`Preferences -> Advanced -> " |
| 1340 |
"Template functions`. Instructions are shown in that dialog. Note that you " |
| 1341 |
"can use `Python Templates` for a similar purpose. As calling user-defined " |
| 1342 |
"functions is faster than calling a Python template, user-defined functions " |
| 1343 |
"might be more efficient depending on the complexity of what the function or " |
| 1344 |
"template does." |
| 1345 |
msgstr "" |
| 1346 |
|
| 1347 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:633 |
| 1348 |
msgid "Special notes for save/send templates" |
| 1349 |
msgstr "" |
| 1350 |
|
| 1351 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:635 |
| 1352 |
msgid "" |
| 1353 |
"Special processing is applied when a template is used in a `save to disk` or" |
| 1354 |
" `send to device` template. The values of the fields are cleaned, replacing " |
| 1355 |
"characters that are special to file systems with underscores, including " |
| 1356 |
"slashes. This means that field text cannot be used to create folders. " |
| 1357 |
"However, slashes are not changed in prefix or suffix strings, so slashes in " |
| 1358 |
"these strings will cause folders to be created. Because of this, you can " |
| 1359 |
"create variable-depth folder structure." |
| 1360 |
msgstr "" |
| 1361 |
|
| 1362 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:637 |
| 1363 |
msgid "" |
| 1364 |
"For example, assume we want the folder structure `series/series_index - " |
| 1365 |
"title`, with the caveat that if series does not exist, then the title should" |
| 1366 |
" be in the top folder. The template to do this is::" |
| 1367 |
msgstr "" |
| 1368 |
|
| 1369 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:641 |
| 1370 |
msgid "The slash and the hyphen appear only if series is not empty." |
| 1371 |
msgstr "" |
| 1372 |
|
| 1373 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:643 |
| 1374 |
msgid "" |
| 1375 |
"The lookup function lets us do even fancier processing. For example, assume " |
| 1376 |
"that if a book has a series, then we want the folder structure " |
| 1377 |
"`series/series index - title.fmt`. If the book does not have a series then " |
| 1378 |
"we want the folder structure `genre/author_sort/title.fmt`. If the book has " |
| 1379 |
"no genre then we want to use 'Unknown'. We want two completely different " |
| 1380 |
"paths, depending on the value of series." |
| 1381 |
msgstr "" |
| 1382 |
|
| 1383 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:645 |
| 1384 |
msgid "To accomplish this, we:" |
| 1385 |
msgstr "" |
| 1386 |
|
| 1387 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:647 |
| 1388 |
msgid "" |
| 1389 |
"Create a composite field (give it lookup name #aa) containing " |
| 1390 |
"``{series}/{series_index} - {title}``. If the series is not empty, then this" |
| 1391 |
" template will produce `series/series_index - title`." |
| 1392 |
msgstr "" |
| 1393 |
|
| 1394 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:648 |
| 1395 |
msgid "" |
| 1396 |
"Create a composite field (give it lookup name #bb) containing " |
| 1397 |
"``{#genre:ifempty(Unknown)}/{author_sort}/{title}``. This template produces " |
| 1398 |
"`genre/author_sort/title`, where an empty genre is replaced with `Unknown`." |
| 1399 |
msgstr "" |
| 1400 |
|
| 1401 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:649 |
| 1402 |
msgid "" |
| 1403 |
"Set the save template to ``{series:lookup(.,#aa,#bb)}``. This template " |
| 1404 |
"chooses composite field ``#aa`` if series is not empty and composite field " |
| 1405 |
"``#bb`` if series is empty. We therefore have two completely different save " |
| 1406 |
"paths, depending on whether or not `series` is empty." |
| 1407 |
msgstr "" |
| 1408 |
|
| 1409 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:652 |
| 1410 |
msgid "Tips" |
| 1411 |
msgstr "" |
| 1412 |
|
| 1413 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:654 |
| 1414 |
msgid "" |
| 1415 |
"Use the Template Tester to test templates. Add the tester to the context " |
| 1416 |
"menu for books in the library and/or give it a keyboard shortcut." |
| 1417 |
msgstr "" |
| 1418 |
|
| 1419 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:655 |
| 1420 |
msgid "" |
| 1421 |
"Templates can use other templates by referencing composite columns built " |
| 1422 |
"with the desired template. Alternatively, you can use Stored Templates." |
| 1423 |
msgstr "" |
| 1424 |
|
| 1425 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:656 |
| 1426 |
msgid "" |
| 1427 |
"In a plugboard, you can set a field to empty (or whatever is equivalent to " |
| 1428 |
"empty) by using the special template ``{}``. This template will always " |
| 1429 |
"evaluate to an empty string." |
| 1430 |
msgstr "" |
| 1431 |
|
| 1432 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:657 |
| 1433 |
msgid "" |
| 1434 |
"The technique described above to show numbers even if they have a zero value" |
| 1435 |
" works with the standard field series_index." |
| 1436 |
msgstr "" |
| 1437 |
|
| 1438 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:662 |
| 1439 |
msgid "Template function reference" |
| 1440 |
msgstr "Template function reference" |