| 1 |
# SOME DESCRIPTIVE TITLE. |
| 2 |
# Copyright (C) Kovid Goyal |
| 3 |
# This file is distributed under the same license as the calibre package. |
| 4 |
# |
| 5 |
# Translators: |
| 6 |
msgid "" |
| 7 |
msgstr "" |
| 8 |
"Project-Id-Version: calibre\n" |
| 9 |
"Report-Msgid-Bugs-To: \n" |
| 10 |
"POT-Creation-Date: 2014-10-17 08:20+0530\n" |
| 11 |
"PO-Revision-Date: 2014-10-17 02:53+0000\n" |
| 12 |
"Last-Translator: Kovid Goyal <[email protected]>\n" |
| 13 |
"Language-Team: Slovenian (Slovenia) (http://www.transifex.com/projects/p/calibre/language/sl_SI/)\n" |
| 14 |
"MIME-Version: 1.0\n" |
| 15 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 16 |
"Content-Transfer-Encoding: 8bit\n" |
| 17 |
"Language: sl_SI\n" |
| 18 |
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
| 19 |
|
| 20 |
# 354b09cd8cb84b75a96a6f38d1b71151 |
| 21 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:4 |
| 22 |
msgid "The calibre template language" |
| 23 |
msgstr "" |
| 24 |
|
| 25 |
# 76febb8a80744fa6a1ad1ee582f61896 |
| 26 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:6 |
| 27 |
msgid "" |
| 28 |
"The calibre template language is used in various places. It is used to " |
| 29 |
"control the folder structure and file name when saving files from the " |
| 30 |
"calibre library to the disk or eBook reader. It is also used to define " |
| 31 |
"\"virtual\" columns that contain data from other columns and so on." |
| 32 |
msgstr "" |
| 33 |
|
| 34 |
# c062703bc63b4158a2337b393084f425 |
| 35 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:9 |
| 36 |
msgid "" |
| 37 |
"The basic template language is very simple, but has very powerful advanced " |
| 38 |
"features. The basic idea is that a template consists of text and names in " |
| 39 |
"curly brackets that are then replaced by the corresponding metadata from the" |
| 40 |
" book being processed. So, for example, the default template used for saving" |
| 41 |
" books to device in calibre is::" |
| 42 |
msgstr "" |
| 43 |
|
| 44 |
# 9370bfb3387b42dfb89ad5669c87ed42 |
| 45 |
# 01f7a72aaea54b1b8f2881a0fe2f2723 |
| 46 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:13 |
| 47 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:21 |
| 48 |
msgid "For the book \"The Foundation\" by \"Isaac Asimov\" it will become::" |
| 49 |
msgstr "" |
| 50 |
|
| 51 |
# d1395e69a10546a4b90ebc8bb95df495 |
| 52 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:17 |
| 53 |
msgid "" |
| 54 |
"The slashes are text, which is put into the template where it appears. For " |
| 55 |
"example, if your template is::" |
| 56 |
msgstr "" |
| 57 |
|
| 58 |
# 4ba3ccf969654e56b74b28c05b0e3dcd |
| 59 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:25 |
| 60 |
msgid "" |
| 61 |
"You can use all the various metadata fields available in calibre in a " |
| 62 |
"template, including any custom columns you have created yourself. To find " |
| 63 |
"out the template name for a column simply hover your mouse over the column " |
| 64 |
"header. Names for custom fields (columns you have created yourself) always " |
| 65 |
"have a # as the first character. For series type custom fields, there is " |
| 66 |
"always an additional field named ``#seriesname_index`` that becomes the " |
| 67 |
"series index for that series. So if you have a custom series field named " |
| 68 |
"``#myseries``, there will also be a field named ``#myseries_index``." |
| 69 |
msgstr "" |
| 70 |
|
| 71 |
# df5ac54024fa42178aa7c7d9b88b13cb |
| 72 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:27 |
| 73 |
msgid "In addition to the column based fields, you also can use::" |
| 74 |
msgstr "" |
| 75 |
|
| 76 |
# 6f333e8a76d742c09b6e2f9db0877dff |
| 77 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:32 |
| 78 |
msgid "" |
| 79 |
"If a particular book does not have a particular piece of metadata, the field" |
| 80 |
" in the template is automatically removed for that book. Consider, for " |
| 81 |
"example::" |
| 82 |
msgstr "" |
| 83 |
|
| 84 |
# 7d3f05c94a8a406888412b4755d025c9 |
| 85 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:36 |
| 86 |
msgid "If a book has a series, the template will produce::" |
| 87 |
msgstr "" |
| 88 |
|
| 89 |
# 5302f2c92c9546c0ab5079e4d81d769b |
| 90 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:40 |
| 91 |
msgid "and if a book does not have a series::" |
| 92 |
msgstr "" |
| 93 |
|
| 94 |
# a37b5ad259814fb5881db5b5af5b413a |
| 95 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:44 |
| 96 |
msgid "" |
| 97 |
"(calibre automatically removes multiple slashes and leading or trailing " |
| 98 |
"spaces)." |
| 99 |
msgstr "" |
| 100 |
|
| 101 |
# 03b035629573410b8087521e122893aa |
| 102 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:47 |
| 103 |
msgid "Advanced formatting" |
| 104 |
msgstr "" |
| 105 |
|
| 106 |
# 45575bf20e454be2aec4298500cce879 |
| 107 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:49 |
| 108 |
msgid "" |
| 109 |
"You can do more than just simple substitution with the templates. You can " |
| 110 |
"also conditionally include text and control how the substituted data is " |
| 111 |
"formatted." |
| 112 |
msgstr "" |
| 113 |
|
| 114 |
# f21bf9db691f425a9a1057604dc1c0cb |
| 115 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:51 |
| 116 |
msgid "" |
| 117 |
"First, conditionally including text. There are cases where you might want to" |
| 118 |
" have text appear in the output only if a field is not empty. A common case " |
| 119 |
"is ``series`` and ``series_index``, where you want either nothing or the two" |
| 120 |
" values with a hyphen between them. Calibre handles this case using a " |
| 121 |
"special field syntax." |
| 122 |
msgstr "" |
| 123 |
|
| 124 |
# e97ffc8ae74f48c78e4591852ca5226f |
| 125 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:53 |
| 126 |
msgid "For example, assume you want to use the template::" |
| 127 |
msgstr "" |
| 128 |
|
| 129 |
# bbd11b38c88840838ad6f4dcb26e7e5b |
| 130 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:57 |
| 131 |
msgid "" |
| 132 |
"If the book has no series, the answer will be ``- - title``. Many people " |
| 133 |
"would rather the result be simply ``title``, without the hyphens. To do " |
| 134 |
"this, use the extended syntax ``{field:|prefix_text|suffix_text}``. When you" |
| 135 |
" use this syntax, if field has the value SERIES then the result will be " |
| 136 |
"``prefix_textSERIESsuffix_text``. If field has no value, then the result " |
| 137 |
"will be the empty string (nothing); the prefix and suffix are ignored. The " |
| 138 |
"prefix and suffix can contain blanks. **Do not use subtemplates (`{ ... }`) " |
| 139 |
"or functions (see below) as the prefix or the suffix.**" |
| 140 |
msgstr "" |
| 141 |
|
| 142 |
# ecca71b3899a4429bff6b1c6f5124e49 |
| 143 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:59 |
| 144 |
msgid "" |
| 145 |
"Using this syntax, we can solve the above series problem with the template::" |
| 146 |
msgstr "" |
| 147 |
|
| 148 |
# 933da6d5a6eb485cb1a18ab4467110d9 |
| 149 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:63 |
| 150 |
msgid "" |
| 151 |
"The hyphens will be included only if the book has a series index, which it " |
| 152 |
"will have only if it has a series." |
| 153 |
msgstr "" |
| 154 |
|
| 155 |
# 9862b0af6aab424cbc26a3c7267c6dc3 |
| 156 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:65 |
| 157 |
msgid "" |
| 158 |
"Notes: you must include the : character if you want to use a prefix or a " |
| 159 |
"suffix. You must either use no \\| characters or both of them; using one, as" |
| 160 |
" in ``{field:| - }``, is not allowed. It is OK not to provide any text for " |
| 161 |
"one side or the other, such as in ``{series:|| - }``. Using ``{title:||}`` " |
| 162 |
"is the same as using ``{title}``." |
| 163 |
msgstr "" |
| 164 |
|
| 165 |
# af1f63bee9874551b6f6529451ef348d |
| 166 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:67 |
| 167 |
msgid "" |
| 168 |
"Second: formatting. Suppose you wanted to ensure that the series_index is " |
| 169 |
"always formatted as three digits with leading zeros. This would do the " |
| 170 |
"trick::" |
| 171 |
msgstr "" |
| 172 |
|
| 173 |
# 3631c39bc28b4e9ba9d2cb28323c790d |
| 174 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:71 |
| 175 |
msgid "If instead of leading zeros you want leading spaces, use::" |
| 176 |
msgstr "" |
| 177 |
|
| 178 |
# cc6b895fa3de4014bb51b9049a0b56be |
| 179 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:75 |
| 180 |
msgid "For trailing zeros, use::" |
| 181 |
msgstr "" |
| 182 |
|
| 183 |
# c6f75d96f637488ebc2d0272243c5a7c |
| 184 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:79 |
| 185 |
msgid "" |
| 186 |
"If you use series indices with sub values (e.g., 1.1), you might want to " |
| 187 |
"ensure that the decimal points line up. For example, you might want the " |
| 188 |
"indices 1 and 2.5 to appear as 01.00 and 02.50 so that they will sort " |
| 189 |
"correctly. To do this, use::" |
| 190 |
msgstr "" |
| 191 |
|
| 192 |
# 206cc4c09e1c41adb3dd9f8770a4670d |
| 193 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:83 |
| 194 |
msgid "If you want only the first two letters of the data, use::" |
| 195 |
msgstr "" |
| 196 |
|
| 197 |
# 97d38c8f1b514f3c8ad36990885b65ec |
| 198 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:87 |
| 199 |
msgid "" |
| 200 |
"The calibre template language comes from python and for more details on the " |
| 201 |
"syntax of these advanced formatting operations, look at the `Python " |
| 202 |
"documentation <http://docs.python.org/library/string.html#format-string-" |
| 203 |
"syntax>`_." |
| 204 |
msgstr "" |
| 205 |
|
| 206 |
# 278d4bd61559435d9e7ff8a2e1a0dc39 |
| 207 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:90 |
| 208 |
msgid "Advanced features" |
| 209 |
msgstr "" |
| 210 |
|
| 211 |
# 40cbeae0753640ea846c18f4c3b8ae59 |
| 212 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:93 |
| 213 |
msgid "Using templates in custom columns" |
| 214 |
msgstr "" |
| 215 |
|
| 216 |
# 6213cb4bb4804188bcdd6c38e87f2832 |
| 217 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:95 |
| 218 |
msgid "" |
| 219 |
"There are sometimes cases where you want to display metadata that calibre " |
| 220 |
"does not normally display, or to display data in a way different from how " |
| 221 |
"calibre normally does. For example, you might want to display the ISBN, a " |
| 222 |
"field that calibre does not display. You can use custom columns for this by " |
| 223 |
"creating a column with the type 'column built from other columns' (hereafter" |
| 224 |
" called composite columns), and entering a template. Result: calibre will " |
| 225 |
"display a column showing the result of evaluating that template. To display " |
| 226 |
"the ISBN, create the column and enter ``{identifiers:select(isbn)}`` into " |
| 227 |
"the template box. To display a column containing the values of two series " |
| 228 |
"custom columns separated by a comma, use ``{#series1:||,}{#series2}``." |
| 229 |
msgstr "" |
| 230 |
|
| 231 |
# fdd63712515b4e379f3947aa1690a1be |
| 232 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:97 |
| 233 |
msgid "Composite columns can use any template option, including formatting." |
| 234 |
msgstr "" |
| 235 |
|
| 236 |
# fad2b18bdfd847a3b1a0fa1a3dc25e49 |
| 237 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:99 |
| 238 |
msgid "" |
| 239 |
"You cannot change the data contained in a composite column. If you edit a " |
| 240 |
"composite column by double-clicking on any item, you will open the template " |
| 241 |
"for editing, not the underlying data. Editing the template on the GUI is a " |
| 242 |
"quick way of testing and changing composite columns." |
| 243 |
msgstr "" |
| 244 |
|
| 245 |
# fe8f5e948c164feaa80b5b804e710e08 |
| 246 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:102 |
| 247 |
msgid "Using functions in templates - single-function mode" |
| 248 |
msgstr "" |
| 249 |
|
| 250 |
# 0438968684874f209bf5041cdfc4a582 |
| 251 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:104 |
| 252 |
msgid "" |
| 253 |
"Suppose you want to display the value of a field in upper case, when that " |
| 254 |
"field is normally in title case. You can do this (and many more things) " |
| 255 |
"using the functions available for templates. For example, to display the " |
| 256 |
"title in upper case, use ``{title:uppercase()}``. To display it in title " |
| 257 |
"case, use ``{title:titlecase()}``." |
| 258 |
msgstr "" |
| 259 |
|
| 260 |
# 0fee6a48cf00475591e4a3903237814f |
| 261 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:106 |
| 262 |
msgid "" |
| 263 |
"Function references appear in the format part, going after the ``:`` and " |
| 264 |
"before the first ``|`` or the closing ``}``. If you have both a format and a" |
| 265 |
" function reference, the function comes after another ``:``. Functions must " |
| 266 |
"always end with ``()``. Some functions take extra values (arguments), and " |
| 267 |
"these go inside the ``()``." |
| 268 |
msgstr "" |
| 269 |
|
| 270 |
# 7af1ec3649c14eb8b16c80e473eec084 |
| 271 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:108 |
| 272 |
msgid "" |
| 273 |
"Functions are always applied before format specifications. See further down " |
| 274 |
"for an example of using both a format and a function, where this order is " |
| 275 |
"demonstrated." |
| 276 |
msgstr "" |
| 277 |
|
| 278 |
# c4c7d507ceff40eaba7467eeb53dd2b4 |
| 279 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:110 |
| 280 |
msgid "" |
| 281 |
"The syntax for using functions is ``{field:function(arguments)}``, or " |
| 282 |
"``{field:function(arguments)|prefix|suffix}``. Arguments are separated by " |
| 283 |
"commas. Commas inside arguments must be preceeded by a backslash ( '\\\\' )." |
| 284 |
" The last (or only) argument cannot contain a closing parenthesis ( ')' ). " |
| 285 |
"Functions return the value of the field used in the template, suitably " |
| 286 |
"modified." |
| 287 |
msgstr "" |
| 288 |
|
| 289 |
# e42a01c9cad84928b3dca5a1e268220e |
| 290 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:112 |
| 291 |
msgid "" |
| 292 |
"Important: If you have programming experience, please note that the syntax " |
| 293 |
"in this mode (single function) is not what you might expect. Strings are not" |
| 294 |
" quoted. Spaces are significant. All arguments must be constants; there is " |
| 295 |
"no sub-evaluation. **Do not use subtemplates (`{ ... }`) as function " |
| 296 |
"arguments.** Instead, use :ref:`template program mode <template_mode>` and " |
| 297 |
":ref:`general program mode <general_mode>`." |
| 298 |
msgstr "" |
| 299 |
|
| 300 |
# 74727617ce6c4c0081a211f176dce90d |
| 301 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:114 |
| 302 |
msgid "" |
| 303 |
"Many functions use regular expressions. In all cases, regular expression " |
| 304 |
"matching is case-insensitive." |
| 305 |
msgstr "" |
| 306 |
|
| 307 |
# 997342be0eac49f5b0862608fe4f4ed9 |
| 308 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:116 |
| 309 |
msgid "" |
| 310 |
"The functions available are listed below. Note that the definitive " |
| 311 |
"documentation for functions is available in the section :ref:`Function " |
| 312 |
"classification <template_functions_reference>`:" |
| 313 |
msgstr "" |
| 314 |
|
| 315 |
# e49c1fa7f8b24e7db4d5c834b4830607 |
| 316 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:118 |
| 317 |
msgid "``lowercase()`` -- return value of the field in lower case." |
| 318 |
msgstr "" |
| 319 |
|
| 320 |
# 5254dbf64dfc454b95a6c63e0d7ec9f0 |
| 321 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:119 |
| 322 |
msgid "``uppercase()`` -- return the value of the field in upper case." |
| 323 |
msgstr "" |
| 324 |
|
| 325 |
# a443b6f03f274cebad6c752d89aa1b2c |
| 326 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:120 |
| 327 |
msgid "``titlecase()`` -- return the value of the field in title case." |
| 328 |
msgstr "" |
| 329 |
|
| 330 |
# 6e70d2f08c304e2f9672ddc169398542 |
| 331 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:121 |
| 332 |
msgid "" |
| 333 |
"``capitalize()`` -- return the value with the first letter upper case and " |
| 334 |
"the rest lower case." |
| 335 |
msgstr "" |
| 336 |
|
| 337 |
# c355baa267c7451eb0bc408892b603c0 |
| 338 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:122 |
| 339 |
msgid "" |
| 340 |
"``contains(pattern, text if match, text if not match)`` -- checks if field " |
| 341 |
"contains matches for the regular expression `pattern`. Returns `text if " |
| 342 |
"match` if matches are found, otherwise it returns `text if no match`." |
| 343 |
msgstr "" |
| 344 |
|
| 345 |
# 5e4d1c1e85694bfcaae1cb372481adb3 |
| 346 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:123 |
| 347 |
msgid "" |
| 348 |
"``count(separator)`` -- interprets the value as a list of items separated by" |
| 349 |
" `separator`, returning the number of items in the list. Most lists use a " |
| 350 |
"comma as the separator, but authors uses an ampersand. Examples: " |
| 351 |
"`{tags:count(,)}`, `{authors:count(&)}`" |
| 352 |
msgstr "" |
| 353 |
|
| 354 |
# eb5a8f63f1734e8aaaa784d492fc1be2 |
| 355 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:124 |
| 356 |
msgid "" |
| 357 |
"``format_number(template)`` -- interprets the value as a number and format " |
| 358 |
"that number using a python formatting template such as \"{0:5.2f}\" or " |
| 359 |
"\"{0:,d}\" or \"${0:5,.2f}\". The field_name part of the template must be a " |
| 360 |
"0 (zero) (the \"{0:\" in the above examples). See the template language and " |
| 361 |
"python documentation for more examples. Returns the empty string if " |
| 362 |
"formatting fails." |
| 363 |
msgstr "" |
| 364 |
|
| 365 |
# 9ef2793289284ee8bcdd43015ecd5d96 |
| 366 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:125 |
| 367 |
msgid "" |
| 368 |
"``human_readable()`` -- expects the value to be a number and returns a " |
| 369 |
"string representing that number in KB, MB, GB, etc." |
| 370 |
msgstr "" |
| 371 |
|
| 372 |
# 9572135aa41a47d79124a80691ccf663 |
| 373 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:126 |
| 374 |
msgid "" |
| 375 |
"``ifempty(text)`` -- if the field is not empty, return the value of the " |
| 376 |
"field. Otherwise return `text`." |
| 377 |
msgstr "" |
| 378 |
|
| 379 |
# 99027781494b4b64b9789457a2a89829 |
| 380 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:127 |
| 381 |
msgid "" |
| 382 |
"``in_list(separator, pattern, found_val, not_found_val)`` -- interpret the " |
| 383 |
"field as a list of items separated by `separator`, comparing the `pattern` " |
| 384 |
"against each value in the list. If the pattern matches a value, return " |
| 385 |
"`found_val`, otherwise return `not_found_val`." |
| 386 |
msgstr "" |
| 387 |
|
| 388 |
# 3c37d4504bec4e8ba9e4615634e61b91 |
| 389 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:128 |
| 390 |
msgid "" |
| 391 |
"``language_codes(lang_strings)`` -- return the language codes for the " |
| 392 |
"strings passed in `lang_strings`. The strings must be in the language of the" |
| 393 |
" current locale. `Lang_strings` is a comma-separated list." |
| 394 |
msgstr "" |
| 395 |
|
| 396 |
# efdf20468956451fa2c9e126a4e79b88 |
| 397 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:129 |
| 398 |
msgid "" |
| 399 |
"``language_strings(lang_codes, localize)`` -- return the strings for the " |
| 400 |
"language codes passed in `lang_codes`. If `localize` is zero, return the " |
| 401 |
"strings in English. If localize is not zero, return the strings in the " |
| 402 |
"language of the current locale. `Lang_codes` is a comma-separated list." |
| 403 |
msgstr "" |
| 404 |
|
| 405 |
# fd264c29cf3d42899aded4bc8b9c45f3 |
| 406 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:130 |
| 407 |
msgid "" |
| 408 |
"``list_item(index, separator)`` -- interpret the field as a list of items " |
| 409 |
"separated by `separator`, returning the `index`th item. The first item is " |
| 410 |
"number zero. The last item can be returned using `list_item(-1,separator)`. " |
| 411 |
"If the item is not in the list, then the empty value is returned. The " |
| 412 |
"separator has the same meaning as in the `count` function." |
| 413 |
msgstr "" |
| 414 |
|
| 415 |
# 6b7b0dbf84a441b5852452304610ee2f |
| 416 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:131 |
| 417 |
msgid "" |
| 418 |
"``lookup(pattern, field, pattern, field, ..., else_field)`` -- like switch, " |
| 419 |
"except the arguments are field (metadata) names, not text. The value of the " |
| 420 |
"appropriate field will be fetched and used. Note that because composite " |
| 421 |
"columns are fields, you can use this function in one composite field to use " |
| 422 |
"the value of some other composite field. This is extremely useful when " |
| 423 |
"constructing variable save paths (more later)." |
| 424 |
msgstr "" |
| 425 |
|
| 426 |
# 3e60edb0ae2245b4b2d1ded327fa899e |
| 427 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:132 |
| 428 |
msgid "" |
| 429 |
"``re(pattern, replacement)`` -- return the field after applying the regular " |
| 430 |
"expression. All instances of `pattern` are replaced with `replacement`. As " |
| 431 |
"in all of calibre, these are python-compatible regular expressions." |
| 432 |
msgstr "" |
| 433 |
|
| 434 |
# 560f90009eb84ade874d8dc1aaee3ffb |
| 435 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:133 |
| 436 |
msgid "" |
| 437 |
"``select(key)`` -- interpret the field as a comma-separated list of items, " |
| 438 |
"with the items being of the form \"id:value\". Find the pair with the id " |
| 439 |
"equal to key, and return the corresponding value. This function is " |
| 440 |
"particularly useful for extracting a value such as an isbn from the set of " |
| 441 |
"identifiers for a book." |
| 442 |
msgstr "" |
| 443 |
|
| 444 |
# a00f23c856fd40b29f8136f76395ef67 |
| 445 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:134 |
| 446 |
msgid "" |
| 447 |
"``shorten(left chars, middle text, right chars)`` -- Return a shortened " |
| 448 |
"version of the field, consisting of `left chars` characters from the " |
| 449 |
"beginning of the field, followed by `middle text`, followed by `right chars`" |
| 450 |
" characters from the end of the string. `Left chars` and `right chars` must " |
| 451 |
"be integers. For example, assume the title of the book is `Ancient English " |
| 452 |
"Laws in the Times of Ivanhoe`, and you want it to fit in a space of at most " |
| 453 |
"15 characters. If you use ``{title:shorten(9,-,5)}``, the result will be " |
| 454 |
"`Ancient E-nhoe`. If the field's length is less than ``left chars`` + " |
| 455 |
"``right chars`` + the length of ``middle text``, then the field will be used" |
| 456 |
" intact. For example, the title `The Dome` would not be changed." |
| 457 |
msgstr "" |
| 458 |
|
| 459 |
# 221e08ff194d43b9aa687357aec6a0c3 |
| 460 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:135 |
| 461 |
msgid "" |
| 462 |
"``str_in_list(val, separator, string, found_val, not_found_val)`` -- treat " |
| 463 |
"val as a list of items separated by separator, comparing the string against " |
| 464 |
"each value in the list. If the string matches a value, return found_val, " |
| 465 |
"otherwise return not_found_val. If the string contains separators, then it " |
| 466 |
"is also treated as a list and each value is checked." |
| 467 |
msgstr "" |
| 468 |
|
| 469 |
# a69b45fa2d994652b02f6c5ac00a27bf |
| 470 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:136 |
| 471 |
msgid "" |
| 472 |
"``subitems(val, start_index, end_index)`` -- This function is used to break " |
| 473 |
"apart lists of tag-like hierarchical items such as genres. It interprets the" |
| 474 |
" value as a comma-separated list of tag-like items, where each item is a " |
| 475 |
"period-separated list. Returns a new list made by first finding all the " |
| 476 |
"period-separated tag-like items, then for each such item extracting the " |
| 477 |
"components from `start_index` to `end_index`, then combining the results " |
| 478 |
"back together. The first component in a period-separated list has an index " |
| 479 |
"of zero. If an index is negative, then it counts from the end of the list. " |
| 480 |
"As a special case, an end_index of zero is assumed to be the length of the " |
| 481 |
"list. Examples::" |
| 482 |
msgstr "" |
| 483 |
|
| 484 |
# 95b91541067a4e1f837cc7d7858acc49 |
| 485 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:146 |
| 486 |
msgid "" |
| 487 |
"``sublist(val, start_index, end_index, separator)`` -- interpret the value " |
| 488 |
"as a list of items separated by `separator`, returning a new list made from " |
| 489 |
"the items from `start_index`to `end_index`. The first item is number zero. " |
| 490 |
"If an index is negative, then it counts from the end of the list. As a " |
| 491 |
"special case, an end_index of zero is assumed to be the length of the list. " |
| 492 |
"Examples assuming that the tags column (which is comma-separated) contains " |
| 493 |
"\"A, B ,C\"::" |
| 494 |
msgstr "" |
| 495 |
|
| 496 |
# 32f4ae47b77e4e6bb6d6bf8a13c9cfdb |
| 497 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:152 |
| 498 |
msgid "" |
| 499 |
"``swap_around_comma(val) `` -- given a value of the form ``B, A``, return " |
| 500 |
"``A B``. This is most useful for converting names in LN, FN format to FN LN." |
| 501 |
" If there is no comma, the function returns val unchanged." |
| 502 |
msgstr "" |
| 503 |
|
| 504 |
# 511f9da6172b40858dcf00de80d144d1 |
| 505 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:153 |
| 506 |
msgid "" |
| 507 |
"``switch(pattern, value, pattern, value, ..., else_value)`` -- for each " |
| 508 |
"``pattern, value`` pair, checks if the field matches the regular expression " |
| 509 |
"``pattern`` and if so, returns that ``value``. If no ``pattern`` matches, " |
| 510 |
"then ``else_value`` is returned. You can have as many ``pattern, value`` " |
| 511 |
"pairs as you want." |
| 512 |
msgstr "" |
| 513 |
|
| 514 |
# 64973433dbd6430b8f5e056a8eb0ee48 |
| 515 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:154 |
| 516 |
msgid "" |
| 517 |
"``test(text if not empty, text if empty)`` -- return `text if not empty` if " |
| 518 |
"the field is not empty, otherwise return `text if empty`." |
| 519 |
msgstr "" |
| 520 |
|
| 521 |
# 2701e37c99d54ae3bb23a800ab2f8804 |
| 522 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:155 |
| 523 |
msgid "" |
| 524 |
"``transliterate()`` -- Returns a string in a latin alphabet formed by " |
| 525 |
"approximating the sound of the words in the source field. For example, if " |
| 526 |
"the source field is ``Фёдор Миха́йлович Достоевский`` the function returns " |
| 527 |
"``Fiodor Mikhailovich Dostoievskii``.'" |
| 528 |
msgstr "" |
| 529 |
|
| 530 |
# b31b88e6f20d4b7890e3bac1968b694f |
| 531 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:157 |
| 532 |
msgid "" |
| 533 |
"Now, what about using functions and formatting in the same field. Suppose " |
| 534 |
"you have an integer custom column called ``#myint`` that you want to see " |
| 535 |
"with leading zeros, as in ``003``. To do this, you would use a format of " |
| 536 |
"``0>3s``. However, by default, if a number (integer or float) equals zero " |
| 537 |
"then the field produces the empty value, so zero values will produce " |
| 538 |
"nothing, not ``000``. If you really want to see ``000`` values, then you use" |
| 539 |
" both the format string and the ``ifempty`` function to change the empty " |
| 540 |
"value back to a zero. The field reference would be::" |
| 541 |
msgstr "" |
| 542 |
|
| 543 |
# 09a64f88fff44290ac2196714f40c662 |
| 544 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:161 |
| 545 |
msgid "" |
| 546 |
"Note that you can use the prefix and suffix as well. If you want the number " |
| 547 |
"to appear as ``[003]`` or ``[000]``, then use the field::" |
| 548 |
msgstr "" |
| 549 |
|
| 550 |
# a68e726e856b440eb59431c8cea48b42 |
| 551 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:168 |
| 552 |
msgid "Using functions in templates - template program mode" |
| 553 |
msgstr "" |
| 554 |
|
| 555 |
# a47d17e2312b4fd386a3ec40be22b1bf |
| 556 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:170 |
| 557 |
msgid "" |
| 558 |
"The template language program mode differs from single-function mode in that" |
| 559 |
" it permits you to write template expressions that refer to other metadata " |
| 560 |
"fields, modify values, and do arithmetic. It is a reasonably complete " |
| 561 |
"programming language." |
| 562 |
msgstr "" |
| 563 |
|
| 564 |
# de34e67d26764b659c79f3071f91c711 |
| 565 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:172 |
| 566 |
msgid "" |
| 567 |
"You can use the functions documented above in template program mode. See " |
| 568 |
"below for details." |
| 569 |
msgstr "" |
| 570 |
|
| 571 |
# 112233c2f3454dbaac086a6f07a453ea |
| 572 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:174 |
| 573 |
msgid "" |
| 574 |
"Beginning with an example, assume that you want your template to show the " |
| 575 |
"series for a book if it has one, otherwise show the value of a custom field " |
| 576 |
"#genre. You cannot do this in the basic language because you cannot make " |
| 577 |
"reference to another metadata field within a template expression. In program" |
| 578 |
" mode, you can. The following expression works::" |
| 579 |
msgstr "" |
| 580 |
|
| 581 |
# 70cffe78d74e4ed4aacd0de4e3569873 |
| 582 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:178 |
| 583 |
msgid "The example shows several things:" |
| 584 |
msgstr "" |
| 585 |
|
| 586 |
# 2d7d8c2c5360482f9d7285af5836eca9 |
| 587 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:180 |
| 588 |
msgid "" |
| 589 |
"program mode is used if the expression begins with ``:'`` and ends with " |
| 590 |
"``'``. Anything else is assumed to be single-function." |
| 591 |
msgstr "" |
| 592 |
|
| 593 |
# 7b5633a3c7e54765aed0464b1bd678cb |
| 594 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:181 |
| 595 |
msgid "" |
| 596 |
"the variable ``$`` stands for the field the expression is operating upon, " |
| 597 |
"``#series`` in this case." |
| 598 |
msgstr "" |
| 599 |
|
| 600 |
# 2c9902c9ee8a421eaa36c410b841be65 |
| 601 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:182 |
| 602 |
msgid "" |
| 603 |
"functions must be given all their arguments. There is no default value. For " |
| 604 |
"example, the standard built-in functions must be given an additional initial" |
| 605 |
" parameter indicating the source field, which is a significant difference " |
| 606 |
"from single-function mode." |
| 607 |
msgstr "" |
| 608 |
|
| 609 |
# 22968ae862914bb7841abdb59d2ada4a |
| 610 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:183 |
| 611 |
msgid "white space is ignored and can be used anywhere within the expression." |
| 612 |
msgstr "" |
| 613 |
|
| 614 |
# 273137268a804b17988b165e913f3a3d |
| 615 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:184 |
| 616 |
msgid "" |
| 617 |
"constant strings are enclosed in matching quotes, either ``'`` or ``\"``." |
| 618 |
msgstr "" |
| 619 |
|
| 620 |
# a1996fb8eb644e47a155617617f5950e |
| 621 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:186 |
| 622 |
msgid "" |
| 623 |
"The language is similar to ``functional`` languages in that it is built " |
| 624 |
"almost entirely from functions. A statement is a function. An expression is " |
| 625 |
"a function. Constants and identifiers can be thought of as functions " |
| 626 |
"returning the value indicated by the constant or stored in the identifier." |
| 627 |
msgstr "" |
| 628 |
|
| 629 |
# aca52b2eac294213b99bfe24fe0d5662 |
| 630 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:188 |
| 631 |
msgid "The syntax of the language is shown by the following grammar::" |
| 632 |
msgstr "" |
| 633 |
|
| 634 |
# 629ba74b03764a6b8cfd64623f57573b |
| 635 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:198 |
| 636 |
msgid "Comments are lines with a '#' character at the beginning of the line." |
| 637 |
msgstr "" |
| 638 |
|
| 639 |
# 6658d2bfe134483aa634038a031f17df |
| 640 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:200 |
| 641 |
msgid "" |
| 642 |
"An ``expression`` always has a value, either the value of the constant, the " |
| 643 |
"value contained in the identifier, or the value returned by a function. The " |
| 644 |
"value of a ``statement`` is the value of the last expression in the sequence" |
| 645 |
" of statements. As such, the value of the program (statement)::" |
| 646 |
msgstr "" |
| 647 |
|
| 648 |
# 4528d9f73b9d4ecba0b3bdbb19af4847 |
| 649 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:204 |
| 650 |
msgid "is 3." |
| 651 |
msgstr "" |
| 652 |
|
| 653 |
# b0f850e540ba4a928ad193b736274a4c |
| 654 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:206 |
| 655 |
msgid "" |
| 656 |
"Another example of a complex but rather silly program might help make things" |
| 657 |
" clearer::" |
| 658 |
msgstr "" |
| 659 |
|
| 660 |
# 765797892b304074bbb8ad5ca990dcdf |
| 661 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:217 |
| 662 |
msgid "This program does the following:" |
| 663 |
msgstr "" |
| 664 |
|
| 665 |
# 7f040fa9db7c44e7815f2b7088eb6819 |
| 666 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:219 |
| 667 |
msgid "" |
| 668 |
"specify that the field being looked at is series_index. This sets the value " |
| 669 |
"of the variable ``$``." |
| 670 |
msgstr "" |
| 671 |
|
| 672 |
# 3c705557ef0a4961a1b7155c2eeb0353 |
| 673 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:220 |
| 674 |
msgid "" |
| 675 |
"calls the ``substr`` function, which takes 3 parameters ``(str, start, " |
| 676 |
"end)``. It returns a string formed by extracting the start through end " |
| 677 |
"characters from string, zero-based (the first character is character zero). " |
| 678 |
"In this case the string will be computed by the ``strcat`` function, the " |
| 679 |
"start is 0, and the end is 6. In this case it will return the first 6 " |
| 680 |
"characters of the string returned by ``strcat``, which must be evaluated " |
| 681 |
"before substr can return." |
| 682 |
msgstr "" |
| 683 |
|
| 684 |
# cbded60635d34e0c8fb577b1f0bef1a9 |
| 685 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:221 |
| 686 |
msgid "" |
| 687 |
"calls the ``strcat`` (string concatenation) function. Strcat accepts 1 or " |
| 688 |
"more arguments, and returns a string formed by concatenating all the values." |
| 689 |
" In this case there are three arguments. The first parameter is the value in" |
| 690 |
" ``$``, which here is the value of ``series_index``. The second paremeter is" |
| 691 |
" the constant string ``'->'``. The third parameter is the value returned by " |
| 692 |
"the ``cmp`` function, which must be fully evaluated before ``strcat`` can " |
| 693 |
"return." |
| 694 |
msgstr "" |
| 695 |
|
| 696 |
# 63caefcc6b6e4c0ab8b9df036c46b064 |
| 697 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:222 |
| 698 |
msgid "" |
| 699 |
"The ``cmp`` function takes 5 arguments ``(x, y, lt, eq, gt)``. It compares x" |
| 700 |
" and y and returns the third argument ``lt`` if x < y, the fourth argument " |
| 701 |
"``eq`` if x == y, and the fifth argument ``gt`` if x > y. As with all " |
| 702 |
"functions, all of the parameters can be statements. In this case the first " |
| 703 |
"parameter (the value for ``x``) is the result of dividing the series_index " |
| 704 |
"by 2. The second parameter ``y`` is the constant ``1``. The third parameter " |
| 705 |
"``lt`` is a statement (more later). The fourth parameter ``eq`` is the " |
| 706 |
"constant string ``'eq'``. The fifth parameter is the constant string " |
| 707 |
"``'gt'``." |
| 708 |
msgstr "" |
| 709 |
|
| 710 |
# f2525af20364470598033af844f1f40d |
| 711 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:223 |
| 712 |
msgid "" |
| 713 |
"The third parameter (the one for ``lt``) is a statement, or a sequence of " |
| 714 |
"expressions. Remember that a statement (a sequence of semicolon-separated " |
| 715 |
"expressions) is also an expression, returning the value of the last " |
| 716 |
"expression in the list. In this case, the program first assigns the value " |
| 717 |
"``1`` to a local variable ``c``, then returns a substring made by extracting" |
| 718 |
" the c'th character to the end. Since c always contains the constant ``1``, " |
| 719 |
"the substring will return the second through end'th characters, or " |
| 720 |
"``'t123'``." |
| 721 |
msgstr "" |
| 722 |
|
| 723 |
# d7998d939c644ab586cb412d8317f417 |
| 724 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:224 |
| 725 |
msgid "" |
| 726 |
"Once the statement providing the value to the third parameter is executed, " |
| 727 |
"``cmp`` can return a value. At that point, ``strcat` can return a value, " |
| 728 |
"then ``substr`` can return a value. The program then terminates." |
| 729 |
msgstr "" |
| 730 |
|
| 731 |
# 29ae64115d5542a3bb1480400dedef19 |
| 732 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:226 |
| 733 |
msgid "For various values of series_index, the program returns:" |
| 734 |
msgstr "" |
| 735 |
|
| 736 |
# 2362a34dfbdb4a5da07b3a9dd57976ca |
| 737 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:228 |
| 738 |
msgid "series_index == undefined, result = ``prefix ->t123 suffix``" |
| 739 |
msgstr "" |
| 740 |
|
| 741 |
# 2c4517bb300c486ea864198873d79ed6 |
| 742 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:229 |
| 743 |
msgid "series_index == 0.5, result = ``prefix 0.50-> suffix``" |
| 744 |
msgstr "" |
| 745 |
|
| 746 |
# dcf23c5b3a8b441890a59542c4da4fbe |
| 747 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:230 |
| 748 |
msgid "series_index == 1, result = ``prefix 1->t12 suffix``" |
| 749 |
msgstr "" |
| 750 |
|
| 751 |
# 7b9e9c5526c34d4c911833521b176b1e |
| 752 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:231 |
| 753 |
msgid "series_index == 2, result = ``prefix 2->eq suffix``" |
| 754 |
msgstr "" |
| 755 |
|
| 756 |
# 3c60700d68964557b847ab035de07cd9 |
| 757 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:232 |
| 758 |
msgid "series_index == 3, result = ``prefix 3->gt suffix``" |
| 759 |
msgstr "" |
| 760 |
|
| 761 |
# 2895c2f8f8d642bc8c0d9aed4c9a5200 |
| 762 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:234 |
| 763 |
msgid "" |
| 764 |
"**All the functions listed under single-function mode can be used in program" |
| 765 |
" mode**. To do so, you must supply the value that the function is to act " |
| 766 |
"upon as the first parameter, in addition to the parameters documented above." |
| 767 |
" For example, in program mode the parameters of the `test` function are " |
| 768 |
"``test(x, text_if_not_empty, text_if_empty)``. The `x` parameter, which is " |
| 769 |
"the value to be tested, will almost always be a variable or a function call," |
| 770 |
" often `field()`." |
| 771 |
msgstr "" |
| 772 |
|
| 773 |
# c946ec9e0f2e43bea58948b950f65f7b |
| 774 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:236 |
| 775 |
msgid "" |
| 776 |
"The following functions are available in addition to those described in " |
| 777 |
"single-function mode. Remember from the example above that the single-" |
| 778 |
"function mode functions require an additional first parameter specifying the" |
| 779 |
" field to operate on. With the exception of the ``id`` parameter of assign, " |
| 780 |
"all parameters can be statements (sequences of expressions). Note that the " |
| 781 |
"definitive documentation for functions is available in the section " |
| 782 |
":ref:`Function classification <template_functions_reference>`:" |
| 783 |
msgstr "" |
| 784 |
|
| 785 |
# 3b8665a09876443b8e9183a8e9a7b61f |
| 786 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:238 |
| 787 |
msgid "" |
| 788 |
"``and(value, value, ...)`` -- returns the string \"1\" if all values are not" |
| 789 |
" empty, otherwise returns the empty string. This function works well with " |
| 790 |
"test or first_non_empty. You can have as many values as you want." |
| 791 |
msgstr "" |
| 792 |
|
| 793 |
# 0c5ac135e98443039f22624e71963f99 |
| 794 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:239 |
| 795 |
msgid "" |
| 796 |
"``add(x, y)`` -- returns x + y. Throws an exception if either x or y are not" |
| 797 |
" numbers." |
| 798 |
msgstr "" |
| 799 |
|
| 800 |
# 612b5ec622fe4e5088448ee1a8f233cd |
| 801 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:240 |
| 802 |
msgid "" |
| 803 |
"``assign(id, val)`` -- assigns val to id, then returns val. id must be an " |
| 804 |
"identifier, not an expression" |
| 805 |
msgstr "" |
| 806 |
|
| 807 |
# 0e2ddc00f28146c597b43ff125d196ed |
| 808 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:242 |
| 809 |
msgid "" |
| 810 |
"``approximate_formats()`` -- return a comma-separated list of formats that " |
| 811 |
"at one point were associated with the book. There is no guarantee that the " |
| 812 |
"list is correct, although it probably is. This function can be called in " |
| 813 |
"template program mode using the template ``{:'approximate_formats()'}``. " |
| 814 |
"Note that format names are always uppercase, as in EPUB." |
| 815 |
msgstr "" |
| 816 |
|
| 817 |
# 62bd88bd6fc443fca65462cc63904b8a |
| 818 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:242 |
| 819 |
msgid "" |
| 820 |
"``author_links(val_separator, pair_separator)`` -- returns a string " |
| 821 |
"containing a list of authors and that author's link values in the form " |
| 822 |
"``author1 val_separator author1link pair_separator author2 val_separator " |
| 823 |
"author2link`` etc. An author is separated from its link value by the " |
| 824 |
"``val_separator`` string with no added spaces. ``author:linkvalue`` pairs " |
| 825 |
"are separated by the ``pair_separator`` string argument with no added " |
| 826 |
"spaces. It is up to you to choose separator strings that do not occur in " |
| 827 |
"author names or links. An author is included even if the author link is " |
| 828 |
"empty." |
| 829 |
msgstr "" |
| 830 |
|
| 831 |
# 23f5878784cb4f009cd64e3dd2ebfb39 |
| 832 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:243 |
| 833 |
msgid "" |
| 834 |
"``author_sorts(val_separator)`` -- returns a string containing a list of " |
| 835 |
"author's sort values for the authors of the book. The sort is the one in the" |
| 836 |
" author metadata (different from the author_sort in books). The returned " |
| 837 |
"list has the form author sort 1 ``val_separator`` author sort 2 etc. The " |
| 838 |
"author sort values in this list are in the same order as the authors of the " |
| 839 |
"book. If you want spaces around ``val_separator`` then include them in the " |
| 840 |
"separator string" |
| 841 |
msgstr "" |
| 842 |
|
| 843 |
# 6393567e88d94c8d86ce63a01457ae54 |
| 844 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:244 |
| 845 |
msgid "" |
| 846 |
"``booksize()`` -- returns the value of the calibre 'size' field. Returns '' " |
| 847 |
"if there are no formats." |
| 848 |
msgstr "" |
| 849 |
|
| 850 |
# 3a1710869996419f9e323a6960b8f704 |
| 851 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:245 |
| 852 |
msgid "" |
| 853 |
"``cmp(x, y, lt, eq, gt)`` -- compares x and y after converting both to " |
| 854 |
"numbers. Returns ``lt`` if x < y. Returns ``eq`` if x == y. Otherwise " |
| 855 |
"returns ``gt``." |
| 856 |
msgstr "" |
| 857 |
|
| 858 |
# d5e039e076f34ea7ac886d4fd2c4ef35 |
| 859 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:246 |
| 860 |
msgid "" |
| 861 |
"``current_library_name() -- `` return the last name on the path to the " |
| 862 |
"current calibre library. This function can be called in template program " |
| 863 |
"mode using the template ``{:'current_library_name()'}``." |
| 864 |
msgstr "" |
| 865 |
|
| 866 |
# 51c13f516f7c40808b45e182ce54f970 |
| 867 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:247 |
| 868 |
msgid "" |
| 869 |
"``current_library_path() -- `` return the path to the current calibre " |
| 870 |
"library. This function can be called in template program mode using the " |
| 871 |
"template ``{:'current_library_path()'}``.." |
| 872 |
msgstr "" |
| 873 |
|
| 874 |
# dccc1d4ae8ed4964a1a9800f3ec185b7 |
| 875 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:248 |
| 876 |
msgid "" |
| 877 |
"``days_between(date1, date2)`` -- return the number of days between " |
| 878 |
"``date1`` and ``date2``. The number is positive if ``date1`` is greater than" |
| 879 |
" ``date2``, otherwise negative. If either ``date1`` or ``date2`` are not " |
| 880 |
"dates, the function returns the empty string." |
| 881 |
msgstr "" |
| 882 |
|
| 883 |
# 04c3160e631c4ceba5443e92e708a67b |
| 884 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:249 |
| 885 |
msgid "" |
| 886 |
"``divide(x, y)`` -- returns x / y. Throws an exception if either x or y are " |
| 887 |
"not numbers." |
| 888 |
msgstr "" |
| 889 |
|
| 890 |
# 198a630e59b042aaac2aa4f170f4a9e7 |
| 891 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:250 |
| 892 |
msgid "" |
| 893 |
"``eval(string)`` -- evaluates the string as a program, passing the local " |
| 894 |
"variables (those ``assign`` ed to). This permits using the template " |
| 895 |
"processor to construct complex results from local variables. Because the `{`" |
| 896 |
" and `}` characters are special, you must use `[[` for the `{` character and" |
| 897 |
" `]]` for the '}' character; they are converted automatically. Note also " |
| 898 |
"that prefixes and suffixes (the `|prefix|suffix` syntax) cannot be used in " |
| 899 |
"the argument to this function when using template program mode." |
| 900 |
msgstr "" |
| 901 |
|
| 902 |
# b273f579374d4e6e96e78cb8502c3a80 |
| 903 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:251 |
| 904 |
msgid "``field(name)`` -- returns the metadata field named by ``name``." |
| 905 |
msgstr "" |
| 906 |
|
| 907 |
# 161d624e150d4ecfb704c13b75d1d800 |
| 908 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:252 |
| 909 |
msgid "" |
| 910 |
"``first_matching_cmp(val, cmp1, result1, cmp2, r2, ..., else_result)`` -- " |
| 911 |
"compares \"val < cmpN\" in sequence, returning resultN for the first " |
| 912 |
"comparison that succeeds. Returns else_result if no comparison succeeds. " |
| 913 |
"Example::" |
| 914 |
msgstr "" |
| 915 |
|
| 916 |
# e49f3f474e1e49baa814ac91216c1cc6 |
| 917 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:256 |
| 918 |
msgid "" |
| 919 |
"returns \"large\". The same example with a first value of 16 returns " |
| 920 |
"\"giant\". * ``first_non_empty(value, value, ...)`` -- returns the first " |
| 921 |
"value that is not empty. If all values are empty, then the empty value is " |
| 922 |
"returned. You can have as many values as you want. * ``format_date(x, " |
| 923 |
"date_format)`` -- format_date(val, format_string) -- format the value, which" |
| 924 |
" must be a date field, using the format_string, returning a string. The " |
| 925 |
"formatting codes are::" |
| 926 |
msgstr "" |
| 927 |
|
| 928 |
# cc699904b9dd4237a195de0545b53808 |
| 929 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:280 |
| 930 |
msgid "" |
| 931 |
"You might get unexpected results if the date you are formatting contains " |
| 932 |
"localized month names, which can happen if you changed the format tweaks to " |
| 933 |
"contain MMMM. In this case, instead of using something like " |
| 934 |
"``{pubdate:format_date(yyyy)}``, write the template using template program " |
| 935 |
"mode as in ``{:'format_date(raw_field('pubdate'),'yyyy')'}``." |
| 936 |
msgstr "" |
| 937 |
|
| 938 |
# e5841227836f46efa1cf433d619fa58a |
| 939 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:282 |
| 940 |
msgid "" |
| 941 |
"finish_formatting(val, fmt, prefix, suffix) -- apply the format, prefix, and" |
| 942 |
" suffix to a value in the same way as done in a template like " |
| 943 |
"``{series_index:05.2f| - |- }``. This function is provided to ease " |
| 944 |
"conversion of complex single-function- or template-program-mode templates to" |
| 945 |
" :ref:`general program mode <general_mode>` (see below) to take advantage of" |
| 946 |
" GPM template compilation. For example, the following program produces the " |
| 947 |
"same output as the above template::" |
| 948 |
msgstr "" |
| 949 |
|
| 950 |
# 6edf168dff0748aea10ec34cec96c462 |
| 951 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:286 |
| 952 |
msgid "" |
| 953 |
"Another example: for the template " |
| 954 |
"``{series:re(([^\\s])[^\\s]+(\\s|$),\\1)}{series_index:0>2s| - | - " |
| 955 |
"}{title}`` use::" |
| 956 |
msgstr "" |
| 957 |
|
| 958 |
# 2992e2f604844d3e93f11f8cd5d3804f |
| 959 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:295 |
| 960 |
msgid "" |
| 961 |
"``formats_modtimes(date_format)`` -- return a comma-separated list of " |
| 962 |
"colon_separated items representing modification times for the formats of a " |
| 963 |
"book. The date_format parameter specifies how the date is to be formatted. " |
| 964 |
"See the date_format function for details. You can use the select function to" |
| 965 |
" get the mod time for a specific format. Note that format names are always " |
| 966 |
"uppercase, as in EPUB." |
| 967 |
msgstr "" |
| 968 |
|
| 969 |
# 83422bad6c714731911545574486671d |
| 970 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:296 |
| 971 |
msgid "" |
| 972 |
"``formats_paths()`` -- return a comma-separated list of colon_separated " |
| 973 |
"items representing full path to the formats of a book. You can use the " |
| 974 |
"select function to get the path for a specific format. Note that format " |
| 975 |
"names are always uppercase, as in EPUB." |
| 976 |
msgstr "" |
| 977 |
|
| 978 |
# fafb57bcd2744a03a19694b9a63e74a8 |
| 979 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:297 |
| 980 |
msgid "" |
| 981 |
"``formats_sizes()`` -- return a comma-separated list of colon_separated " |
| 982 |
"items representing sizes in bytes of the formats of a book. You can use the " |
| 983 |
"select function to get the size for a specific format. Note that format " |
| 984 |
"names are always uppercase, as in EPUB." |
| 985 |
msgstr "" |
| 986 |
|
| 987 |
# 7be3159f001f4a95b5fa54782da55456 |
| 988 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:298 |
| 989 |
msgid "" |
| 990 |
"``has_cover()`` -- return ``Yes`` if the book has a cover, otherwise return " |
| 991 |
"the empty string" |
| 992 |
msgstr "" |
| 993 |
|
| 994 |
# ddccfe235533427a80398161ad863e36 |
| 995 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:299 |
| 996 |
msgid "" |
| 997 |
"``not(value)`` -- returns the string \"1\" if the value is empty, otherwise " |
| 998 |
"returns the empty string. This function works well with test or " |
| 999 |
"first_non_empty. You can have as many values as you want." |
| 1000 |
msgstr "" |
| 1001 |
|
| 1002 |
# d1177b3ca6044468a64ffc51d510e751 |
| 1003 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:300 |
| 1004 |
msgid "" |
| 1005 |
"``list_difference(list1, list2, separator)`` -- return a list made by " |
| 1006 |
"removing from `list1` any item found in `list2`, using a case-insensitive " |
| 1007 |
"compare. The items in `list1` and `list2` are separated by separator, as are" |
| 1008 |
" the items in the returned list." |
| 1009 |
msgstr "" |
| 1010 |
|
| 1011 |
# e26306a788a1431e8ab4e50891d8a523 |
| 1012 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:301 |
| 1013 |
msgid "" |
| 1014 |
"``list_equals(list1, sep1, list2, sep2, yes_val, no_val)`` -- return " |
| 1015 |
"`yes_val` if `list1` and `list2` contain the same items, otherwise return " |
| 1016 |
"`no_val`. The items are determined by splitting each list using the " |
| 1017 |
"appropriate separator character (`sep1` or `sep2`). The order of items in " |
| 1018 |
"the lists is not relevant. The compare is case insensitive." |
| 1019 |
msgstr "" |
| 1020 |
|
| 1021 |
# b847d714a51e4d988629fc038e1d0e7e |
| 1022 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:302 |
| 1023 |
msgid "" |
| 1024 |
"``list_intersection(list1, list2, separator)`` -- return a list made by " |
| 1025 |
"removing from `list1` any item not found in `list2`, using a case-" |
| 1026 |
"insensitive compare. The items in `list1` and `list2` are separated by " |
| 1027 |
"separator, as are the items in the returned list." |
| 1028 |
msgstr "" |
| 1029 |
|
| 1030 |
# cc1c17f938de480ab61c0c1e065b8ae2 |
| 1031 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:303 |
| 1032 |
msgid "" |
| 1033 |
"``list_re(src_list, separator, include_re, opt_replace)`` -- Construct a " |
| 1034 |
"list by first separating `src_list` into items using the `separator` " |
| 1035 |
"character. For each item in the list, check if it matches `include_re`. If " |
| 1036 |
"it does, then add it to the list to be returned. If `opt_replace` is not the" |
| 1037 |
" empty string, then apply the replacement before adding the item to the " |
| 1038 |
"returned list." |
| 1039 |
msgstr "" |
| 1040 |
|
| 1041 |
# 1345444f81694cada8d7b1db18dcf759 |
| 1042 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:304 |
| 1043 |
msgid "" |
| 1044 |
"``list_re_group(src_list, separator, include_re, search_re, " |
| 1045 |
"template_for_group_1, for_group_2, ...)`` -- Like list_re except " |
| 1046 |
"replacements are not optional. It uses re_group(item, search_re, template " |
| 1047 |
"...) when doing the replacements." |
| 1048 |
msgstr "" |
| 1049 |
|
| 1050 |
# f897aef348d24d65ba2f5afc051eea53 |
| 1051 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:305 |
| 1052 |
msgid "" |
| 1053 |
"``list_sort(list, direction, separator)`` -- return list sorted using a " |
| 1054 |
"case-insensitive sort. If `direction` is zero, the list is sorted ascending," |
| 1055 |
" otherwise descending. The list items are separated by separator, as are the" |
| 1056 |
" items in the returned list." |
| 1057 |
msgstr "" |
| 1058 |
|
| 1059 |
# 8dec658a16fe46449bc5957709f0c05f |
| 1060 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:306 |
| 1061 |
msgid "" |
| 1062 |
"``list_union(list1, list2, separator)`` -- return a list made by merging the" |
| 1063 |
" items in list1 and list2, removing duplicate items using a case-insensitive" |
| 1064 |
" compare. If items differ in case, the one in list1 is used. The items in " |
| 1065 |
"list1 and list2 are separated by separator, as are the items in the returned" |
| 1066 |
" list." |
| 1067 |
msgstr "" |
| 1068 |
|
| 1069 |
# bf2dd363e49b48af9eb7b2257548317a |
| 1070 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:307 |
| 1071 |
msgid "" |
| 1072 |
"``multiply(x, y)`` -- returns x * y. Throws an exception if either x or y " |
| 1073 |
"are not numbers." |
| 1074 |
msgstr "" |
| 1075 |
|
| 1076 |
# 42d22f65bbb94f5d85973cf1d75e9f02 |
| 1077 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:308 |
| 1078 |
msgid "" |
| 1079 |
"``ondevice()`` -- return the string \"Yes\" if ondevice is set, otherwise " |
| 1080 |
"return the empty string" |
| 1081 |
msgstr "" |
| 1082 |
|
| 1083 |
# a25dd2f1f7c6476a8ef341adfd4fb55c |
| 1084 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:309 |
| 1085 |
msgid "" |
| 1086 |
"``or(value, value, ...)`` -- returns the string \"1\" if any value is not " |
| 1087 |
"empty, otherwise returns the empty string. This function works well with " |
| 1088 |
"test or first_non_empty. You can have as many values as you want." |
| 1089 |
msgstr "" |
| 1090 |
|
| 1091 |
# 118cfca7b929402399aa73835208f1eb |
| 1092 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:310 |
| 1093 |
msgid "" |
| 1094 |
"``print(a, b, ...)`` -- prints the arguments to standard output. Unless you " |
| 1095 |
"start calibre from the command line (``calibre-debug -g``), the output will " |
| 1096 |
"go to a black hole." |
| 1097 |
msgstr "" |
| 1098 |
|
| 1099 |
# a604978dcc6f4a0d97f7d777c372dc19 |
| 1100 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:311 |
| 1101 |
msgid "" |
| 1102 |
"``raw_field(name)`` -- returns the metadata field named by name without " |
| 1103 |
"applying any formatting." |
| 1104 |
msgstr "" |
| 1105 |
|
| 1106 |
# 5d133094853f4eaea2bb80931b3de5aa |
| 1107 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:312 |
| 1108 |
msgid "" |
| 1109 |
"``raw_list(name, separator)`` -- returns the metadata list named by name " |
| 1110 |
"without applying any formatting or sorting and with items separated by " |
| 1111 |
"separator." |
| 1112 |
msgstr "" |
| 1113 |
|
| 1114 |
# 21df9bc1f7e24cbbad3f949dcbbe7abe |
| 1115 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:313 |
| 1116 |
msgid "" |
| 1117 |
"``re_group(val, pattern, template_for_group_1, for_group_2, ...)`` -- " |
| 1118 |
"return a string made by applying the reqular expression pattern to the val " |
| 1119 |
"and replacing each matched instance with the string computed by replacing " |
| 1120 |
"each matched group by the value returned by the corresponding template. The " |
| 1121 |
"original matched value for the group is available as $. In template program " |
| 1122 |
"mode, like for the template and the eval functions, you use [[ for { and ]] " |
| 1123 |
"for }. The following example in template program mode looks for series with " |
| 1124 |
"more than one word and uppercases the first word::" |
| 1125 |
msgstr "" |
| 1126 |
|
| 1127 |
# 9cca8fda1d414f56aacdefd64728330b |
| 1128 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:317 |
| 1129 |
msgid "``series_sort()`` -- returns the series sort value." |
| 1130 |
msgstr "" |
| 1131 |
|
| 1132 |
# 6c0177f3ed11431fb22a3816729cbcee |
| 1133 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:318 |
| 1134 |
msgid "" |
| 1135 |
"``strcat(a, b, ...)`` -- can take any number of arguments. Returns a string " |
| 1136 |
"formed by concatenating all the arguments." |
| 1137 |
msgstr "" |
| 1138 |
|
| 1139 |
# 0328af7dad1d49e181e95c71c24a6944 |
| 1140 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:319 |
| 1141 |
msgid "" |
| 1142 |
"``strcat_max(max, string1, prefix2, string2, ...)`` -- Returns a string " |
| 1143 |
"formed by concatenating the arguments. The returned value is initialized to " |
| 1144 |
"string1. `Prefix, string` pairs are added to the end of the value as long as" |
| 1145 |
" the resulting string length is less than `max`. String1 is returned even if" |
| 1146 |
" string1 is longer than max. You can pass as many `prefix, string` pairs as " |
| 1147 |
"you wish." |
| 1148 |
msgstr "" |
| 1149 |
|
| 1150 |
# 0c4b4c26e20748719eff4ba82e50d2dd |
| 1151 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:320 |
| 1152 |
msgid "" |
| 1153 |
"``strcmp(x, y, lt, eq, gt)`` -- does a case-insensitive comparison x and y " |
| 1154 |
"as strings. Returns ``lt`` if x < y. Returns ``eq`` if x == y. Otherwise " |
| 1155 |
"returns ``gt``." |
| 1156 |
msgstr "" |
| 1157 |
|
| 1158 |
# 85a3f2f685ee49dfb93b5e6897ee6d45 |
| 1159 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:321 |
| 1160 |
msgid "" |
| 1161 |
"``strlen(a)`` -- Returns the length of the string passed as the argument." |
| 1162 |
msgstr "" |
| 1163 |
|
| 1164 |
# e7b045b75bec43f8be357dc75f088d80 |
| 1165 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:322 |
| 1166 |
msgid "" |
| 1167 |
"``substr(str, start, end)`` -- returns the ``start``'th through the " |
| 1168 |
"``end``'th characters of ``str``. The first character in ``str`` is the " |
| 1169 |
"zero'th character. If end is negative, then it indicates that many " |
| 1170 |
"characters counting from the right. If end is zero, then it indicates the " |
| 1171 |
"last character. For example, ``substr('12345', 1, 0)`` returns ``'2345'``, " |
| 1172 |
"and ``substr('12345', 1, -1)`` returns ``'234'``." |
| 1173 |
msgstr "" |
| 1174 |
|
| 1175 |
# dd607d60661f4bf987f1f17e2364fe90 |
| 1176 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:323 |
| 1177 |
msgid "" |
| 1178 |
"``subtract(x, y)`` -- returns x - y. Throws an exception if either x or y " |
| 1179 |
"are not numbers." |
| 1180 |
msgstr "" |
| 1181 |
|
| 1182 |
# 675cbc4c2f504359a2c0c810821b2902 |
| 1183 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:324 |
| 1184 |
msgid "" |
| 1185 |
"``today()`` -- return a date string for today. This value is designed for " |
| 1186 |
"use in format_date or days_between, but can be manipulated like any other " |
| 1187 |
"string. The date is in ISO format." |
| 1188 |
msgstr "" |
| 1189 |
|
| 1190 |
# c241ccb436e741b2bf6443ab8af0f66c |
| 1191 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:325 |
| 1192 |
msgid "" |
| 1193 |
"``template(x)`` -- evaluates x as a template. The evaluation is done in its " |
| 1194 |
"own context, meaning that variables are not shared between the caller and " |
| 1195 |
"the template evaluation. Because the `{` and `}` characters are special, you" |
| 1196 |
" must use `[[` for the `{` character and `]]` for the '}' character; they " |
| 1197 |
"are converted automatically. For example, ``template('[[title_sort]]') will " |
| 1198 |
"evaluate the template ``{title_sort}`` and return its value. Note also that " |
| 1199 |
"prefixes and suffixes (the `|prefix|suffix` syntax) cannot be used in the " |
| 1200 |
"argument to this function when using template program mode." |
| 1201 |
msgstr "" |
| 1202 |
|
| 1203 |
# 5bc08b05cf4f42fd934e6e267c45ab0b |
| 1204 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:330 |
| 1205 |
msgid "Function classification" |
| 1206 |
msgstr "" |
| 1207 |
|
| 1208 |
# 4217f8bf6faf44358230cb8049e7da60 |
| 1209 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:341 |
| 1210 |
msgid "Using general program mode" |
| 1211 |
msgstr "" |
| 1212 |
|
| 1213 |
# 5d36c407151e42d08aeeaf8cffda1df8 |
| 1214 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:343 |
| 1215 |
msgid "" |
| 1216 |
"For more complicated template programs, it is sometimes easier to avoid " |
| 1217 |
"template syntax (all the `{` and `}` characters), instead writing a more " |
| 1218 |
"classical-looking program. You can do this in calibre by beginning the " |
| 1219 |
"template with `program:`. In this case, no template processing is done. The " |
| 1220 |
"special variable `$` is not set. It is up to your program to produce the " |
| 1221 |
"correct results." |
| 1222 |
msgstr "" |
| 1223 |
|
| 1224 |
# e2e4f920ff5149b9955467e25684a3c5 |
| 1225 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:345 |
| 1226 |
msgid "" |
| 1227 |
"One advantage of `program:` mode is that the brackets are no longer special." |
| 1228 |
" For example, it is not necessary to use `[[` and `]]` when using the " |
| 1229 |
"`template()` function. Another advantage is that program mode templates are " |
| 1230 |
"compiled to Python and can run much faster than templates in the other two " |
| 1231 |
"modes. Speed improvement depends on the complexity of the templates; the " |
| 1232 |
"more complicated the template the more the improvement. Compilation is " |
| 1233 |
"turned off or on using the tweak ``compile_gpm_templates`` (Compile General " |
| 1234 |
"Program Mode templates to Python). The main reason to turn off compilation " |
| 1235 |
"is if a compiled template does not work, in which case please file a bug " |
| 1236 |
"report." |
| 1237 |
msgstr "" |
| 1238 |
|
| 1239 |
# 191c9fd8a6f1402eba1ee4661a040d31 |
| 1240 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:347 |
| 1241 |
msgid "" |
| 1242 |
"The following example is a `program:` mode implementation of a recipe on the" |
| 1243 |
" MobileRead forum: \"Put series into the title, using either initials or a " |
| 1244 |
"shortened form. Strip leading articles from the series name (any).\" For " |
| 1245 |
"example, for the book The Two Towers in the Lord of the Rings series, the " |
| 1246 |
"recipe gives `LotR [02] The Two Towers`. Using standard templates, the " |
| 1247 |
"recipe requires three custom columns and a plugboard, as explained in the " |
| 1248 |
"following:" |
| 1249 |
msgstr "" |
| 1250 |
|
| 1251 |
# 1861a2e62ead44f3b6ea92ddfd282f6b |
| 1252 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:349 |
| 1253 |
msgid "" |
| 1254 |
"The solution requires creating three composite columns. The first column is " |
| 1255 |
"used to remove the leading articles. The second is used to compute the " |
| 1256 |
"'shorten' form. The third is to compute the 'initials' form. Once you have " |
| 1257 |
"these columns, the plugboard selects between them. You can hide any or all " |
| 1258 |
"of the three columns on the library view." |
| 1259 |
msgstr "" |
| 1260 |
|
| 1261 |
# 65d99854f63044908a54b0e6b08a2bee |
| 1262 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:351 |
| 1263 |
msgid "" |
| 1264 |
"First column: Name: #stripped_series. Template: " |
| 1265 |
"{series:re(^(A|The|An)\\s+,)||}" |
| 1266 |
msgstr "" |
| 1267 |
|
| 1268 |
# 52f74bc1dffb46c18ac4a98fc869152d |
| 1269 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:355 |
| 1270 |
msgid "" |
| 1271 |
"Second column (the shortened form): Name: #shortened. Template: " |
| 1272 |
"{#stripped_series:shorten(4,-,4)}" |
| 1273 |
msgstr "" |
| 1274 |
|
| 1275 |
# 7748a878c399456093664e763777ecfb |
| 1276 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:359 |
| 1277 |
msgid "" |
| 1278 |
"Third column (the initials form): Name: #initials. Template: " |
| 1279 |
"{#stripped_series:re(([^\\s])[^\\s]+(\\s|$),\\1)}" |
| 1280 |
msgstr "" |
| 1281 |
|
| 1282 |
# 959644bdea214ff38775ee7716e42cf8 |
| 1283 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:363 |
| 1284 |
msgid "" |
| 1285 |
"Plugboard expression: " |
| 1286 |
"Template:{#stripped_series:lookup(.\\s,#initials,.,#shortened,series)}{series_index:0>2.0f|" |
| 1287 |
" [|] }{title} Destination field: title" |
| 1288 |
msgstr "" |
| 1289 |
|
| 1290 |
# 32b870999c8546a9a8074ceee8337ae5 |
| 1291 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:367 |
| 1292 |
msgid "" |
| 1293 |
"This set of fields and plugboard produces: Series: The Lord of the Rings " |
| 1294 |
"Series index: 2 Title: The Two Towers Output: LotR [02] The Two Towers" |
| 1295 |
msgstr "" |
| 1296 |
|
| 1297 |
# 5dea81b11b5045adb60945e108ea0418 |
| 1298 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:373 |
| 1299 |
msgid "" |
| 1300 |
"Series: Dahak Series index: 1 Title: Mutineers Moon Output: Dahak [01] " |
| 1301 |
"Mutineers Moon" |
| 1302 |
msgstr "" |
| 1303 |
|
| 1304 |
# 7192ee03b2774f48ba7b145ae7a3f363 |
| 1305 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:378 |
| 1306 |
msgid "" |
| 1307 |
"Series: Berserkers Series Index: 4 Title: Berserker Throne Output: Bers-kers" |
| 1308 |
" [04] Berserker Throne" |
| 1309 |
msgstr "" |
| 1310 |
|
| 1311 |
# e4fa70b12a0e43c5950b734eea8787da |
| 1312 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:383 |
| 1313 |
msgid "" |
| 1314 |
"Series: Meg Langslow Mysteries Series Index: 3 Title: Revenge of the " |
| 1315 |
"Wrought-Iron Flamingos Output: MLM [03] Revenge of the Wrought-Iron " |
| 1316 |
"Flamingos" |
| 1317 |
msgstr "" |
| 1318 |
|
| 1319 |
# c86024c6843c48d3871f952933408900 |
| 1320 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:388 |
| 1321 |
msgid "" |
| 1322 |
"The following program produces the same results as the original recipe, " |
| 1323 |
"using only one custom column to hold the results of a program that computes " |
| 1324 |
"the special title value::" |
| 1325 |
msgstr "" |
| 1326 |
|
| 1327 |
# bdbec8dfdfa74ff9ba9d4ea8a1b5bd34 |
| 1328 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:425 |
| 1329 |
msgid "" |
| 1330 |
"It would be possible to do the above with no custom columns by putting the " |
| 1331 |
"program into the template box of the plugboard. However, to do so, all " |
| 1332 |
"comments must be removed because the plugboard text box does not support " |
| 1333 |
"multi-line editing. It is debatable whether the gain of not having the " |
| 1334 |
"custom column is worth the vast increase in difficulty caused by the program" |
| 1335 |
" being one giant line." |
| 1336 |
msgstr "" |
| 1337 |
|
| 1338 |
# 753e88d6630b4e1b9ee7ed05c50a5d49 |
| 1339 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:429 |
| 1340 |
msgid "User-defined Template Functions" |
| 1341 |
msgstr "" |
| 1342 |
|
| 1343 |
# c97b77a3d2ee486d94c491064e0b2ca8 |
| 1344 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:431 |
| 1345 |
msgid "" |
| 1346 |
"You can add your own functions to the template processor. Such functions are" |
| 1347 |
" written in python, and can be used in any of the three template programming" |
| 1348 |
" modes. The functions are added by going to Preferences -> Advanced -> " |
| 1349 |
"Template Functions. Instructions are shown in that dialog." |
| 1350 |
msgstr "" |
| 1351 |
|
| 1352 |
# 776ce8335963475d99a89ed8613990ac |
| 1353 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:434 |
| 1354 |
msgid "Special notes for save/send templates" |
| 1355 |
msgstr "" |
| 1356 |
|
| 1357 |
# 175f42a740dd45bd9eaf4f86a44d5d09 |
| 1358 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:436 |
| 1359 |
msgid "" |
| 1360 |
"Special processing is applied when a template is used in a `save to disk` or" |
| 1361 |
" `send to device` template. The values of the fields are cleaned, replacing " |
| 1362 |
"characters that are special to file systems with underscores, including " |
| 1363 |
"slashes. This means that field text cannot be used to create folders. " |
| 1364 |
"However, slashes are not changed in prefix or suffix strings, so slashes in " |
| 1365 |
"these strings will cause folders to be created. Because of this, you can " |
| 1366 |
"create variable-depth folder structure." |
| 1367 |
msgstr "" |
| 1368 |
|
| 1369 |
# e72b94b45fdb4067be3d6608eb77ab8b |
| 1370 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:438 |
| 1371 |
msgid "" |
| 1372 |
"For example, assume we want the folder structure `series/series_index - " |
| 1373 |
"title`, with the caveat that if series does not exist, then the title should" |
| 1374 |
" be in the top folder. The template to do this is::" |
| 1375 |
msgstr "" |
| 1376 |
|
| 1377 |
# 643bad39896a469cad5fd648050a317d |
| 1378 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:442 |
| 1379 |
msgid "The slash and the hyphen appear only if series is not empty." |
| 1380 |
msgstr "" |
| 1381 |
|
| 1382 |
# d539c707f68b4c048b0f6f329dcfff36 |
| 1383 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:444 |
| 1384 |
msgid "" |
| 1385 |
"The lookup function lets us do even fancier processing. For example, assume " |
| 1386 |
"that if a book has a series, then we want the folder structure " |
| 1387 |
"`series/series index - title.fmt`. If the book does not have a series, then " |
| 1388 |
"we want the folder structure `genre/author_sort/title.fmt`. If the book has " |
| 1389 |
"no genre, we want to use 'Unknown'. We want two completely different paths, " |
| 1390 |
"depending on the value of series." |
| 1391 |
msgstr "" |
| 1392 |
|
| 1393 |
# 3058cb83fc464fc38c1a0626c431d50c |
| 1394 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:449 |
| 1395 |
msgid "To accomplish this, we:" |
| 1396 |
msgstr "" |
| 1397 |
|
| 1398 |
# 60ad2e82c1a14e63b2b9f1e1163684ff |
| 1399 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:447 |
| 1400 |
msgid "" |
| 1401 |
"Create a composite field (call it AA) containing ``{series}/{series_index} -" |
| 1402 |
" {title'}``. If the series is not empty, then this template will produce " |
| 1403 |
"`series/series_index - title`." |
| 1404 |
msgstr "" |
| 1405 |
|
| 1406 |
# 2a5cea69d72947a198a5747ce9f97fc7 |
| 1407 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:448 |
| 1408 |
msgid "" |
| 1409 |
"Create a composite field (call it BB) containing " |
| 1410 |
"``{#genre:ifempty(Unknown)}/{author_sort}/{title}``. This template produces " |
| 1411 |
"`genre/author_sort/title`, where an empty genre is replaced wuth `Unknown`." |
| 1412 |
msgstr "" |
| 1413 |
|
| 1414 |
# 6350eeb3a39b4a319a52ce6a530cd342 |
| 1415 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:449 |
| 1416 |
msgid "" |
| 1417 |
"Set the save template to ``{series:lookup(.,AA,BB)}``. This template chooses" |
| 1418 |
" composite field AA if series is not empty, and composite field BB if series" |
| 1419 |
" is empty. We therefore have two completely different save paths, depending " |
| 1420 |
"on whether or not `series` is empty." |
| 1421 |
msgstr "" |
| 1422 |
|
| 1423 |
# 0e6f8ab9effe4a50be38e59dc6535566 |
| 1424 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:452 |
| 1425 |
msgid "Templates and Plugboards" |
| 1426 |
msgstr "" |
| 1427 |
|
| 1428 |
# e3d9a2f8364c4dea8bfa105a06835655 |
| 1429 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:454 |
| 1430 |
msgid "" |
| 1431 |
"Plugboards are used for changing the metadata written into books during " |
| 1432 |
"send-to-device and save-to-disk operations. A plugboard permits you to " |
| 1433 |
"specify a template to provide the data to write into the book's metadata. " |
| 1434 |
"You can use plugboards to modify the following fields: authors, author_sort," |
| 1435 |
" language, publisher, tags, title, title_sort. This feature helps people who" |
| 1436 |
" want to use different metadata in books on devices to solve sorting or " |
| 1437 |
"display issues." |
| 1438 |
msgstr "" |
| 1439 |
|
| 1440 |
# b5fddb345c5f4287b3357fac965b54bf |
| 1441 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:456 |
| 1442 |
msgid "" |
| 1443 |
"When you create a plugboard, you specify the format and device for which the" |
| 1444 |
" plugboard is to be used. A special device is provided, save_to_disk, that " |
| 1445 |
"is used when saving formats (as opposed to sending them to a device). Once " |
| 1446 |
"you have chosen the format and device, you choose the metadata fields to " |
| 1447 |
"change, providing templates to supply the new values. These templates are " |
| 1448 |
"`connected` to their destination fields, hence the name `plugboards`. You " |
| 1449 |
"can, of course, use composite columns in these templates." |
| 1450 |
msgstr "" |
| 1451 |
|
| 1452 |
# 1f5a1cdc8e05431e9952fc0fe98b8748 |
| 1453 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:458 |
| 1454 |
msgid "" |
| 1455 |
"When a plugboard might apply (content server, save to disk, or send to " |
| 1456 |
"device), calibre searches the defined plugboards to choose the correct one " |
| 1457 |
"for the given format and device. For example, to find the appropriate " |
| 1458 |
"plugboard for an EPUB book being sent to an ANDROID device, calibre searches" |
| 1459 |
" the plugboards using the following search order:" |
| 1460 |
msgstr "" |
| 1461 |
|
| 1462 |
# 2229f3f906a94ed0984b305b7771fa91 |
| 1463 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:460 |
| 1464 |
msgid "" |
| 1465 |
"a plugboard with an exact match on format and device, e.g., ``EPUB`` and " |
| 1466 |
"``ANDROID``" |
| 1467 |
msgstr "" |
| 1468 |
|
| 1469 |
# 88cd202ca1624ee791ed3e870f69cd14 |
| 1470 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:461 |
| 1471 |
msgid "" |
| 1472 |
"a plugboard with an exact match on format and the special ``any device`` " |
| 1473 |
"choice, e.g., ``EPUB`` and ``any device``" |
| 1474 |
msgstr "" |
| 1475 |
|
| 1476 |
# 4f0ffcd686644ba2b802e32d9b878c3b |
| 1477 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:462 |
| 1478 |
msgid "" |
| 1479 |
"a plugboard with the special ``any format`` choice and an exact match on " |
| 1480 |
"device, e.g., ``any format`` and ``ANDROID``" |
| 1481 |
msgstr "" |
| 1482 |
|
| 1483 |
# a08e23ca369c4a41a9e0f6b2ce70039b |
| 1484 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:463 |
| 1485 |
msgid "a plugboard with ``any format`` and ``any device``" |
| 1486 |
msgstr "" |
| 1487 |
|
| 1488 |
# 539e4eb447f640f2bf9a48137626b5d7 |
| 1489 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:465 |
| 1490 |
msgid "" |
| 1491 |
"The tags and authors fields have special treatment, because both of these " |
| 1492 |
"fields can hold more than one item. A book can have many tags and many " |
| 1493 |
"authors. When you specify that one of these two fields is to be changed, the" |
| 1494 |
" template's result is examined to see if more than one item is there. For " |
| 1495 |
"tags, the result is cut apart wherever calibre finds a comma. For example, " |
| 1496 |
"if the template produces the value ``Thriller, Horror``, then the result " |
| 1497 |
"will be two tags, ``Thriller`` and ``Horror``. There is no way to put a " |
| 1498 |
"comma in the middle of a tag." |
| 1499 |
msgstr "" |
| 1500 |
|
| 1501 |
# bbc476ec5256468a8ea37d97d6fa1619 |
| 1502 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:467 |
| 1503 |
msgid "" |
| 1504 |
"The same thing happens for authors, but using a different character for the " |
| 1505 |
"cut, a `&` (ampersand) instead of a comma. For example, if the template " |
| 1506 |
"produces the value ``Blogs, Joe&Posts, Susan``, then the book will end up " |
| 1507 |
"with two authors, ``Blogs, Joe`` and ``Posts, Susan``. If the template " |
| 1508 |
"produces the value ``Blogs, Joe;Posts, Susan``, then the book will have one " |
| 1509 |
"author with a rather strange name." |
| 1510 |
msgstr "" |
| 1511 |
|
| 1512 |
# 3d7242eb4b12401d9ab5a5e41c599a7d |
| 1513 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:469 |
| 1514 |
msgid "" |
| 1515 |
"Plugboards affect the metadata written into the book when it is saved to " |
| 1516 |
"disk or written to the device. Plugboards do not affect the metadata used by" |
| 1517 |
" ``save to disk`` and ``send to device`` to create the file names. Instead, " |
| 1518 |
"file names are constructed using the templates entered on the appropriate " |
| 1519 |
"preferences window." |
| 1520 |
msgstr "" |
| 1521 |
|
| 1522 |
# bcc09bfd55de42b7967e92ee99684146 |
| 1523 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:472 |
| 1524 |
msgid "Helpful Tips" |
| 1525 |
msgstr "" |
| 1526 |
|
| 1527 |
# 6664d9811aa743a18eb25615b7286612 |
| 1528 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:474 |
| 1529 |
msgid "You might find the following tips useful." |
| 1530 |
msgstr "" |
| 1531 |
|
| 1532 |
# 9073dbe6c500418cb5f0a50001c90fba |
| 1533 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:476 |
| 1534 |
msgid "" |
| 1535 |
"Create a custom composite column to test templates. Once you have the " |
| 1536 |
"column, you can change its template simply by double-clicking on the column." |
| 1537 |
" Hide the column when you are not testing." |
| 1538 |
msgstr "" |
| 1539 |
|
| 1540 |
# 1aa0018f5feb49bdb5ab44d97cda4773 |
| 1541 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:477 |
| 1542 |
msgid "" |
| 1543 |
"Templates can use other templates by referencing a composite custom column." |
| 1544 |
msgstr "" |
| 1545 |
|
| 1546 |
# 3cd440ffdda341a3be657608f4d989e0 |
| 1547 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:478 |
| 1548 |
msgid "" |
| 1549 |
"In a plugboard, you can set a field to empty (or whatever is equivalent to " |
| 1550 |
"empty) by using the special template ``{}``. This template will always " |
| 1551 |
"evaluate to an empty string." |
| 1552 |
msgstr "" |
| 1553 |
|
| 1554 |
# af88f0cfff5e4d0ca15e07fb187fbb5b |
| 1555 |
#: ../../home/kovid/work/calibre/manual/template_lang.rst:479 |
| 1556 |
msgid "" |
| 1557 |
"The technique described above to show numbers even if they have a zero value" |
| 1558 |
" works with the standard field series_index." |
| 1559 |
msgstr "" |