| 1 |
# SOME DESCRIPTIVE TITLE. |
| 2 |
# Copyright (C) Kovid Goyal |
| 3 |
# This file is distributed under the same license as the calibre package. |
| 4 |
# |
| 5 |
# Translators: |
| 6 |
msgid "" |
| 7 |
msgstr "" |
| 8 |
"Project-Id-Version: calibre\n" |
| 9 |
"Report-Msgid-Bugs-To: \n" |
| 10 |
"POT-Creation-Date: 2022-02-03 02:30+0000\n" |
| 11 |
"PO-Revision-Date: 2022-02-01 09:40+0000\n" |
| 12 |
"Last-Translator: Kovid Goyal <[email protected]>\n" |
| 13 |
"Language-Team: Kinyarwanda (http://www.transifex.com/calibre/calibre/language/rw/)\n" |
| 14 |
"MIME-Version: 1.0\n" |
| 15 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 16 |
"Content-Transfer-Encoding: 8bit\n" |
| 17 |
"Language: rw\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 "" |
| 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:249 |
| 214 |
msgid "Notes:" |
| 215 |
msgstr "" |
| 216 |
|
| 217 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:85 |
| 218 |
msgid "" |
| 219 |
"You must include the colon after the ``lookup name`` if you are using a " |
| 220 |
"prefix or a suffix." |
| 221 |
msgstr "" |
| 222 |
|
| 223 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:86 |
| 224 |
msgid "" |
| 225 |
"You must either use either no or both ``|`` characters. Using one, as in " |
| 226 |
"``{field:| - }``, is not allowed." |
| 227 |
msgstr "" |
| 228 |
|
| 229 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:87 |
| 230 |
msgid "" |
| 231 |
"It is OK to provide no text for either the prefix or the suffix, such as in " |
| 232 |
"``{series:|| - }``. The template ``{title:||}`` is the same as ``{title}``." |
| 233 |
msgstr "" |
| 234 |
|
| 235 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:89 |
| 236 |
msgid "**Formatting**" |
| 237 |
msgstr "" |
| 238 |
|
| 239 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:91 |
| 240 |
msgid "" |
| 241 |
"Suppose you want the ``series_index`` to be formatted as three digits with " |
| 242 |
"leading zeros. This does the trick:" |
| 243 |
msgstr "" |
| 244 |
|
| 245 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:93 |
| 246 |
msgid "``{series_index:0>3s}`` - Three digits with leading zeros" |
| 247 |
msgstr "" |
| 248 |
|
| 249 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:95 |
| 250 |
msgid "For trailing zeros, use:" |
| 251 |
msgstr "" |
| 252 |
|
| 253 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:97 |
| 254 |
msgid "``{series_index:0<3s}`` - Three digits with trailing zeros" |
| 255 |
msgstr "" |
| 256 |
|
| 257 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:99 |
| 258 |
msgid "" |
| 259 |
"If you use series indices with fractional values, e.g., 1.1, you might want " |
| 260 |
"the decimal points to line up. For example, you might want the indices 1 and" |
| 261 |
" 2.5 to appear as 01.00 and 02.50 so that they will sort correctly on a " |
| 262 |
"device that does lexical sorting. To do this, use:" |
| 263 |
msgstr "" |
| 264 |
|
| 265 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:101 |
| 266 |
msgid "" |
| 267 |
"``{series_index:0>5.2f}`` - Five characters consisting of two digits with " |
| 268 |
"leading zeros, a decimal point, then 2 digits after the decimal point." |
| 269 |
msgstr "" |
| 270 |
|
| 271 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:103 |
| 272 |
msgid "If you want only the first two letters of the data, use:" |
| 273 |
msgstr "" |
| 274 |
|
| 275 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:105 |
| 276 |
msgid "" |
| 277 |
"``{author_sort:.2}`` - Only the first two letters of the author sort name" |
| 278 |
msgstr "" |
| 279 |
|
| 280 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:107 |
| 281 |
msgid "" |
| 282 |
"Much of the calibre template language formatting comes from Python. For more" |
| 283 |
" details on the syntax of these advanced formatting operations see the " |
| 284 |
"`Python documentation " |
| 285 |
"<https://docs.python.org/3/library/string.html#formatstrings>`_." |
| 286 |
msgstr "" |
| 287 |
|
| 288 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:111 |
| 289 |
msgid "Using templates to define custom columns" |
| 290 |
msgstr "" |
| 291 |
|
| 292 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:113 |
| 293 |
msgid "" |
| 294 |
"Templates can be used to display information that isn't in calibre metadata," |
| 295 |
" or to display metadata differently from calibre's normal format. For " |
| 296 |
"example, you might want to show the ``ISBN``, a field that calibre does not " |
| 297 |
"display. You can accomplish this creating a custom column with the type " |
| 298 |
"`Column built from other columns` (hereafter called `composite columns`) and" |
| 299 |
" providing a template to generate the displayed text. The column will " |
| 300 |
"display the result of evaluating the template. For example, to display the " |
| 301 |
"ISBN, create the column and enter ``{identifiers:select(isbn)}`` in the " |
| 302 |
"template box. To display a column containing the values of two series custom" |
| 303 |
" columns, separated by a comma, use ``{#series1:||,}{#series2}``." |
| 304 |
msgstr "" |
| 305 |
|
| 306 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:115 |
| 307 |
msgid "Composite columns can use any template option, including formatting." |
| 308 |
msgstr "" |
| 309 |
|
| 310 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:117 |
| 311 |
msgid "" |
| 312 |
"Note: You cannot edit the data displayed in a composite column. Instead you " |
| 313 |
"edit the source columns. If you edit a composite column, for example by " |
| 314 |
"double-clicking it, calibre will open the template for editing, not the " |
| 315 |
"underlying data." |
| 316 |
msgstr "" |
| 317 |
|
| 318 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:122 |
| 319 |
msgid "Using functions in templates - Single Function Mode" |
| 320 |
msgstr "" |
| 321 |
|
| 322 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:124 |
| 323 |
msgid "" |
| 324 |
"Suppose you want to display the value of a field in upper case when that " |
| 325 |
"field is normally in title case. You can do this using `template functions`." |
| 326 |
" For example, to display the title in upper case use the ``uppercase`` " |
| 327 |
"function, as in ``{title:uppercase()}``. To display it in title case, use " |
| 328 |
"``{title:titlecase()}``." |
| 329 |
msgstr "" |
| 330 |
|
| 331 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:126 |
| 332 |
msgid "" |
| 333 |
"Functions go into the format part of the template, after the ``:`` and " |
| 334 |
"before the first ``|`` or the closing ``}`` if no prefix/suffix is used. If " |
| 335 |
"you have both a format and a function reference, the function comes after a " |
| 336 |
"second ``:``. Functions return the value of the column specified in the " |
| 337 |
"template, suitably modified." |
| 338 |
msgstr "" |
| 339 |
|
| 340 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:128 |
| 341 |
msgid "The syntax for using functions is one of::" |
| 342 |
msgstr "" |
| 343 |
|
| 344 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:135 |
| 345 |
msgid "" |
| 346 |
"Function names must always be followed by opening and closing parentheses. " |
| 347 |
"Some functions require extra values (arguments), and these go inside the " |
| 348 |
"parentheses. Arguments are separated by commas. Literal commas (commas as " |
| 349 |
"text, not argument separators) must be preceded by a backslash (``\\``) . " |
| 350 |
"The last (or only) argument cannot contain a textual closing parenthesis." |
| 351 |
msgstr "" |
| 352 |
|
| 353 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:137 |
| 354 |
msgid "" |
| 355 |
"Functions are evaluated before format specifications and the prefix/suffix. " |
| 356 |
"See further down for an example of using both a format and a function." |
| 357 |
msgstr "" |
| 358 |
|
| 359 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:139 |
| 360 |
msgid "" |
| 361 |
"**Important**: If you have programming experience, please note that the " |
| 362 |
"syntax in `Single Function Mode` is not what you expect. Strings are not " |
| 363 |
"quoted and spaces are significant. All arguments are considered to be " |
| 364 |
"constants; there are no expressions." |
| 365 |
msgstr "" |
| 366 |
|
| 367 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:141 |
| 368 |
msgid "" |
| 369 |
"**Do not use subtemplates (`{ ... }`) as function arguments.** Instead, use " |
| 370 |
":ref:`Template Program Mode <template_mode>` and :ref:`General Program Mode " |
| 371 |
"<general_mode>`." |
| 372 |
msgstr "" |
| 373 |
|
| 374 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:143 |
| 375 |
msgid "" |
| 376 |
"Some functions require regular expressions. In the template language regular" |
| 377 |
" expression matching is case-insensitive." |
| 378 |
msgstr "" |
| 379 |
|
| 380 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:145 |
| 381 |
msgid "" |
| 382 |
"In the function documentation below, the notation ``[something]*`` means " |
| 383 |
"that ``something`` can be repeated zero or more times. The notation " |
| 384 |
"``[something]+`` means that the ``something`` is repeated one or more times " |
| 385 |
"(must exist at least one time)." |
| 386 |
msgstr "" |
| 387 |
|
| 388 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:147 |
| 389 |
msgid "The functions intended for use in Single Function Mode are:" |
| 390 |
msgstr "" |
| 391 |
|
| 392 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:150 |
| 393 |
msgid "" |
| 394 |
"``capitalize()`` -- returns the value with the first letter upper case and " |
| 395 |
"the rest lower case." |
| 396 |
msgstr "" |
| 397 |
|
| 398 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:151 |
| 399 |
msgid "" |
| 400 |
"``contains(pattern, text if match, text if not match)`` -- checks if the " |
| 401 |
"value is matched by the regular expression ``pattern``. Returns ``text if " |
| 402 |
"match`` if the pattern matches the value, otherwise returns ``text if no " |
| 403 |
"match``." |
| 404 |
msgstr "" |
| 405 |
|
| 406 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:152 |
| 407 |
msgid "" |
| 408 |
"``count(separator)`` -- interprets the value as a list of items separated by" |
| 409 |
" ``separator`` and returns the number of items in the list. Most lists use a" |
| 410 |
" comma as the separator, but ``authors`` uses an ampersand (&). Examples: " |
| 411 |
"``{tags:count(,)}``, ``{authors:count(&)}``. Aliases: ``count()``, " |
| 412 |
"``list_count()``" |
| 413 |
msgstr "" |
| 414 |
|
| 415 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:153 |
| 416 |
msgid "" |
| 417 |
"``format_number(template)`` -- interprets the value as a number and formats " |
| 418 |
"that number using a Python formatting template such as ``{0:5.2f}`` or " |
| 419 |
"``{0:,d}`` or ``${0:5,.2f}``. The formatting template must begin with " |
| 420 |
"``{0:`` and end with ``}`` as in the above examples. Exception: you can " |
| 421 |
"leave off the leading \"{0:\" and trailing \"}\" if the format template " |
| 422 |
"contains only a format. See the template language and the `Python " |
| 423 |
"documentation " |
| 424 |
"<https://docs.python.org/3/library/string.html#formatstrings>`_ for more " |
| 425 |
"examples. Returns the empty string if formatting fails." |
| 426 |
msgstr "" |
| 427 |
|
| 428 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:154 |
| 429 |
msgid "" |
| 430 |
"``human_readable()`` -- expects the value to be a number and returns a " |
| 431 |
"string representing that number in KB, MB, GB, etc." |
| 432 |
msgstr "" |
| 433 |
|
| 434 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:155 |
| 435 |
msgid "" |
| 436 |
"``ifempty(text if empty)`` -- if the value is not empty then return the " |
| 437 |
"value of the field, otherwise return `text if empty`." |
| 438 |
msgstr "" |
| 439 |
|
| 440 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:156 |
| 441 |
msgid "" |
| 442 |
"``in_list(separator, [ pattern, found_val, ]* not_found_val)`` -- interpret " |
| 443 |
"the value as a list of items separated by ``separator``, checking the " |
| 444 |
"``pattern`` against each item in the list. If the ``pattern`` matches an " |
| 445 |
"item then return ``found_val``, otherwise return ``not_found_val``. The pair" |
| 446 |
" ``pattern`` and ``found_value`` can be repeated as many times as desired, " |
| 447 |
"permitting returning different values depending on the item's value. The " |
| 448 |
"patterns are checked in order, and the first match is returned." |
| 449 |
msgstr "" |
| 450 |
|
| 451 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:157 |
| 452 |
msgid "" |
| 453 |
"``language_strings(localize)`` -- return the `language names " |
| 454 |
"<https://www.loc.gov/standards/iso639-2/php/code_list.php>`_ for the " |
| 455 |
"`language codes <https://www.loc.gov/standards/iso639-2/php/code_list.php>`_" |
| 456 |
" passed in as the value. Example: ``{languages:language_strings()}``. If " |
| 457 |
"``localize`` is zero, return the strings in English. If ``localize`` is not " |
| 458 |
"zero, return the strings in the language of the current locale. " |
| 459 |
"``Lang_codes`` is a comma-separated list." |
| 460 |
msgstr "" |
| 461 |
|
| 462 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:158 |
| 463 |
msgid "" |
| 464 |
"``list_item(index, separator)`` -- interpret the value as a list of items " |
| 465 |
"separated by ``separator``, returning the 'index'th item. The first item is " |
| 466 |
"number zero. The last item has the index ``-1`` as in " |
| 467 |
"``list_item(-1,separator)``. If the item is not in the list, then the empty " |
| 468 |
"string is returned." |
| 469 |
msgstr "" |
| 470 |
|
| 471 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:159 |
| 472 |
msgid "" |
| 473 |
"``lookup([ pattern, key, ]* else_key)`` -- The patterns will be checked " |
| 474 |
"against the value in order. If a pattern matches then the value of the field" |
| 475 |
" named by ``key`` is returned. If no pattern matches then the value of the " |
| 476 |
"field named by ``else_key`` is returned. See``switch`` (below)." |
| 477 |
msgstr "" |
| 478 |
|
| 479 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:160 |
| 480 |
msgid "``lowercase()`` -- returns the value of the field in lower case." |
| 481 |
msgstr "" |
| 482 |
|
| 483 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:161 |
| 484 |
msgid "" |
| 485 |
"``rating_to_stars(use_half_stars)`` -- Returns the rating as string of star " |
| 486 |
"(``★``) characters. The value must be a number between 0 and 5. Set " |
| 487 |
"use_half_stars to 1 if you want half star characters for fractional numbers " |
| 488 |
"available with custom ratings columns." |
| 489 |
msgstr "" |
| 490 |
|
| 491 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:162 |
| 492 |
msgid "" |
| 493 |
"``re(pattern, replacement)`` -- return the value after applying the regular " |
| 494 |
"expression. All instances of ``pattern`` in the value are replaced with " |
| 495 |
"``replacement``. The template language uses case insensitive `Python regular" |
| 496 |
" expressions <https://docs.python.org/3/library/re.html>`_." |
| 497 |
msgstr "" |
| 498 |
|
| 499 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:163 |
| 500 |
msgid "" |
| 501 |
"``select(key)`` -- interpret the value as a comma-separated list of items " |
| 502 |
"with each item having the form ``id:value`` (the calibre ``identifier`` " |
| 503 |
"format). The function finds the first pair with the id equal to key and " |
| 504 |
"returns the corresponding value. If no id matches then the function returns " |
| 505 |
"the empty string." |
| 506 |
msgstr "" |
| 507 |
|
| 508 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:164 |
| 509 |
msgid "" |
| 510 |
"``shorten(left chars, middle text, right chars)`` -- Return a shortened " |
| 511 |
"version of the value, consisting of ``left chars`` characters from the " |
| 512 |
"beginning of the value, followed by ``middle text``, followed by ``right " |
| 513 |
"chars`` characters from the end of the value. ``Left chars`` and ``right " |
| 514 |
"chars`` must be non-negative integers. Example: assume you want to display " |
| 515 |
"the title with a length of at most 15 characters in length. One template " |
| 516 |
"that does this is ``{title:shorten(9,-,5)}``. For a book with the title " |
| 517 |
"`Ancient English Laws in the Times of Ivanhoe` the result will be `Ancient " |
| 518 |
"E-anhoe`: the first 9 characters of the title, a ``-``, then the last 5 " |
| 519 |
"characters. If the value's length is less than ``left chars`` + ``right " |
| 520 |
"chars`` + the length of ``middle text`` then the value will be returned " |
| 521 |
"unchanged. For example, the title `The Dome` would not be changed." |
| 522 |
msgstr "" |
| 523 |
|
| 524 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:165 |
| 525 |
msgid "" |
| 526 |
"``str_in_list(separator, [ string, found_val, ]+ not_found_val)`` -- " |
| 527 |
"interpret the value as a list of items separated by ``separator`` then " |
| 528 |
"compare ``string`` against each value in the list. The ``string`` is not a " |
| 529 |
"regular expression. If ``string`` is equal to any item (ignoring case) then " |
| 530 |
"return the corresponding ``found_val``. If ``string`` contains " |
| 531 |
"``separators`` then it is also treated as a list and each subvalue is " |
| 532 |
"checked. The ``string`` and ``found_value`` pairs can be repeated as many " |
| 533 |
"times as desired, permitting returning different values depending on " |
| 534 |
"string's value. If none of the strings match then ``not_found_value`` is " |
| 535 |
"returned. The strings are checked in order. The first match is returned." |
| 536 |
msgstr "" |
| 537 |
|
| 538 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:166 |
| 539 |
msgid "" |
| 540 |
"``subitems(start_index, end_index)`` -- This function breaks apart lists of " |
| 541 |
"tag-like hierarchical items such as genres. It interprets the value as a " |
| 542 |
"comma-separated list of tag-like items, where each item is a period-" |
| 543 |
"separated list. It returns a new list made by extracting from each item the " |
| 544 |
"components from ``start_index`` to ``end_index``, then merging the results " |
| 545 |
"back together. Duplicates are removed. The first subitem in a period-" |
| 546 |
"separated list has an index of zero. If an index is negative then it counts " |
| 547 |
"from the end of the list. As a special case, an end_index of zero is assumed" |
| 548 |
" to be the length of the list." |
| 549 |
msgstr "" |
| 550 |
|
| 551 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:168 |
| 552 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:351 |
| 553 |
msgid "Examples:" |
| 554 |
msgstr "" |
| 555 |
|
| 556 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:170 |
| 557 |
msgid "Assuming a #genre column containing `A.B.C`:" |
| 558 |
msgstr "" |
| 559 |
|
| 560 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:172 |
| 561 |
msgid "``{#genre:subitems(0,1)}`` returns \"A\"" |
| 562 |
msgstr "" |
| 563 |
|
| 564 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:173 |
| 565 |
msgid "``{#genre:subitems(0,2)}`` returns \"A.B\"" |
| 566 |
msgstr "" |
| 567 |
|
| 568 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:174 |
| 569 |
msgid "``{#genre:subitems(1,0)}`` returns \"B.C\"" |
| 570 |
msgstr "" |
| 571 |
|
| 572 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:176 |
| 573 |
msgid "Assuming a #genre column containing \"A.B.C, D.E\":" |
| 574 |
msgstr "" |
| 575 |
|
| 576 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:178 |
| 577 |
msgid "``{#genre:subitems(0,1)}`` returns \"A, D\"" |
| 578 |
msgstr "" |
| 579 |
|
| 580 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:179 |
| 581 |
msgid "``{#genre:subitems(0,2)}`` returns \"A.B, D.E\"" |
| 582 |
msgstr "" |
| 583 |
|
| 584 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:181 |
| 585 |
msgid "" |
| 586 |
"``sublist(start_index, end_index, separator)`` -- interpret the value as a " |
| 587 |
"list of items separated by ``separator``, returning a new list made from the" |
| 588 |
" items from ``start_index`` to ``end_index``. The first item is number zero." |
| 589 |
" If an index is negative, then it counts from the end of the list. As a " |
| 590 |
"special case, an end_index of zero is assumed to be the length of the list." |
| 591 |
msgstr "" |
| 592 |
|
| 593 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:183 |
| 594 |
msgid "" |
| 595 |
"Examples assuming that the tags column (which is comma-separated) contains " |
| 596 |
"\"A, B ,C\":" |
| 597 |
msgstr "" |
| 598 |
|
| 599 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:185 |
| 600 |
msgid "``{tags:sublist(0,1,\\,)}`` returns \"A\"" |
| 601 |
msgstr "" |
| 602 |
|
| 603 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:186 |
| 604 |
msgid "``{tags:sublist(-1,0,\\,)}`` returns \"C\"" |
| 605 |
msgstr "" |
| 606 |
|
| 607 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:187 |
| 608 |
msgid "``{tags:sublist(0,-1,\\,)}`` returns \"A, B\"" |
| 609 |
msgstr "" |
| 610 |
|
| 611 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:189 |
| 612 |
msgid "" |
| 613 |
"``swap_around_articles(separator)`` -- returns the value with articles moved" |
| 614 |
" to the end. The value can be a list, in which case each item in the list is" |
| 615 |
" processed. If the value is a list then you must provide the ``separator``. " |
| 616 |
"If no ``separator`` is provided then the value is treated as being a single " |
| 617 |
"value, not a list. The `articles` are those used by calibre to generate the " |
| 618 |
"``title_sort``." |
| 619 |
msgstr "" |
| 620 |
|
| 621 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:190 |
| 622 |
msgid "" |
| 623 |
"``swap_around_comma()`` -- given a value of the form ``B, A``, return ``A " |
| 624 |
"B``. This is most useful for converting names in LN, FN format to FN LN. If " |
| 625 |
"there is no comma in the value then the function returns the value " |
| 626 |
"unchanged." |
| 627 |
msgstr "" |
| 628 |
|
| 629 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:191 |
| 630 |
msgid "" |
| 631 |
"``switch([pattern, value,]+ else_value)`` -- for each ``pattern, value`` " |
| 632 |
"pair, checks if the value matches the regular expression ``pattern`` and if " |
| 633 |
"so returns the associated ``value``. If no ``pattern`` matches, then " |
| 634 |
"``else_value`` is returned. You can have as many ``pattern, value`` pairs as" |
| 635 |
" you wish. The first match is returned." |
| 636 |
msgstr "" |
| 637 |
|
| 638 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:192 |
| 639 |
msgid "" |
| 640 |
"``test(text if not empty, text if empty)`` -- return ``text if not empty`` " |
| 641 |
"if the value is not empty, otherwise return ``text if empty``." |
| 642 |
msgstr "" |
| 643 |
|
| 644 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:193 |
| 645 |
msgid "``titlecase()`` -- returns the value of the field in title case." |
| 646 |
msgstr "" |
| 647 |
|
| 648 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:194 |
| 649 |
msgid "" |
| 650 |
"``transliterate()`` -- Return a string in a latin alphabet formed by " |
| 651 |
"approximating the sound of the words in the source field. For example, if " |
| 652 |
"the source field is ``Фёдор Миха́йлович Достоевский`` this function returns " |
| 653 |
"``Fiodor Mikhailovich Dostoievskii``." |
| 654 |
msgstr "" |
| 655 |
|
| 656 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:195 |
| 657 |
msgid "``uppercase()`` -- returns the value of the field in upper case." |
| 658 |
msgstr "" |
| 659 |
|
| 660 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:197 |
| 661 |
msgid "**Using functions and formatting in the same template**" |
| 662 |
msgstr "" |
| 663 |
|
| 664 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:199 |
| 665 |
msgid "" |
| 666 |
"Suppose you have an integer custom column ``#myint`` that you want displayed" |
| 667 |
" with leading zeros, as in ``003``. One way to do this is to use a format of" |
| 668 |
" ``0>3s``. However, by default if a number (integer or float) equals zero " |
| 669 |
"then the value is displayed as the empty string so zero values will produce " |
| 670 |
"the empty string, not ``000``. If you want to see ``000`` values then you " |
| 671 |
"use both the format string and the ``ifempty`` function to change the empty " |
| 672 |
"value back to a zero. The template would be::" |
| 673 |
msgstr "" |
| 674 |
|
| 675 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:203 |
| 676 |
msgid "" |
| 677 |
"Note that you can use the prefix and suffix as well. If you want the number " |
| 678 |
"to appear as ``[003]`` or ``[000]``, then use the template::" |
| 679 |
msgstr "" |
| 680 |
|
| 681 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:210 |
| 682 |
msgid "General Program Mode" |
| 683 |
msgstr "" |
| 684 |
|
| 685 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:212 |
| 686 |
msgid "" |
| 687 |
"`General Program Mode` (`GPM`) replaces `template expressions` with a " |
| 688 |
"program written in the `template language`. The syntax of the language is " |
| 689 |
"defined by the following grammar::" |
| 690 |
msgstr "" |
| 691 |
|
| 692 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:251 |
| 693 |
msgid "" |
| 694 |
"a ``top_expression`` always has a value. The value of an ``expression_list``" |
| 695 |
" is the value of the last ``top_expression`` in the list. For example, the " |
| 696 |
"value of the expression list ``1;2;'foobar';3`` is ``3``." |
| 697 |
msgstr "" |
| 698 |
|
| 699 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:252 |
| 700 |
msgid "In a logical context, any non-empty value is ``True``" |
| 701 |
msgstr "" |
| 702 |
|
| 703 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:253 |
| 704 |
msgid "In a logical context, the empty value is ``False``" |
| 705 |
msgstr "" |
| 706 |
|
| 707 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:254 |
| 708 |
msgid "" |
| 709 |
"Strings and numbers can be used interchangeably. For example, ``10`` and " |
| 710 |
"``'10'`` are the same thing." |
| 711 |
msgstr "" |
| 712 |
|
| 713 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:255 |
| 714 |
msgid "" |
| 715 |
"Comments are lines starting with a '#' character. Comments beginning later " |
| 716 |
"in a line are not supported." |
| 717 |
msgstr "" |
| 718 |
|
| 719 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:257 |
| 720 |
msgid "**Operator precedence**" |
| 721 |
msgstr "" |
| 722 |
|
| 723 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:259 |
| 724 |
msgid "" |
| 725 |
"The operator precedence (order of evaluation) from highest (evaluated first)" |
| 726 |
" to lowest (evaluated last) is:" |
| 727 |
msgstr "" |
| 728 |
|
| 729 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:261 |
| 730 |
msgid "" |
| 731 |
"Function calls, constants, parenthesized expressions, statement expressions," |
| 732 |
" assignment expressions, field references." |
| 733 |
msgstr "" |
| 734 |
|
| 735 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:262 |
| 736 |
msgid "" |
| 737 |
"Unary plus (``+``) and minus (``-``). These operators evaluate right to " |
| 738 |
"left." |
| 739 |
msgstr "" |
| 740 |
|
| 741 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:264 |
| 742 |
msgid "" |
| 743 |
"These and all the other arithmetic operators return integers if the " |
| 744 |
"expression results in a fractional part equal to zero. For example, if an " |
| 745 |
"expression returns ``3.0`` it is changed to ``3``." |
| 746 |
msgstr "" |
| 747 |
|
| 748 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:265 |
| 749 |
msgid "" |
| 750 |
"Multiply (``*``) and divide (``/``). These operators are associative and " |
| 751 |
"evaluate left to right. Use parentheses if you want to change the order of " |
| 752 |
"evaluation." |
| 753 |
msgstr "" |
| 754 |
|
| 755 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:266 |
| 756 |
msgid "" |
| 757 |
"Add (``+``) and subtract (``-``). These operators are associative and " |
| 758 |
"evaluate left to right." |
| 759 |
msgstr "" |
| 760 |
|
| 761 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:267 |
| 762 |
msgid "" |
| 763 |
"Numeric and string comparisons. These operators return ``'1'`` if the " |
| 764 |
"comparison succeeds, otherwise the empty string (``''``). Comparisons are " |
| 765 |
"not associative: ``a < b < c`` is a syntax error." |
| 766 |
msgstr "" |
| 767 |
|
| 768 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:268 |
| 769 |
msgid "" |
| 770 |
"Unary logical not (``!``). This operator returns ``'1'`` if the expression " |
| 771 |
"is False (evaluates to the empty string), otherwise ``''``." |
| 772 |
msgstr "" |
| 773 |
|
| 774 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:269 |
| 775 |
msgid "" |
| 776 |
"Logical and (``&&``). This operator returns '1' if both the left-hand and " |
| 777 |
"right-hand expressions are True, or the empty string ``''`` if either is " |
| 778 |
"False. It is associative, evaluates left to right, and does `short-" |
| 779 |
"circuiting <https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_." |
| 780 |
msgstr "" |
| 781 |
|
| 782 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:270 |
| 783 |
msgid "" |
| 784 |
"Logical or (``||``). This operator returns ``'1'`` if either the left-hand " |
| 785 |
"or right-hand expression is True, or ``''`` if both are False. It is " |
| 786 |
"associative, evaluates left to right, and does `short-circuiting " |
| 787 |
"<https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_. It is an " |
| 788 |
"`inclusive or`, returning ``'1'`` if both the left- and right-hand " |
| 789 |
"expressions are True." |
| 790 |
msgstr "" |
| 791 |
|
| 792 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:272 |
| 793 |
msgid "**Field references**" |
| 794 |
msgstr "" |
| 795 |
|
| 796 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:274 |
| 797 |
msgid "" |
| 798 |
"A ``field_reference`` evaluates to the value of the metadata field named by " |
| 799 |
"lookup name that follows the ``$`` or ``$$``. Using ``$`` is equivalent to " |
| 800 |
"using the ``field()`` function. Using ``$$`` is equivalent to using the " |
| 801 |
"``raw_field`` function. Examples::" |
| 802 |
msgstr "" |
| 803 |
|
| 804 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:281 |
| 805 |
msgid "**If expressions**" |
| 806 |
msgstr "" |
| 807 |
|
| 808 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:283 |
| 809 |
msgid "" |
| 810 |
"``If`` expressions first evaluate the ``condition``. If the ``condition`` is" |
| 811 |
" True (a non-empty value) then the ``expression_list`` in the ``then`` " |
| 812 |
"clause is evaluated. If it is False then if present the ``expression_list`` " |
| 813 |
"in the ``elif`` or ``else`` clause is evaluated. The ``elif`` and ``else`` " |
| 814 |
"parts are optional. The words ``if``, ``then``, ``elif``, ``else``, and " |
| 815 |
"``fi`` are reserved; you cannot use them as identifier names. You can put " |
| 816 |
"newlines and white space wherever they make sense. The ``condition`` is a " |
| 817 |
"``top_expression`` not an ``expression_list``; semicolons are not allowed. " |
| 818 |
"The ``expression_lists`` are semicolon-separated sequences of " |
| 819 |
"``top_expressions``. An ``if`` expression returns the result of the last " |
| 820 |
"``top_expression`` in the evaluated ``expression_list``, or the empty string" |
| 821 |
" if no expression list was evaluated." |
| 822 |
msgstr "" |
| 823 |
|
| 824 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:285 |
| 825 |
msgid "Examples::" |
| 826 |
msgstr "" |
| 827 |
|
| 828 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:298 |
| 829 |
msgid "Nested ``if`` example::" |
| 830 |
msgstr "" |
| 831 |
|
| 832 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:311 |
| 833 |
msgid "" |
| 834 |
"As said above, an ``if`` produces a value. This means that all the following" |
| 835 |
" are equivalent::" |
| 836 |
msgstr "" |
| 837 |
|
| 838 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:317 |
| 839 |
msgid "" |
| 840 |
"As a last example, this program returns the value of the ``series`` column " |
| 841 |
"if the book has a series, otherwise the value of the ``title`` column::" |
| 842 |
msgstr "" |
| 843 |
|
| 844 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:321 |
| 845 |
msgid "**For expressions**" |
| 846 |
msgstr "" |
| 847 |
|
| 848 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:323 |
| 849 |
msgid "" |
| 850 |
"The ``for`` expression iterates over a list of values, processing them one " |
| 851 |
"at a time. The ``list_expression`` must evaluate to either a metadata field " |
| 852 |
"``lookup name``, for example ``tags`` or ``#genre``, or a list of values. If" |
| 853 |
" the result is a valid ``lookup name`` then the field's value is fetched and" |
| 854 |
" the separator specified for that field type is used. If the result isn't a " |
| 855 |
"valid lookup name then it is assumed to be a list of values. The list is " |
| 856 |
"assumed to be separated by commas unless the optional keyword ``separator`` " |
| 857 |
"is supplied, in which case the list values must be separated by the result " |
| 858 |
"of evaluating the ``separator_expr``. Each value in the list is assigned to " |
| 859 |
"the specified variable then the ``expression_list`` is evaluated. You can " |
| 860 |
"use ``break`` to jump out of the loop, and ``continue`` to jump to the " |
| 861 |
"beginning of the loop for the next iteration." |
| 862 |
msgstr "" |
| 863 |
|
| 864 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:325 |
| 865 |
msgid "" |
| 866 |
"Example: This template removes the first hierarchical name for each value in" |
| 867 |
" Genre (``#genre``), constructing a list with the new names::" |
| 868 |
msgstr "" |
| 869 |
|
| 870 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:335 |
| 871 |
msgid "" |
| 872 |
"If the original Genre is `History.Military, Science Fiction.Alternate " |
| 873 |
"History, ReadMe` then the template returns `Military, Alternate History, " |
| 874 |
"ReadMe`. You could use this template in calibre's :guilabel:`Edit metadata " |
| 875 |
"in bulk -> Search & replace` with :guilabel:`Search for` set to ``template``" |
| 876 |
" to strip off the first level of the hierarchy and assign the resulting " |
| 877 |
"value to Genre." |
| 878 |
msgstr "" |
| 879 |
|
| 880 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:338 |
| 881 |
msgid "" |
| 882 |
"Note: the last line in the template, ``new_tags``, isn't strictly necessary " |
| 883 |
"in this case because ``for`` returns the value of the last top_expression in" |
| 884 |
" the expression list. The value of an assignment is the value of its " |
| 885 |
"expression, so the value of the ``for`` statement is what was assigned to " |
| 886 |
"``new_tags``." |
| 887 |
msgstr "" |
| 888 |
|
| 889 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:340 |
| 890 |
msgid "**Relational operators**" |
| 891 |
msgstr "" |
| 892 |
|
| 893 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:342 |
| 894 |
msgid "" |
| 895 |
"Relational operators return ``'1'`` if the comparison is true, otherwise the" |
| 896 |
" empty string ('')." |
| 897 |
msgstr "" |
| 898 |
|
| 899 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:344 |
| 900 |
msgid "" |
| 901 |
"There are two forms of relational operators: string comparisons and numeric " |
| 902 |
"comparisons." |
| 903 |
msgstr "" |
| 904 |
|
| 905 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:346 |
| 906 |
msgid "" |
| 907 |
"String comparisons do case-insensitive string comparison using lexical " |
| 908 |
"order. The supported string comparison operators are ``==``, ``!=``, ``<``, " |
| 909 |
"``<=``, ``>``, ``>=``, ``in``, and ``inlist``. For the ``in`` operator, the " |
| 910 |
"result of the left hand expression is interpreted as a regular expression " |
| 911 |
"pattern. The ``in`` operator is True if the value of left-hand regular " |
| 912 |
"expression matches the value of the right hand expression. The ``inlist`` " |
| 913 |
"operator is true if the left hand regular expression matches any one of the " |
| 914 |
"items in the right hand list where the items in the list are separated by " |
| 915 |
"commas. The matches are case-insensitive." |
| 916 |
msgstr "" |
| 917 |
|
| 918 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:349 |
| 919 |
msgid "" |
| 920 |
"The numeric comparison operators are ``==#``, ``!=#``, ``<#``, ``<=#``, " |
| 921 |
"``>#``, ``>=#``. The left and right expressions must evaluate to numeric " |
| 922 |
"values with two exceptions: both the string value \"None\" (undefined field)" |
| 923 |
" and the empty string evaluate to the value zero." |
| 924 |
msgstr "" |
| 925 |
|
| 926 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:353 |
| 927 |
msgid "" |
| 928 |
"``program: field('series') == 'foo'`` returns ``'1'`` if the book's series " |
| 929 |
"is 'foo', otherwise ``''``." |
| 930 |
msgstr "" |
| 931 |
|
| 932 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:354 |
| 933 |
msgid "" |
| 934 |
"``program: 'f.o' in field('series')`` returns ``'1'`` if the book's series " |
| 935 |
"matches the regular expression ``f.o`` (e.g., `foo`, `Off Onyx`, etc.), " |
| 936 |
"otherwise ``''``." |
| 937 |
msgstr "" |
| 938 |
|
| 939 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:355 |
| 940 |
msgid "" |
| 941 |
"``program: 'science' inlist field('#genre')`` returns ``'1'`` if any of the " |
| 942 |
"book's genres match the regular expression ``science``, e.g., `Science`, " |
| 943 |
"`History of Science`, `Science Fiction` etc.), otherwise ``''``." |
| 944 |
msgstr "" |
| 945 |
|
| 946 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:356 |
| 947 |
msgid "" |
| 948 |
"``program: '^science$' inlist field('#genre')`` returns ``'1'`` if any of " |
| 949 |
"the book's genres exactly match the regular expression ``^science$``, e.g., " |
| 950 |
"`Science`. The genres `History of Science` and `Science Fiction` don't " |
| 951 |
"match. If there isn't a match then returns ``''``." |
| 952 |
msgstr "" |
| 953 |
|
| 954 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:357 |
| 955 |
msgid "" |
| 956 |
"``program: if field('series') != 'foo' then 'bar' else 'mumble' fi`` returns" |
| 957 |
" ``'bar'`` if the book's series is not ``foo``. Otherwise it returns " |
| 958 |
"``'mumble'``." |
| 959 |
msgstr "" |
| 960 |
|
| 961 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:358 |
| 962 |
msgid "" |
| 963 |
"``program: if field('series') == 'foo' || field('series') == '1632' then " |
| 964 |
"'yes' else 'no' fi`` returns ``'yes'`` if series is either ``'foo'`` or " |
| 965 |
"``'1632'``, otherwise ``'no'``." |
| 966 |
msgstr "" |
| 967 |
|
| 968 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:359 |
| 969 |
msgid "" |
| 970 |
"``program: if '^(foo|1632)$' in field('series') then 'yes' else 'no' fi`` " |
| 971 |
"returns ``'yes'`` if series is either ``'foo'`` or ``'1632'``, otherwise " |
| 972 |
"``'no'``." |
| 973 |
msgstr "" |
| 974 |
|
| 975 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:360 |
| 976 |
msgid "" |
| 977 |
"``program: if 11 > 2 then 'yes' else 'no' fi`` returns ``'no'`` because the " |
| 978 |
"``>`` operator does a lexical comparison." |
| 979 |
msgstr "" |
| 980 |
|
| 981 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:361 |
| 982 |
msgid "" |
| 983 |
"``program: if 11 ># 2 then 'yes' else 'no' fi`` returns ``'yes'`` because " |
| 984 |
"the ``>#`` operator does a numeric comparison." |
| 985 |
msgstr "" |
| 986 |
|
| 987 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:363 |
| 988 |
msgid "**Additional available functions**" |
| 989 |
msgstr "" |
| 990 |
|
| 991 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:365 |
| 992 |
msgid "" |
| 993 |
"The following functions are available in addition to those described in " |
| 994 |
":ref:`Single Function Mode <single_mode>`." |
| 995 |
msgstr "" |
| 996 |
|
| 997 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:367 |
| 998 |
msgid "" |
| 999 |
"In `GPM` the functions described in `Single Function Mode` all require an " |
| 1000 |
"additional first parameter specifying the value to operate upon. All " |
| 1001 |
"parameters are expression_lists (see the grammar above)." |
| 1002 |
msgstr "" |
| 1003 |
|
| 1004 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:369 |
| 1005 |
msgid "" |
| 1006 |
"``add(x [, y]*)`` -- returns the sum of its arguments. Throws an exception " |
| 1007 |
"if an argument is not a number. In most cases you can use the ``+`` operator" |
| 1008 |
" instead of this function." |
| 1009 |
msgstr "" |
| 1010 |
|
| 1011 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:370 |
| 1012 |
msgid "" |
| 1013 |
"``and(value [, value]*)`` -- returns the string \"1\" if all values are not " |
| 1014 |
"empty, otherwise returns the empty string. You can have as many values as " |
| 1015 |
"you want. In most cases you can use the ``&&`` operator instead of this " |
| 1016 |
"function. One reason not to replace ``and`` with ``&&`` is if short-" |
| 1017 |
"circuiting can change the results because of side effects. For example, " |
| 1018 |
"``and(a='',b=5)`` will always do both assignments, where the ``&&`` operator" |
| 1019 |
" won't do the second." |
| 1020 |
msgstr "" |
| 1021 |
|
| 1022 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:371 |
| 1023 |
msgid "" |
| 1024 |
"``assign(id, val)`` -- assigns ``val`` to ``id``, then returns ``val``. " |
| 1025 |
"``id`` must be an identifier, not an expression. In most cases you can use " |
| 1026 |
"the ``=`` operator instead of this function." |
| 1027 |
msgstr "" |
| 1028 |
|
| 1029 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:372 |
| 1030 |
msgid "" |
| 1031 |
"``approximate_formats()`` -- return a comma-separated list of formats " |
| 1032 |
"associated with the book. There is no guarantee that the list is correct, " |
| 1033 |
"although it probably is. This and other zero-parameter functions can be " |
| 1034 |
"called in Template Program Mode (see below) using the template " |
| 1035 |
"``{:'approximate_formats()'}``. Note that resulting format names are always " |
| 1036 |
"uppercase, as in EPUB. The ``approximate_formats()`` function is " |
| 1037 |
"significantly faster than the ``formats_...`` functions discussed below." |
| 1038 |
msgstr "" |
| 1039 |
|
| 1040 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:373 |
| 1041 |
msgid "" |
| 1042 |
"``author_links(val_separator, pair_separator)`` -- returns a string " |
| 1043 |
"containing a list of authors and those authors' link values in the form::" |
| 1044 |
msgstr "" |
| 1045 |
|
| 1046 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:377 |
| 1047 |
msgid "" |
| 1048 |
"An author is separated from its link value by the ``val_separator`` string " |
| 1049 |
"with no added spaces. ``author:linkvalue`` pairs are separated by the " |
| 1050 |
"``pair_separator`` string argument with no added spaces. It is up to you to " |
| 1051 |
"choose separator strings that do not occur in author names or links. An " |
| 1052 |
"author is included even if the author link is empty." |
| 1053 |
msgstr "" |
| 1054 |
|
| 1055 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:378 |
| 1056 |
msgid "" |
| 1057 |
"``author_sorts(val_separator)`` -- returns a string containing a list of " |
| 1058 |
"author's sort values for the authors of the book. The sort is the one in the" |
| 1059 |
" author metadata information (different from the author_sort in books). The " |
| 1060 |
"returned list has the form ``author sort 1`` ``val_separator`` ``author sort" |
| 1061 |
" 2`` etc. with no added spaces. The author sort values in this list are in " |
| 1062 |
"the same order as the authors of the book. If you want spaces around " |
| 1063 |
"``val_separator`` then include them in the ``val_separator`` string." |
| 1064 |
msgstr "" |
| 1065 |
|
| 1066 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:379 |
| 1067 |
msgid "" |
| 1068 |
"``booksize()`` -- returns the value of the calibre 'size' field. Returns '' " |
| 1069 |
"if there are no formats." |
| 1070 |
msgstr "" |
| 1071 |
|
| 1072 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:380 |
| 1073 |
msgid "" |
| 1074 |
"``check_yes_no(field_name, is_undefined, is_false, is_true)`` -- checks if " |
| 1075 |
"the value of the yes/no field named by the lookup name ``field_name`` is one" |
| 1076 |
" of the values specified by the parameters, returning ``'yes'`` if a match " |
| 1077 |
"is found otherwise returning the empty string. Set the parameter " |
| 1078 |
"``is_undefined``, ``is_false``, or ``is_true`` to 1 (the number) to check " |
| 1079 |
"that condition, otherwise set it to 0. Example:" |
| 1080 |
msgstr "" |
| 1081 |
|
| 1082 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:382 |
| 1083 |
msgid "" |
| 1084 |
"``check_yes_no(\"#bool\", 1, 0, 1)`` returns ``'yes'`` if the yes/no field " |
| 1085 |
"``#bool`` is either True or undefined (neither True nor False)." |
| 1086 |
msgstr "" |
| 1087 |
|
| 1088 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:384 |
| 1089 |
msgid "" |
| 1090 |
"More than one of ``is_undefined``, ``is_false``, or ``is_true`` can be set " |
| 1091 |
"to 1." |
| 1092 |
msgstr "" |
| 1093 |
|
| 1094 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:385 |
| 1095 |
msgid "" |
| 1096 |
"``ceiling(x)`` -- returns the smallest integer greater than or equal to " |
| 1097 |
"``x``. Throws an exception if ``x`` is not a number." |
| 1098 |
msgstr "" |
| 1099 |
|
| 1100 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:386 |
| 1101 |
msgid "" |
| 1102 |
"``character(character_name)`` -- returns the character named by " |
| 1103 |
"character_name. For example, ``character('newline')`` returns a newline " |
| 1104 |
"character (``'\\n'``). The supported character names are ``newline``, " |
| 1105 |
"``return``, ``tab``, and ``backslash``." |
| 1106 |
msgstr "" |
| 1107 |
|
| 1108 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:387 |
| 1109 |
msgid "" |
| 1110 |
"``cmp(x, y, lt, eq, gt)`` -- compares ``x`` and ``y`` after converting both " |
| 1111 |
"to numbers. Returns ``lt`` if ``x <# y``, ``eq`` if ``x ==# y``, otherwise " |
| 1112 |
"``gt``. This function can usually be replaced with one of the numeric " |
| 1113 |
"compare operators (``==#``, ``<#``, ``>#``, etc)." |
| 1114 |
msgstr "" |
| 1115 |
|
| 1116 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:388 |
| 1117 |
msgid "" |
| 1118 |
"``connected_device_name(storage_location_key)`` -- if a device is connected " |
| 1119 |
"then return the device name, otherwise return the empty string. Each storage" |
| 1120 |
" location on a device has its own device name. The ``storage_location_key`` " |
| 1121 |
"names are ``'main'``, ``'carda'`` and ``'cardb'``. This function works only " |
| 1122 |
"in the GUI." |
| 1123 |
msgstr "" |
| 1124 |
|
| 1125 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:389 |
| 1126 |
msgid "" |
| 1127 |
"``connected_device_uuid(storage_location_key)`` -- if a device is connected " |
| 1128 |
"then return the device uuid (unique id), otherwise return the empty string. " |
| 1129 |
"Each storage location on a device has a different uuid. The " |
| 1130 |
"``storage_location_key`` location names are ``'main'``, ``'carda'`` and " |
| 1131 |
"``'cardb'``. This function works only in the GUI." |
| 1132 |
msgstr "" |
| 1133 |
|
| 1134 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:390 |
| 1135 |
msgid "" |
| 1136 |
"``current_library_name()`` -- return the last name on the path to the " |
| 1137 |
"current calibre library." |
| 1138 |
msgstr "" |
| 1139 |
|
| 1140 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:391 |
| 1141 |
msgid "" |
| 1142 |
"``current_library_path()`` -- return the full path to the current calibre " |
| 1143 |
"library." |
| 1144 |
msgstr "" |
| 1145 |
|
| 1146 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:392 |
| 1147 |
msgid "" |
| 1148 |
"``current_virtual_library_name()`` -- return the name of the current virtual" |
| 1149 |
" library if there is one, otherwise the empty string. Library name case is " |
| 1150 |
"preserved. Example: ``program: current_virtual_library_name()``. This " |
| 1151 |
"function works only in the GUI." |
| 1152 |
msgstr "" |
| 1153 |
|
| 1154 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:393 |
| 1155 |
msgid "" |
| 1156 |
"``date_arithmetic(date, calc_spec, fmt)`` -- Calculate a new date from " |
| 1157 |
"``date`` using ``calc_spec``. Return the new date formatted according to " |
| 1158 |
"optional ``fmt``: if not supplied then the result will be in ISO format. The" |
| 1159 |
" calc_spec is a string formed by concatenating pairs of ``vW`` " |
| 1160 |
"(``valueWhat``) where ``v`` is a possibly-negative number and W is one of " |
| 1161 |
"the following letters:" |
| 1162 |
msgstr "" |
| 1163 |
|
| 1164 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:395 |
| 1165 |
msgid "``s``: add ``v`` seconds to ``date``" |
| 1166 |
msgstr "" |
| 1167 |
|
| 1168 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:396 |
| 1169 |
msgid "``m``: add ``v`` minutes to ``date``" |
| 1170 |
msgstr "" |
| 1171 |
|
| 1172 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:397 |
| 1173 |
msgid "``h``: add ``v`` hours to ``date``" |
| 1174 |
msgstr "" |
| 1175 |
|
| 1176 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:398 |
| 1177 |
msgid "``d``: add ``v`` days to ``date``" |
| 1178 |
msgstr "" |
| 1179 |
|
| 1180 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:399 |
| 1181 |
msgid "``w``: add ``v`` weeks to ``date``" |
| 1182 |
msgstr "" |
| 1183 |
|
| 1184 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:400 |
| 1185 |
msgid "``y``: add ``v`` years to ``date``, where a year is 365 days." |
| 1186 |
msgstr "" |
| 1187 |
|
| 1188 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:402 |
| 1189 |
msgid "" |
| 1190 |
"Example: ``'1s3d-1m'`` will add 1 second, add 3 days, and subtract 1 minute " |
| 1191 |
"from ``date``." |
| 1192 |
msgstr "" |
| 1193 |
|
| 1194 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:403 |
| 1195 |
msgid "" |
| 1196 |
"``days_between(date1, date2)`` -- return the number of days between " |
| 1197 |
"``date1`` and ``date2``. The number is positive if ``date1`` is greater than" |
| 1198 |
" ``date2``, otherwise negative. If either ``date1`` or ``date2`` are not " |
| 1199 |
"dates, the function returns the empty string." |
| 1200 |
msgstr "" |
| 1201 |
|
| 1202 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:404 |
| 1203 |
msgid "" |
| 1204 |
"``divide(x, y)`` -- returns ``x / y``. Throws an exception if either ``x`` " |
| 1205 |
"or ``y`` are not numbers. This function can usually be replaced by the ``/``" |
| 1206 |
" operator." |
| 1207 |
msgstr "" |
| 1208 |
|
| 1209 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:405 |
| 1210 |
msgid "" |
| 1211 |
"``eval(string)`` -- evaluates the string as a program, passing the local " |
| 1212 |
"variables. This permits using the template processor to construct complex " |
| 1213 |
"results from local variables. In :ref:`Template Program Mode " |
| 1214 |
"<template_mode>`, because the `{` and `}` characters are interpreted before " |
| 1215 |
"the template is evaluated you must use `[[` for the `{` character and `]]` " |
| 1216 |
"for the ``}`` character. They are converted automatically. Note also that " |
| 1217 |
"prefixes and suffixes (the `|prefix|suffix` syntax) cannot be used in the " |
| 1218 |
"argument to this function when using :ref:`Template Program Mode " |
| 1219 |
"<template_mode>`." |
| 1220 |
msgstr "" |
| 1221 |
|
| 1222 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:406 |
| 1223 |
msgid "" |
| 1224 |
"``field(lookup_name)`` -- returns the value of the metadata field with " |
| 1225 |
"lookup name ``lookup_name``." |
| 1226 |
msgstr "" |
| 1227 |
|
| 1228 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:407 |
| 1229 |
msgid "" |
| 1230 |
"``field_exists(field_name)`` -- checks if a field (column) with the lookup " |
| 1231 |
"name ``field_name`` exists, returning ``'1'`` if so and the empty string if " |
| 1232 |
"not." |
| 1233 |
msgstr "" |
| 1234 |
|
| 1235 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:408 |
| 1236 |
msgid "" |
| 1237 |
"``finish_formatting(val, fmt, prefix, suffix)`` -- apply the format, prefix," |
| 1238 |
" and suffix to a value in the same way as done in a template like " |
| 1239 |
"``{series_index:05.2f| - |- }``. This function is provided to ease " |
| 1240 |
"conversion of complex single-function- or template-program-mode templates to" |
| 1241 |
" `GPM` Templates. For example, the following program produces the same " |
| 1242 |
"output as the above template::" |
| 1243 |
msgstr "" |
| 1244 |
|
| 1245 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:412 |
| 1246 |
msgid "" |
| 1247 |
"Another example: for the template " |
| 1248 |
"``{series:re(([^\\s])[^\\s]+(\\s|$),\\1)}{series_index:0>2s| - | - " |
| 1249 |
"}{title}`` use::" |
| 1250 |
msgstr "" |
| 1251 |
|
| 1252 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:421 |
| 1253 |
msgid "" |
| 1254 |
"``first_matching_cmp(val, [ cmp, result, ]* else_result)`` -- compares ``val" |
| 1255 |
" < cmp`` in sequence, returning the associated result for the first " |
| 1256 |
"comparison that succeeds. Returns else_result if no comparison succeeds. " |
| 1257 |
"Example::" |
| 1258 |
msgstr "" |
| 1259 |
|
| 1260 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:426 |
| 1261 |
msgid "" |
| 1262 |
"returns ``\"large\"``. The same example with a first value of 16 returns " |
| 1263 |
"``\"giant\"``." |
| 1264 |
msgstr "" |
| 1265 |
|
| 1266 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:428 |
| 1267 |
msgid "" |
| 1268 |
"``first_non_empty(value [, value]*)`` -- returns the first ``value`` that is" |
| 1269 |
" not empty. If all values are empty, then the empty string is returned. You " |
| 1270 |
"can have as many values as you want." |
| 1271 |
msgstr "" |
| 1272 |
|
| 1273 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:429 |
| 1274 |
msgid "" |
| 1275 |
"``floor(x)`` -- returns the largest integer less than or equal to ``x``. " |
| 1276 |
"Throws an exception if ``x`` is not a number." |
| 1277 |
msgstr "" |
| 1278 |
|
| 1279 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:430 |
| 1280 |
msgid "" |
| 1281 |
"``format_date(val, format_string)`` -- format the value, which must be a " |
| 1282 |
"date string, using the format_string, returning a string. The formatting " |
| 1283 |
"codes are:" |
| 1284 |
msgstr "" |
| 1285 |
|
| 1286 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:432 |
| 1287 |
msgid "``d :`` the day as number without a leading zero (1 to 31)" |
| 1288 |
msgstr "" |
| 1289 |
|
| 1290 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:433 |
| 1291 |
msgid "``dd :`` the day as number with a leading zero (01 to 31)" |
| 1292 |
msgstr "" |
| 1293 |
|
| 1294 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:434 |
| 1295 |
msgid "``ddd :`` the abbreviated localized day name (e.g. \"Mon\" to \"Sun\")." |
| 1296 |
msgstr "" |
| 1297 |
|
| 1298 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:435 |
| 1299 |
msgid "``dddd :`` the long localized day name (e.g. \"Monday\" to \"Sunday\")." |
| 1300 |
msgstr "" |
| 1301 |
|
| 1302 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:436 |
| 1303 |
msgid "``M :`` the month as number without a leading zero (1 to 12)." |
| 1304 |
msgstr "" |
| 1305 |
|
| 1306 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:437 |
| 1307 |
msgid "``MM :`` the month as number with a leading zero (01 to 12)" |
| 1308 |
msgstr "" |
| 1309 |
|
| 1310 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:438 |
| 1311 |
msgid "``MMM :`` the abbreviated localized month name (e.g. \"Jan\" to \"Dec\")." |
| 1312 |
msgstr "" |
| 1313 |
|
| 1314 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:439 |
| 1315 |
msgid "``MMMM :`` the long localized month name (e.g. \"January\" to \"December\")." |
| 1316 |
msgstr "" |
| 1317 |
|
| 1318 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:440 |
| 1319 |
msgid "``yy :`` the year as two digit number (00 to 99)." |
| 1320 |
msgstr "" |
| 1321 |
|
| 1322 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:441 |
| 1323 |
msgid "``yyyy :`` the year as four digit number." |
| 1324 |
msgstr "" |
| 1325 |
|
| 1326 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:442 |
| 1327 |
msgid "" |
| 1328 |
"``h :`` the hours without a leading 0 (0 to 11 or 0 to 23, depending on " |
| 1329 |
"am/pm)" |
| 1330 |
msgstr "" |
| 1331 |
|
| 1332 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:443 |
| 1333 |
msgid "" |
| 1334 |
"``hh :`` the hours with a leading 0 (00 to 11 or 00 to 23, depending on " |
| 1335 |
"am/pm)" |
| 1336 |
msgstr "" |
| 1337 |
|
| 1338 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:444 |
| 1339 |
msgid "``m :`` the minutes without a leading 0 (0 to 59)" |
| 1340 |
msgstr "" |
| 1341 |
|
| 1342 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:445 |
| 1343 |
msgid "``mm :`` the minutes with a leading 0 (00 to 59)" |
| 1344 |
msgstr "" |
| 1345 |
|
| 1346 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:446 |
| 1347 |
msgid "``s :`` the seconds without a leading 0 (0 to 59)" |
| 1348 |
msgstr "" |
| 1349 |
|
| 1350 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:447 |
| 1351 |
msgid "``ss :`` the seconds with a leading 0 (00 to 59)" |
| 1352 |
msgstr "" |
| 1353 |
|
| 1354 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:448 |
| 1355 |
msgid "" |
| 1356 |
"``ap :`` use a 12-hour clock instead of a 24-hour clock, with 'ap' " |
| 1357 |
"replaced by the localized string for am or pm." |
| 1358 |
msgstr "" |
| 1359 |
|
| 1360 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:449 |
| 1361 |
msgid "" |
| 1362 |
"``AP :`` use a 12-hour clock instead of a 24-hour clock, with 'AP' " |
| 1363 |
"replaced by the localized string for AM or PM." |
| 1364 |
msgstr "" |
| 1365 |
|
| 1366 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:450 |
| 1367 |
msgid "" |
| 1368 |
"``iso :`` the date with time and timezone. Must be the only format present." |
| 1369 |
msgstr "" |
| 1370 |
|
| 1371 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:451 |
| 1372 |
msgid "" |
| 1373 |
"``to_number :`` convert the date & time into a floating point number (a " |
| 1374 |
"`timestamp`)" |
| 1375 |
msgstr "" |
| 1376 |
|
| 1377 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:452 |
| 1378 |
msgid "" |
| 1379 |
"``from_number :`` convert a floating point number (a `timestamp`) into an " |
| 1380 |
"``iso`` formatted date. If you want a different date format then add the " |
| 1381 |
"desired formatting string after ``from_number`` and a colon (``:``). " |
| 1382 |
"Example: ``from_number:MMM dd yyyy``" |
| 1383 |
msgstr "" |
| 1384 |
|
| 1385 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:454 |
| 1386 |
msgid "" |
| 1387 |
"You might get unexpected results if the date you are formatting contains " |
| 1388 |
"localized month names, which can happen if you changed the date format " |
| 1389 |
"tweaks to contain ``MMMM``. In this case, instead of using the ``field()`` " |
| 1390 |
"function as in::" |
| 1391 |
msgstr "" |
| 1392 |
|
| 1393 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:458 |
| 1394 |
msgid "use the ``raw_field()`` function as in::" |
| 1395 |
msgstr "" |
| 1396 |
|
| 1397 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:462 |
| 1398 |
msgid "" |
| 1399 |
"``formats_modtimes(date_format_string)`` -- return a comma-separated list of" |
| 1400 |
" colon-separated items ``FMT:DATE`` representing modification times for the " |
| 1401 |
"formats of a book. The ``date_format_string`` parameter specifies how the " |
| 1402 |
"date is to be formatted. See the ``format_date()`` function for details. You" |
| 1403 |
" can use the ``select`` function to get the modification time for a specific" |
| 1404 |
" format. Note that format names are always uppercase, as in EPUB." |
| 1405 |
msgstr "" |
| 1406 |
|
| 1407 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:463 |
| 1408 |
msgid "" |
| 1409 |
"``formats_paths()`` -- return a comma-separated list of colon-separated " |
| 1410 |
"items ``FMT:PATH`` giving the full path to the formats of a book. You can " |
| 1411 |
"use the select function to get the path for a specific format. Note that " |
| 1412 |
"format names are always uppercase, as in EPUB." |
| 1413 |
msgstr "" |
| 1414 |
|
| 1415 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:464 |
| 1416 |
msgid "" |
| 1417 |
"``formats_sizes()`` -- return a comma-separated list of colon-separated " |
| 1418 |
"``FMT:SIZE`` items giving the sizes in bytes of the formats of a book. You " |
| 1419 |
"can use the select function to get the size for a specific format. Note that" |
| 1420 |
" format names are always uppercase, as in EPUB." |
| 1421 |
msgstr "" |
| 1422 |
|
| 1423 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:465 |
| 1424 |
msgid "" |
| 1425 |
"``fractional_part(x)`` -- returns the value after the decimal point. For " |
| 1426 |
"example, ``fractional_part(3.14)`` returns ``0.14``. Throws an exception if " |
| 1427 |
"``x`` is not a number." |
| 1428 |
msgstr "" |
| 1429 |
|
| 1430 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:466 |
| 1431 |
msgid "" |
| 1432 |
"``has_cover()`` -- return ``'Yes'`` if the book has a cover, otherwise the " |
| 1433 |
"empty string." |
| 1434 |
msgstr "" |
| 1435 |
|
| 1436 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:467 |
| 1437 |
msgid "" |
| 1438 |
"``is_marked()`` -- check whether the book is `marked` in calibre. If it is " |
| 1439 |
"then return the value of the mark, either ``'true'`` (lower case) or a " |
| 1440 |
"comma-separated list of named marks. Returns ``''`` (the empty string) if " |
| 1441 |
"the book is not marked. This function works only in the GUI." |
| 1442 |
msgstr "" |
| 1443 |
|
| 1444 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:468 |
| 1445 |
msgid "" |
| 1446 |
"``language_codes(lang_strings)`` -- return the `language codes " |
| 1447 |
"<https://www.loc.gov/standards/iso639-2/php/code_list.php>`_ for the " |
| 1448 |
"language names passed in `lang_strings`. The strings must be in the language" |
| 1449 |
" of the current locale. ``Lang_strings`` is a comma-separated list." |
| 1450 |
msgstr "" |
| 1451 |
|
| 1452 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:469 |
| 1453 |
msgid "" |
| 1454 |
"``list_contains(value, separator, [ pattern, found_val, ]* not_found_val)`` " |
| 1455 |
"-- (Alias of ``in_list``) Interpreting the value as a list of items " |
| 1456 |
"separated by ``separator``, evaluate the ``pattern`` against each value in " |
| 1457 |
"the list. If the ``pattern`` matches any value then return ``found_val``, " |
| 1458 |
"otherwise return ``not_found_val``. The ``pattern`` and ``found_value`` can " |
| 1459 |
"be repeated as many times as desired, permitting returning different values " |
| 1460 |
"depending on the search. The patterns are checked in order. The first match " |
| 1461 |
"is returned. Aliases: ``in_list()``, ``list_contains()``" |
| 1462 |
msgstr "" |
| 1463 |
|
| 1464 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:470 |
| 1465 |
msgid "" |
| 1466 |
"``list_count(value, separator)`` -- interprets ``value`` as a list of items " |
| 1467 |
"separated by ``separator``, returning the count of items in the list. " |
| 1468 |
"Aliases: ``count()``, ``list_count()``" |
| 1469 |
msgstr "" |
| 1470 |
|
| 1471 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:471 |
| 1472 |
msgid "" |
| 1473 |
"``list_count_matching(list, pattern, separator)`` -- interprets ``list`` as " |
| 1474 |
"a list of items separated by ``separator``, returning the number of items in" |
| 1475 |
" the list that match the regular expression ``pattern``. Aliases: " |
| 1476 |
"``list_count_matching()``, ``count_matching()``" |
| 1477 |
msgstr "" |
| 1478 |
|
| 1479 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:472 |
| 1480 |
msgid "" |
| 1481 |
"``list_difference(list1, list2, separator)`` -- return a list made by " |
| 1482 |
"removing from ``list1`` any item found in ``list2`` using a case-insensitive" |
| 1483 |
" comparison. The items in ``list1`` and ``list2`` are separated by " |
| 1484 |
"separator, as are the items in the returned list." |
| 1485 |
msgstr "" |
| 1486 |
|
| 1487 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:473 |
| 1488 |
msgid "" |
| 1489 |
"``list_equals(list1, sep1, list2, sep2, yes_val, no_val)`` -- return " |
| 1490 |
"``yes_val`` if ``list1`` and `list2` contain the same items, otherwise " |
| 1491 |
"return ``no_val``. The items are determined by splitting each list using the" |
| 1492 |
" appropriate separator character (``sep1`` or ``sep2``). The order of items " |
| 1493 |
"in the lists is not relevant. The comparison is case-insensitive." |
| 1494 |
msgstr "" |
| 1495 |
|
| 1496 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:474 |
| 1497 |
msgid "" |
| 1498 |
"``list_intersection(list1, list2, separator)`` -- return a list made by " |
| 1499 |
"removing from ``list1`` any item not found in ``list2``, using a case-" |
| 1500 |
"insensitive comparison. The items in ``list1`` and ``list2`` are separated " |
| 1501 |
"by separator, as are the items in the returned list." |
| 1502 |
msgstr "" |
| 1503 |
|
| 1504 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:475 |
| 1505 |
msgid "" |
| 1506 |
"``list_re(src_list, separator, include_re, opt_replace)`` -- Construct a " |
| 1507 |
"list by first separating ``src_list`` into items using the ``separator`` " |
| 1508 |
"character. For each item in the list, check if it matches ``include_re``. If" |
| 1509 |
" it does then add it to the list to be returned. If ``opt_replace`` is not " |
| 1510 |
"the empty string then apply the replacement before adding the item to the " |
| 1511 |
"returned list." |
| 1512 |
msgstr "" |
| 1513 |
|
| 1514 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:476 |
| 1515 |
msgid "" |
| 1516 |
"``list_re_group(src_list, separator, include_re, search_re [, " |
| 1517 |
"template_for_group]*)`` -- Like list_re except replacements are not " |
| 1518 |
"optional. It uses ``re_group(item, search_re, template ...)`` when doing the" |
| 1519 |
" replacements." |
| 1520 |
msgstr "" |
| 1521 |
|
| 1522 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:477 |
| 1523 |
msgid "" |
| 1524 |
"``list_remove_duplicates(list, separator)`` -- return a list made by " |
| 1525 |
"removing duplicate items in ``list``. If items differ only in case then the " |
| 1526 |
"last is returned. The items in ``list`` are separated by ``separator``, as " |
| 1527 |
"are the items in the returned list." |
| 1528 |
msgstr "" |
| 1529 |
|
| 1530 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:478 |
| 1531 |
msgid "" |
| 1532 |
"``list_sort(list, direction, separator)`` -- return ``list`` sorted using a " |
| 1533 |
"case-insensitive lexical sort. If ``direction`` is zero, ``list`` is sorted " |
| 1534 |
"ascending, otherwise descending. The list items are separated by " |
| 1535 |
"``separator``, as are the items in the returned list." |
| 1536 |
msgstr "" |
| 1537 |
|
| 1538 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:479 |
| 1539 |
msgid "" |
| 1540 |
"``list_split(list_val, sep, id_prefix)`` -- splits ``list_val`` into " |
| 1541 |
"separate values using ``sep``, then assigns the values to local variables " |
| 1542 |
"named ``id_prefix_N`` where N is the position of the value in the list. The " |
| 1543 |
"first item has position 0 (zero). The function returns the last element in " |
| 1544 |
"the list." |
| 1545 |
msgstr "" |
| 1546 |
|
| 1547 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:481 |
| 1548 |
msgid "Example::" |
| 1549 |
msgstr "" |
| 1550 |
|
| 1551 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:485 |
| 1552 |
msgid "is equivalent to::" |
| 1553 |
msgstr "" |
| 1554 |
|
| 1555 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:491 |
| 1556 |
msgid "" |
| 1557 |
"``list_union(list1, list2, separator)`` -- return a list made by merging the" |
| 1558 |
" items in ``list1`` and ``list2``, removing duplicate items using a case-" |
| 1559 |
"insensitive comparison. If items differ in case, the one in ``list1`` is " |
| 1560 |
"used. The items in ``list1`` and ``list2`` are separated by ``separator``, " |
| 1561 |
"as are the items in the returned list. Aliases: ``merge_lists()``, " |
| 1562 |
"``list_union()``" |
| 1563 |
msgstr "" |
| 1564 |
|
| 1565 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:492 |
| 1566 |
msgid "" |
| 1567 |
"``mod(x, y)`` -- returns the ``floor`` of the remainder of ``x / y``. Throws" |
| 1568 |
" an exception if either ``x`` or ``y`` is not a number." |
| 1569 |
msgstr "" |
| 1570 |
|
| 1571 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:493 |
| 1572 |
msgid "" |
| 1573 |
"``multiply(x [, y]*)`` -- returns the product of its arguments. Throws an " |
| 1574 |
"exception if any argument is not a number. This function can usually be " |
| 1575 |
"replaced by the ``*`` operator." |
| 1576 |
msgstr "" |
| 1577 |
|
| 1578 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:494 |
| 1579 |
msgid "" |
| 1580 |
"``not(value)`` -- returns the string \"1\" if the value is empty, otherwise " |
| 1581 |
"returns the empty string. This function can usually be replaced with the " |
| 1582 |
"unary not (``!``) operator." |
| 1583 |
msgstr "" |
| 1584 |
|
| 1585 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:495 |
| 1586 |
msgid "" |
| 1587 |
"``ondevice()`` -- return the string ``'Yes'`` if ``ondevice`` is set, " |
| 1588 |
"otherwise return the empty string." |
| 1589 |
msgstr "" |
| 1590 |
|
| 1591 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:496 |
| 1592 |
msgid "" |
| 1593 |
"``or(value [, value]*)`` -- returns the string ``'1'`` if any value is not " |
| 1594 |
"empty, otherwise returns the empty string. You can have as many values as " |
| 1595 |
"you want. This function can usually be replaced by the ``||`` operator. A " |
| 1596 |
"reason it cannot be replaced is if short-circuiting will change the results " |
| 1597 |
"because of side effects." |
| 1598 |
msgstr "" |
| 1599 |
|
| 1600 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:497 |
| 1601 |
msgid "" |
| 1602 |
"``print(a [, b]*)`` -- prints the arguments to standard output. Unless you " |
| 1603 |
"start calibre from the command line (``calibre-debug -g``), the output will " |
| 1604 |
"go to a black hole. The ``print`` function always returns the empty string." |
| 1605 |
msgstr "" |
| 1606 |
|
| 1607 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:498 |
| 1608 |
msgid "" |
| 1609 |
"``raw_field(lookup_name [, optional_default])`` -- returns the metadata " |
| 1610 |
"field named by ``lookup_name`` without applying any formatting. It evaluates" |
| 1611 |
" and returns the optional second argument ``optional_default`` if the " |
| 1612 |
"field's value is undefined (``None``)." |
| 1613 |
msgstr "" |
| 1614 |
|
| 1615 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:499 |
| 1616 |
msgid "" |
| 1617 |
"``raw_list(lookup_name, separator)`` -- returns the metadata list named by " |
| 1618 |
"``lookup_name`` without applying any formatting or sorting, with the items " |
| 1619 |
"separated by separator." |
| 1620 |
msgstr "" |
| 1621 |
|
| 1622 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:500 |
| 1623 |
msgid "" |
| 1624 |
"``re_group(value, pattern [, template_for_group]*)`` -- return a string " |
| 1625 |
"made by applying the regular expression pattern to ``value`` and replacing " |
| 1626 |
"each matched instance with the the value returned by the corresponding " |
| 1627 |
"template. In :ref:`Template Program Mode <template_mode>`, like for the " |
| 1628 |
"``template`` and the ``eval`` functions, you use ``[[`` for ``{`` and ``]]``" |
| 1629 |
" for ``}``." |
| 1630 |
msgstr "" |
| 1631 |
|
| 1632 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:502 |
| 1633 |
msgid "" |
| 1634 |
"The following example looks for a series with more than one word and " |
| 1635 |
"uppercases the first word::" |
| 1636 |
msgstr "" |
| 1637 |
|
| 1638 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:506 |
| 1639 |
msgid "" |
| 1640 |
"``round(x)`` -- returns the nearest integer to ``x``. Throws an exception if" |
| 1641 |
" ``x`` is not a number." |
| 1642 |
msgstr "" |
| 1643 |
|
| 1644 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:507 |
| 1645 |
msgid "``series_sort()`` -- returns the series sort value." |
| 1646 |
msgstr "" |
| 1647 |
|
| 1648 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:508 |
| 1649 |
msgid "" |
| 1650 |
"``strcat(a [, b]*)`` -- can take any number of arguments. Returns a string " |
| 1651 |
"formed by concatenating all the arguments." |
| 1652 |
msgstr "" |
| 1653 |
|
| 1654 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:509 |
| 1655 |
msgid "" |
| 1656 |
"``strcat_max(max, string1 [, prefix2, string2]*)`` -- Returns a string " |
| 1657 |
"formed by concatenating the arguments. The returned value is initialized to " |
| 1658 |
"``string1``. Strings made from ``prefix, string`` pairs are added to the end" |
| 1659 |
" of the value as long as the resulting string length is less than ``max``. " |
| 1660 |
"Prefixes can be empty. Returns ``string1`` even if ``string1`` is longer " |
| 1661 |
"than ``max``. You can pass as many ``prefix, string`` pairs as you wish." |
| 1662 |
msgstr "" |
| 1663 |
|
| 1664 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:510 |
| 1665 |
msgid "" |
| 1666 |
"``strcmp(x, y, lt, eq, gt)`` -- does a case-insensitive lexical comparison " |
| 1667 |
"of ``x`` and ``y``. Returns ``lt`` if ``x < y``, ``eq`` if ``x == y``, " |
| 1668 |
"otherwise ``gt``. This function can often be replaced by one of the lexical " |
| 1669 |
"comparison operators (``==``, ``>``, ``<``, etc.)" |
| 1670 |
msgstr "" |
| 1671 |
|
| 1672 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:511 |
| 1673 |
msgid "``strlen(value)`` -- Returns the length of the string ``value``." |
| 1674 |
msgstr "" |
| 1675 |
|
| 1676 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:512 |
| 1677 |
msgid "" |
| 1678 |
"``substr(str, start, end)`` -- returns the ``start``'th through the " |
| 1679 |
"``end``'th characters of ``str``. The first character in ``str`` is the " |
| 1680 |
"zero'th character. If ``end`` is negative, then it indicates that many " |
| 1681 |
"characters counting from the right. If ``end`` is zero, then it indicates " |
| 1682 |
"the last character. For example, ``substr('12345', 1, 0)`` returns " |
| 1683 |
"``'2345'``, and ``substr('12345', 1, -1)`` returns ``'234'``." |
| 1684 |
msgstr "" |
| 1685 |
|
| 1686 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:513 |
| 1687 |
msgid "" |
| 1688 |
"``subtract(x, y)`` -- returns ``x - y``. Throws an exception if either ``x``" |
| 1689 |
" or ``y`` are not numbers. This function can usually be replaced by the " |
| 1690 |
"``-`` operator." |
| 1691 |
msgstr "" |
| 1692 |
|
| 1693 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:514 |
| 1694 |
msgid "" |
| 1695 |
"``today()`` -- return a date+time string for today (now). This value is " |
| 1696 |
"designed for use in `format_date` or `days_between`, but can be manipulated " |
| 1697 |
"like any other string. The date is in `ISO " |
| 1698 |
"<https://en.wikipedia.org/wiki/ISO_8601>`_ date/time format." |
| 1699 |
msgstr "" |
| 1700 |
|
| 1701 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:515 |
| 1702 |
msgid "" |
| 1703 |
"``template(x)`` -- evaluates ``x`` as a template. The evaluation is done in " |
| 1704 |
"its own context, meaning that variables are not shared between the caller " |
| 1705 |
"and the template evaluation." |
| 1706 |
msgstr "" |
| 1707 |
|
| 1708 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:520 |
| 1709 |
msgid "More complex programs in template expressions - Template Program Mode" |
| 1710 |
msgstr "" |
| 1711 |
|
| 1712 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:522 |
| 1713 |
msgid "" |
| 1714 |
"`Template Program Mode` (`TPM`) is a blend of :ref:`General Program Mode " |
| 1715 |
"<general_mode>` and :ref:`Single Function Mode <single_mode>`. `TPM` differs" |
| 1716 |
" from Single Function Mode in that it permits writing template expressions " |
| 1717 |
"that refer to other metadata fields, use nested functions, modify variables," |
| 1718 |
" and do arithmetic. It differs from `General Program Mode` in that the " |
| 1719 |
"template is contained between ``{`` and ``}`` characters and doesn't begin " |
| 1720 |
"with the word ``program:``. The program portion of the template is a General" |
| 1721 |
" Program Mode expression list." |
| 1722 |
msgstr "" |
| 1723 |
|
| 1724 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:525 |
| 1725 |
msgid "" |
| 1726 |
"Example: assume you want a template to show the series for a book if it has " |
| 1727 |
"one, otherwise show the value of a custom field #genre. You cannot do this " |
| 1728 |
"in the :ref:`Single Function Mode <single_mode>` because you cannot make " |
| 1729 |
"reference to another metadata field within a template expression. In `TPM` " |
| 1730 |
"you can, as the following expression demonstrates::" |
| 1731 |
msgstr "" |
| 1732 |
|
| 1733 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:530 |
| 1734 |
msgid "The example shows several things:" |
| 1735 |
msgstr "" |
| 1736 |
|
| 1737 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:532 |
| 1738 |
msgid "" |
| 1739 |
"`TPM` is used if the expression begins with ``:'`` and ends with ``'``. " |
| 1740 |
"Anything else is assumed to be in :ref:`Single Function Mode <single_mode>`." |
| 1741 |
msgstr "" |
| 1742 |
|
| 1743 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:533 |
| 1744 |
msgid "" |
| 1745 |
"the variable ``$`` stands for the field named in the template: the " |
| 1746 |
"expression is operating upon, ``#series`` in this case." |
| 1747 |
msgstr "" |
| 1748 |
|
| 1749 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:534 |
| 1750 |
msgid "" |
| 1751 |
"functions must be given all their arguments. There is no default value. For " |
| 1752 |
"example, the standard built-in functions must be given an additional initial" |
| 1753 |
" parameter indicating the source field." |
| 1754 |
msgstr "" |
| 1755 |
|
| 1756 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:535 |
| 1757 |
msgid "white space is ignored and can be used anywhere within the expression." |
| 1758 |
msgstr "" |
| 1759 |
|
| 1760 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:536 |
| 1761 |
msgid "" |
| 1762 |
"constant strings are enclosed in matching quotes, either ``'`` or ``\"``." |
| 1763 |
msgstr "" |
| 1764 |
|
| 1765 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:538 |
| 1766 |
msgid "" |
| 1767 |
"All the functions listed under `Single Function Mode` and `General Program " |
| 1768 |
"Mode` can be used in `TPM`." |
| 1769 |
msgstr "" |
| 1770 |
|
| 1771 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:540 |
| 1772 |
msgid "" |
| 1773 |
"In `TPM`, using ``{`` and ``}`` characters in string literals can lead to " |
| 1774 |
"errors or unexpected results because they confuse the template processor. It" |
| 1775 |
" tries to treat them as template expression boundaries, not characters. In " |
| 1776 |
"some but not all cases you can replace a ``{`` with ``[[`` and a ``}`` with " |
| 1777 |
"`]]`. Generally, if your program contains ``{`` and ``}`` characters then " |
| 1778 |
"you should use `General Program Mode`." |
| 1779 |
msgstr "" |
| 1780 |
|
| 1781 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:542 |
| 1782 |
msgid "" |
| 1783 |
"As with `General Program Mode`, for functions documented under :ref:`Single " |
| 1784 |
"Function Mode <single_mode>` you must supply the value the function is to " |
| 1785 |
"act upon as the first parameter in addition to the documented parameters. In" |
| 1786 |
" `TPM` you can use ``$`` to access the value specified by the ``lookup " |
| 1787 |
"name`` for the template expression." |
| 1788 |
msgstr "" |
| 1789 |
|
| 1790 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:545 |
| 1791 |
msgid "Stored general program mode templates" |
| 1792 |
msgstr "" |
| 1793 |
|
| 1794 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:547 |
| 1795 |
msgid "" |
| 1796 |
":ref:`General Program Mode <general_mode>` supports saving templates and " |
| 1797 |
"calling those templates from another template, much like calling stored " |
| 1798 |
"functions. You save templates using " |
| 1799 |
":guilabel:`Preferences->Advanced->Template functions`. More information is " |
| 1800 |
"provided in that dialog. You call a template the same way you call a " |
| 1801 |
"function, passing positional arguments if desired. An argument can be any " |
| 1802 |
"expression. Examples of calling a template, assuming the stored template is " |
| 1803 |
"named ``foo``:" |
| 1804 |
msgstr "" |
| 1805 |
|
| 1806 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:549 |
| 1807 |
msgid "``foo()`` -- call the template passing no arguments." |
| 1808 |
msgstr "" |
| 1809 |
|
| 1810 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:550 |
| 1811 |
msgid "" |
| 1812 |
"``foo(a, b)`` call the template passing the values of the two variables " |
| 1813 |
"``a`` and ``b``." |
| 1814 |
msgstr "" |
| 1815 |
|
| 1816 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:551 |
| 1817 |
msgid "" |
| 1818 |
"``foo(if field('series') then field('series_index') else 0 fi)`` -- if the " |
| 1819 |
"book has a ``series`` then pass the ``series_index``, otherwise pass the " |
| 1820 |
"value ``0``." |
| 1821 |
msgstr "" |
| 1822 |
|
| 1823 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:553 |
| 1824 |
msgid "" |
| 1825 |
"You retrieve the arguments passed in the call to the stored template using " |
| 1826 |
"the ``arguments`` function. It both declares and initializes local " |
| 1827 |
"variables, effectively parameters. The variables are positional; they get " |
| 1828 |
"the value of the value given in the call in the same position. If the " |
| 1829 |
"corresponding parameter is not provided in the call then ``arguments`` " |
| 1830 |
"assigns that variable the provided default value. If there is no default " |
| 1831 |
"value then the variable is set to the empty string. For example, the " |
| 1832 |
"following ``arguments`` function declares 2 variables, ``key``, " |
| 1833 |
"``alternate``::" |
| 1834 |
msgstr "" |
| 1835 |
|
| 1836 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:557 |
| 1837 |
msgid "Examples, again assuming the stored template is named ``foo``:" |
| 1838 |
msgstr "" |
| 1839 |
|
| 1840 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:559 |
| 1841 |
msgid "" |
| 1842 |
"``foo('#myseries')`` -- argument ``key`` is assigned the value " |
| 1843 |
"``'myseries'`` and the argument ``alternate`` is assigned the default value " |
| 1844 |
"``'series'``." |
| 1845 |
msgstr "" |
| 1846 |
|
| 1847 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:560 |
| 1848 |
msgid "" |
| 1849 |
"``foo('series', '#genre')`` the variable ``key`` is assigned the value " |
| 1850 |
"``'series'`` and the variable ``alternate`` is assigned the value " |
| 1851 |
"``'#genre'``." |
| 1852 |
msgstr "" |
| 1853 |
|
| 1854 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:561 |
| 1855 |
msgid "" |
| 1856 |
"``foo()`` -- the variable ``key`` is assigned the empty string and the " |
| 1857 |
"variable ``alternate`` is assigned the value ``'series'``." |
| 1858 |
msgstr "" |
| 1859 |
|
| 1860 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:563 |
| 1861 |
msgid "" |
| 1862 |
"An easy way to test stored templates is using the ``Template tester`` " |
| 1863 |
"dialog. For ease of access give it a keyboard shortcut in " |
| 1864 |
":guilabel:`Preferences->Advanced->Keyboard shortcuts->Template tester`. " |
| 1865 |
"Giving the ``Stored templates`` dialog a shortcut will help switching more " |
| 1866 |
"rapidly between the tester and editing the stored template's source code." |
| 1867 |
msgstr "" |
| 1868 |
|
| 1869 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:566 |
| 1870 |
msgid "Providing additional information to templates" |
| 1871 |
msgstr "" |
| 1872 |
|
| 1873 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:568 |
| 1874 |
msgid "" |
| 1875 |
"A developer can choose to pass additional information to the template " |
| 1876 |
"processor, such as application-specific book metadata or information about " |
| 1877 |
"what the processor is being asked to do. A template can access this " |
| 1878 |
"information and use it during the evaluation." |
| 1879 |
msgstr "" |
| 1880 |
|
| 1881 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:570 |
| 1882 |
msgid "**Developer: how to pass additional information**" |
| 1883 |
msgstr "" |
| 1884 |
|
| 1885 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:572 |
| 1886 |
msgid "" |
| 1887 |
"The additional information is a Python dictionary containing pairs " |
| 1888 |
"``variable_name: variable_value`` where the values must be strings. The " |
| 1889 |
"template can access the dict, creating template local variables named " |
| 1890 |
"``variable_name`` containing the value ``variable_value``. The user cannot " |
| 1891 |
"change the name so it is best to use names that won't collide with other " |
| 1892 |
"template local variables, for example by prefixing the name with an " |
| 1893 |
"underscore." |
| 1894 |
msgstr "" |
| 1895 |
|
| 1896 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:574 |
| 1897 |
msgid "" |
| 1898 |
"This dict is passed to the template processor (the ``formatter``) using the " |
| 1899 |
"named parameter ``global_vars=your_dict``. The full method signature is::" |
| 1900 |
msgstr "" |
| 1901 |
|
| 1902 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:582 |
| 1903 |
msgid "**Template writer: how to access the additional information**" |
| 1904 |
msgstr "" |
| 1905 |
|
| 1906 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:584 |
| 1907 |
msgid "" |
| 1908 |
"You access the additional information (the ``globals`` dict) in a template " |
| 1909 |
"using the template function::" |
| 1910 |
msgstr "" |
| 1911 |
|
| 1912 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:588 |
| 1913 |
msgid "" |
| 1914 |
"where ``id`` is any legal variable name. This function checks whether the " |
| 1915 |
"additional information provided by the developer contains the name. If it " |
| 1916 |
"does then the function assigns the provided value to a template local " |
| 1917 |
"variable with that name. If the name is not in the additional information " |
| 1918 |
"and if an ``expression`` is provided, the ``expression`` is evaluated and " |
| 1919 |
"the result is assigned to the local variable. If neither a value nor an " |
| 1920 |
"expression is provided, the function assigns the empty string (``''``) to " |
| 1921 |
"the local variable." |
| 1922 |
msgstr "" |
| 1923 |
|
| 1924 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:590 |
| 1925 |
msgid "" |
| 1926 |
"A template can set a value in the ``globals`` dict using the template " |
| 1927 |
"function::" |
| 1928 |
msgstr "" |
| 1929 |
|
| 1930 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:594 |
| 1931 |
msgid "" |
| 1932 |
"This function sets the ``globals`` dict key:value pair ``id:value`` where " |
| 1933 |
"``value`` is the value of the template local variable ``id``. If that local " |
| 1934 |
"variable doesn't exist then ``value`` is set to the result of evaluating " |
| 1935 |
"``expression``." |
| 1936 |
msgstr "" |
| 1937 |
|
| 1938 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:597 |
| 1939 |
msgid "Notes on the difference between modes" |
| 1940 |
msgstr "" |
| 1941 |
|
| 1942 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:599 |
| 1943 |
msgid "" |
| 1944 |
"The three program modes, :ref:`Single Function Mode <single_mode>` (SFM), " |
| 1945 |
":ref:`Template Program Mode <template_mode>` (`TPM`), and :ref:`General " |
| 1946 |
"Program Mode <general_mode>` (`GPM`), work differently. SFM is intended to " |
| 1947 |
"be 'simple' so it hides a lot of programming language bits." |
| 1948 |
msgstr "" |
| 1949 |
|
| 1950 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:601 |
| 1951 |
msgid "Differences:" |
| 1952 |
msgstr "" |
| 1953 |
|
| 1954 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:603 |
| 1955 |
msgid "" |
| 1956 |
"In SFM the value of the column is always passed as an 'invisible' first " |
| 1957 |
"argument to a function included in the template." |
| 1958 |
msgstr "" |
| 1959 |
|
| 1960 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:604 |
| 1961 |
msgid "" |
| 1962 |
"SFM doesn't support the difference between variables and strings; all values" |
| 1963 |
" are strings." |
| 1964 |
msgstr "" |
| 1965 |
|
| 1966 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:605 |
| 1967 |
msgid "" |
| 1968 |
"The following SFM template returns either the series name or the string \"no" |
| 1969 |
" series\"::" |
| 1970 |
msgstr "" |
| 1971 |
|
| 1972 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:609 |
| 1973 |
msgid "The equivalent template in `TPM` is ::" |
| 1974 |
msgstr "" |
| 1975 |
|
| 1976 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:613 |
| 1977 |
msgid "The equivalent template in `GPM` is::" |
| 1978 |
msgstr "" |
| 1979 |
|
| 1980 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:617 |
| 1981 |
msgid "" |
| 1982 |
"The first argument to ``ifempty`` is the value of the field ``series``. The " |
| 1983 |
"second argument is the string ``no series``. In SFM the first argument, the " |
| 1984 |
"value of the field, is automatically passed (the invisible argument)." |
| 1985 |
msgstr "" |
| 1986 |
|
| 1987 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:618 |
| 1988 |
msgid "" |
| 1989 |
"Several template functions, for example ``booksize()`` and " |
| 1990 |
"``current_library_name()``, take no arguments. Because of the 'invisible " |
| 1991 |
"argument' you cannot use these functions in SFM." |
| 1992 |
msgstr "" |
| 1993 |
|
| 1994 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:619 |
| 1995 |
msgid "" |
| 1996 |
"Nested functions, where a function calls another function to compute an " |
| 1997 |
"argument, cannot be used in SFM. For example this template, intended to " |
| 1998 |
"return the first 5 characters of the series value uppercased, won't work in " |
| 1999 |
"SFM::" |
| 2000 |
msgstr "" |
| 2001 |
|
| 2002 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:623 |
| 2003 |
msgid "" |
| 2004 |
"`TPM` and `GPM` support nested functions. The above template in `TPM` would " |
| 2005 |
"be::" |
| 2006 |
msgstr "" |
| 2007 |
|
| 2008 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:627 |
| 2009 |
msgid "In `GPM` it would be::" |
| 2010 |
msgstr "" |
| 2011 |
|
| 2012 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:631 |
| 2013 |
msgid "" |
| 2014 |
"As noted in the above :ref:`Template Program Mode <template_mode>` section, " |
| 2015 |
"using ``{`` and ``}`` characters in `TPM` string literals can lead to errors" |
| 2016 |
" or unexpected results because they confuse the template processor. It tries" |
| 2017 |
" to treat them as template boundaries, not characters. In some but not all " |
| 2018 |
"cases you can replace a ``{`` with ``[[`` and a ``}`` with `]]`. Generally, " |
| 2019 |
"if your program contains ``{`` and ``}`` characters then you should use " |
| 2020 |
"`General Program Mode`." |
| 2021 |
msgstr "" |
| 2022 |
|
| 2023 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:635 |
| 2024 |
msgid "User-defined Python template functions" |
| 2025 |
msgstr "" |
| 2026 |
|
| 2027 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:637 |
| 2028 |
msgid "" |
| 2029 |
"You can add your own Python functions to the template processor. Such " |
| 2030 |
"functions can be used in any of the three template programming modes. The " |
| 2031 |
"functions are added by going to :guilabel:`Preferences -> Advanced -> " |
| 2032 |
"Template functions`. Instructions are shown in that dialog." |
| 2033 |
msgstr "" |
| 2034 |
|
| 2035 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:640 |
| 2036 |
msgid "Special notes for save/send templates" |
| 2037 |
msgstr "" |
| 2038 |
|
| 2039 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:642 |
| 2040 |
msgid "" |
| 2041 |
"Special processing is applied when a template is used in a `save to disk` or" |
| 2042 |
" `send to device` template. The values of the fields are cleaned, replacing " |
| 2043 |
"characters that are special to file systems with underscores, including " |
| 2044 |
"slashes. This means that field text cannot be used to create folders. " |
| 2045 |
"However, slashes are not changed in prefix or suffix strings, so slashes in " |
| 2046 |
"these strings will cause folders to be created. Because of this, you can " |
| 2047 |
"create variable-depth folder structure." |
| 2048 |
msgstr "" |
| 2049 |
|
| 2050 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:644 |
| 2051 |
msgid "" |
| 2052 |
"For example, assume we want the folder structure `series/series_index - " |
| 2053 |
"title`, with the caveat that if series does not exist, then the title should" |
| 2054 |
" be in the top folder. The template to do this is::" |
| 2055 |
msgstr "" |
| 2056 |
|
| 2057 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:648 |
| 2058 |
msgid "The slash and the hyphen appear only if series is not empty." |
| 2059 |
msgstr "" |
| 2060 |
|
| 2061 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:650 |
| 2062 |
msgid "" |
| 2063 |
"The lookup function lets us do even fancier processing. For example, assume " |
| 2064 |
"that if a book has a series, then we want the folder structure " |
| 2065 |
"`series/series index - title.fmt`. If the book does not have a series then " |
| 2066 |
"we want the folder structure `genre/author_sort/title.fmt`. If the book has " |
| 2067 |
"no genre then we want to use 'Unknown'. We want two completely different " |
| 2068 |
"paths, depending on the value of series." |
| 2069 |
msgstr "" |
| 2070 |
|
| 2071 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:652 |
| 2072 |
msgid "To accomplish this, we:" |
| 2073 |
msgstr "" |
| 2074 |
|
| 2075 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:654 |
| 2076 |
msgid "" |
| 2077 |
"Create a composite field (give it lookup name #aa) containing " |
| 2078 |
"``{series}/{series_index} - {title}``. If the series is not empty, then this" |
| 2079 |
" template will produce `series/series_index - title`." |
| 2080 |
msgstr "" |
| 2081 |
|
| 2082 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:655 |
| 2083 |
msgid "" |
| 2084 |
"Create a composite field (give it lookup name #bb) containing " |
| 2085 |
"``{#genre:ifempty(Unknown)}/{author_sort}/{title}``. This template produces " |
| 2086 |
"`genre/author_sort/title`, where an empty genre is replaced with `Unknown`." |
| 2087 |
msgstr "" |
| 2088 |
|
| 2089 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:656 |
| 2090 |
msgid "" |
| 2091 |
"Set the save template to ``{series:lookup(.,#aa,#bb}``. This template " |
| 2092 |
"chooses composite field ``#aa`` if series is not empty and composite field " |
| 2093 |
"``#bb`` if series is empty. We therefore have two completely different save " |
| 2094 |
"paths, depending on whether or not `series` is empty." |
| 2095 |
msgstr "" |
| 2096 |
|
| 2097 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:659 |
| 2098 |
msgid "Templates and plugboards" |
| 2099 |
msgstr "" |
| 2100 |
|
| 2101 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:661 |
| 2102 |
msgid "" |
| 2103 |
"Plugboards are used for changing the metadata written into books during " |
| 2104 |
"send-to-device and save-to-disk operations. A plugboard permits you to " |
| 2105 |
"specify a template to provide the data to write into the book's metadata. " |
| 2106 |
"You can use plugboards to modify the following fields: authors, author_sort," |
| 2107 |
" language, publisher, tags, title, title_sort. This feature helps people who" |
| 2108 |
" want to use different metadata in books on devices to solve sorting or " |
| 2109 |
"display issues." |
| 2110 |
msgstr "" |
| 2111 |
|
| 2112 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:663 |
| 2113 |
msgid "" |
| 2114 |
"When you create a plugboard, you specify the format and device for which the" |
| 2115 |
" plugboard is to be used. A special device is provided, ``save_to_disk``, " |
| 2116 |
"that is used when saving formats (as opposed to sending them to a device). " |
| 2117 |
"Once you have chosen the format and device, you choose the metadata fields " |
| 2118 |
"to change, providing templates to supply the new values. These templates are" |
| 2119 |
" `connected` to their destination fields, hence the name `plugboards`. You " |
| 2120 |
"can of course use composite columns in these templates." |
| 2121 |
msgstr "" |
| 2122 |
|
| 2123 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:665 |
| 2124 |
msgid "" |
| 2125 |
"When a plugboard might apply (Content server, save to disk, or send to " |
| 2126 |
"device), calibre searches the defined plugboards to choose the correct one " |
| 2127 |
"for the given format and device. For example, to find the appropriate " |
| 2128 |
"plugboard for an EPUB book being sent to an ANDROID device, calibre searches" |
| 2129 |
" the plugboards using the following search order:" |
| 2130 |
msgstr "" |
| 2131 |
|
| 2132 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:669 |
| 2133 |
msgid "" |
| 2134 |
"a plugboard with an exact match on format and device, e.g., ``EPUB`` and " |
| 2135 |
"``ANDROID``" |
| 2136 |
msgstr "" |
| 2137 |
|
| 2138 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:670 |
| 2139 |
msgid "" |
| 2140 |
"a plugboard with an exact match on format and the special ``any device`` " |
| 2141 |
"choice, e.g., ``EPUB`` and ``any device``" |
| 2142 |
msgstr "" |
| 2143 |
|
| 2144 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:671 |
| 2145 |
msgid "" |
| 2146 |
"a plugboard with the special ``any format`` choice and an exact match on " |
| 2147 |
"device, e.g., ``any format`` and ``ANDROID``" |
| 2148 |
msgstr "" |
| 2149 |
|
| 2150 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:672 |
| 2151 |
msgid "a plugboard with ``any format`` and ``any device``" |
| 2152 |
msgstr "" |
| 2153 |
|
| 2154 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:674 |
| 2155 |
msgid "" |
| 2156 |
"The tags and authors fields have special treatment, because both of these " |
| 2157 |
"fields can hold more than one item. A book can have many tags and many " |
| 2158 |
"authors. When you specify that one of these two fields is to be changed, the" |
| 2159 |
" template's result is examined to see if more than one item is there. For " |
| 2160 |
"tags, the result is cut apart wherever calibre finds a comma. For example, " |
| 2161 |
"if the template produces the value ``Thriller, Horror``, then the result " |
| 2162 |
"will be two tags, ``Thriller`` and ``Horror``. There is no way to put a " |
| 2163 |
"comma in the middle of a tag." |
| 2164 |
msgstr "" |
| 2165 |
|
| 2166 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:677 |
| 2167 |
msgid "" |
| 2168 |
"The same thing happens for authors, but using a different character for the " |
| 2169 |
"cut, a `&` (ampersand) instead of a comma. For example, if the template " |
| 2170 |
"produces the value ``Blogs, Joe&Posts, Susan``, then the book will end up " |
| 2171 |
"with two authors, ``Blogs, Joe`` and ``Posts, Susan``. If the template " |
| 2172 |
"produces the value ``Blogs, Joe;Posts, Susan``, then the book will have one " |
| 2173 |
"author with a rather strange name." |
| 2174 |
msgstr "" |
| 2175 |
|
| 2176 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:679 |
| 2177 |
msgid "" |
| 2178 |
"Plugboards affect the metadata written into the book when it is saved to " |
| 2179 |
"disk or written to the device. Plugboards do not affect the metadata used by" |
| 2180 |
" ``save to disk`` and ``send to device`` to create the file names. Instead, " |
| 2181 |
"file names are constructed using the templates entered on the appropriate " |
| 2182 |
"preferences window." |
| 2183 |
msgstr "" |
| 2184 |
|
| 2185 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:682 |
| 2186 |
msgid "Tips" |
| 2187 |
msgstr "" |
| 2188 |
|
| 2189 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:684 |
| 2190 |
msgid "" |
| 2191 |
"Use the Template Tester to test templates. Add the tester to the context " |
| 2192 |
"menu for books in the library and/or give it a keyboard shortcut." |
| 2193 |
msgstr "" |
| 2194 |
|
| 2195 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:685 |
| 2196 |
msgid "" |
| 2197 |
"Templates can use other templates by referencing composite columns built " |
| 2198 |
"with the desired template. Alternatively, you can use Stored Templates." |
| 2199 |
msgstr "" |
| 2200 |
|
| 2201 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:686 |
| 2202 |
msgid "" |
| 2203 |
"In a plugboard, you can set a field to empty (or whatever is equivalent to " |
| 2204 |
"empty) by using the special template ``{}``. This template will always " |
| 2205 |
"evaluate to an empty string." |
| 2206 |
msgstr "" |
| 2207 |
|
| 2208 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:687 |
| 2209 |
msgid "" |
| 2210 |
"The technique described above to show numbers even if they have a zero value" |
| 2211 |
" works with the standard field series_index." |
| 2212 |
msgstr "" |
| 2213 |
|
| 2214 |
#: ../../__w/calibre/calibre/manual/template_lang.rst:692 |
| 2215 |
msgid "Function reference" |
| 2216 |
msgstr "" |