| 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 |
# Kevin Jin <[email protected]>, 2016 |
| 7 |
# Pler Li, 2024 |
| 8 |
# RERBIN MA, 2025-2026 |
| 9 |
# tony shen <[email protected]>, 2024 |
| 10 |
# MewX <[email protected]>, 2016 |
| 11 |
msgid "" |
| 12 |
msgstr "" |
| 13 |
"Project-Id-Version: calibre\n" |
| 14 |
"Report-Msgid-Bugs-To: \n" |
| 15 |
"POT-Creation-Date: 2026-02-25 10:21+0000\n" |
| 16 |
"PO-Revision-Date: 2014-06-17 08:34+0000\n" |
| 17 |
"Last-Translator: RERBIN MA, 2025-2026\n" |
| 18 |
"Language-Team: Chinese (China) (http://app.transifex.com/calibre/calibre/language/zh_CN/)\n" |
| 19 |
"MIME-Version: 1.0\n" |
| 20 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 21 |
"Content-Transfer-Encoding: 8bit\n" |
| 22 |
"Language: zh_CN\n" |
| 23 |
"Plural-Forms: nplurals=1; plural=0;\n" |
| 24 |
|
| 25 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:4 |
| 26 |
msgid "The calibre template language" |
| 27 |
msgstr "calibre 模板语言" |
| 28 |
|
| 29 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:6 |
| 30 |
msgid "" |
| 31 |
"The calibre template language is a calibre-specific language used throughout" |
| 32 |
" calibre for tasks such as specifying file paths, formatting values, and " |
| 33 |
"computing the value for user-specified columns. Examples:" |
| 34 |
msgstr "calibre模板语言是calibre特定的语言,用于在calibre中执行任务,例如指定文件路径、格式化值和计算用户指定列的值。示例:" |
| 35 |
|
| 36 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:8 |
| 37 |
msgid "" |
| 38 |
"Specify the folder structure and file names when saving files from the " |
| 39 |
"calibre library to the disk or e-book reader." |
| 40 |
msgstr "在将文件从calibre书库保存到磁盘或电子书阅读器时,指定文件夹结构和文件名。" |
| 41 |
|
| 42 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:9 |
| 43 |
msgid "Define rules for adding icons and colors to the calibre book list." |
| 44 |
msgstr "定义规则以将图标和颜色添加到calibre图书列表中。" |
| 45 |
|
| 46 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:10 |
| 47 |
msgid "Define `virtual columns` that contain data from other columns." |
| 48 |
msgstr "定义包含来自其他列的数据的“虚拟列”。" |
| 49 |
|
| 50 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:11 |
| 51 |
msgid "Advanced library searching." |
| 52 |
msgstr "高级书库搜索。" |
| 53 |
|
| 54 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:12 |
| 55 |
msgid "Advanced metadata search and replace." |
| 56 |
msgstr "高级元数据搜索和替换。" |
| 57 |
|
| 58 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:14 |
| 59 |
msgid "" |
| 60 |
"The language is built around the notion of a `template`, which specifies " |
| 61 |
"which book metadata to use, computations on that metadata, and how it is to " |
| 62 |
"be formatted." |
| 63 |
msgstr "该语言是围绕“模板”的概念构建的,它指定要使用的图书元数据、元数据的计算以及如何格式化。" |
| 64 |
|
| 65 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:17 |
| 66 |
msgid "Basic templates" |
| 67 |
msgstr "基本模板" |
| 68 |
|
| 69 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:19 |
| 70 |
msgid "" |
| 71 |
"A basic template consists of one or more ``template expressions``. A " |
| 72 |
"``template expression`` consists of text and names in curly brackets " |
| 73 |
"(``{}``) that is replaced by the corresponding metadata from the book being " |
| 74 |
"processed. For example, the default template in calibre used for saving " |
| 75 |
"books to device has 4 ``template expressions``::" |
| 76 |
msgstr "基本模板由一个或多个“模板表达式”组成。一个“模板表达式”包含文本以及花括号({})中的名称。在处理书籍时,花括号中的内容会被替换为对应的书籍元数据。例如,Calibre 中用于将书籍保存到设备的默认模板包含 4 个“模板表达式”::" |
| 77 |
|
| 78 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:23 |
| 79 |
msgid "For the book \"The Foundation\" by \"Isaac Asimov\" the template will become::" |
| 80 |
msgstr "对于 \"Isaac Asimov\"的作品 \"The Foundation\" ,该模板将变为::" |
| 81 |
|
| 82 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:27 |
| 83 |
msgid "" |
| 84 |
"The slashes are not ``template expressions`` because they are not in between" |
| 85 |
" ``{}``. Such text is left where it appears. For example, if the template " |
| 86 |
"is::" |
| 87 |
msgstr "斜杠并非``模板表达式``,因为它们不在 ``{}``之间。此类文本将保留在原处。例如,如果模板为::" |
| 88 |
|
| 89 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:31 |
| 90 |
msgid "then for \"The Foundation\" the template produces::" |
| 91 |
msgstr "那么对于“The Foundation”,模板会生成:" |
| 92 |
|
| 93 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:35 |
| 94 |
msgid "" |
| 95 |
"A ``template expression`` can access all the metadata available in calibre, " |
| 96 |
"including custom columns (columns you create yourself), by using a column's " |
| 97 |
"``lookup name``. To find the lookup name for a `column` (sometimes called " |
| 98 |
"`fields`), hover your mouse over the column header in calibre's book list. " |
| 99 |
"Lookup names for custom columns always begin with ``#``. For series type " |
| 100 |
"columns there is an additional field named ``#lookup name_index`` that is " |
| 101 |
"the series index for that book in the series. For example, if you have a " |
| 102 |
"custom series column named ``#myseries``, there will also be a column named " |
| 103 |
"``#myseries_index``. The standard series column's index is named " |
| 104 |
"``series_index``." |
| 105 |
msgstr "“模板表达式”可以通过使用列的“查找名称”来访问 calibre 中可用的所有元数据,包括自定义列(您自己创建的列)。 要查找“列”(有时称为“字段”)的查找名称,请将鼠标悬停在 calibre 图书列表中的列标题上。 自定义列的查找名称始终以“#”开头。 对于系列类型列,有一个名为“#lookup name_index”的附加字段,它是该系列中该书的系列索引。 例如,如果您有一个名为“#myseries”的自定义系列列,那么还将有一个名为“#myseries_index”的列。 标准系列列的索引名为“series_index”。" |
| 106 |
|
| 107 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:37 |
| 108 |
msgid "In addition to the standard column based fields, you also can use:" |
| 109 |
msgstr "除了基于标准列的字段之外,您还可以使用:" |
| 110 |
|
| 111 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:39 |
| 112 |
msgid "" |
| 113 |
"``{formats}`` - A list of formats available in the calibre library for a " |
| 114 |
"book" |
| 115 |
msgstr "``{formats}`` - calibre 书库中书籍可用的格式列表" |
| 116 |
|
| 117 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:40 |
| 118 |
msgid "``{identifiers:select(isbn)}`` - The ISBN of the book" |
| 119 |
msgstr "``{identifiers:select(isbn)}`` - 书籍的 ISBN" |
| 120 |
|
| 121 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:42 |
| 122 |
msgid "" |
| 123 |
"If the metadata for the field for a given book is not defined then the field" |
| 124 |
" in the template is replaced by the empty string (``''``). For example, " |
| 125 |
"consider the following template::" |
| 126 |
msgstr "如果某本书的字段元数据未定义,则模板中的该字段将被替换为空字符串(“'''”)。例如,请考虑以下模板:" |
| 127 |
|
| 128 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:46 |
| 129 |
msgid "" |
| 130 |
"If Asimov's book \"Second Foundation\" is in the series \"Foundation\" then " |
| 131 |
"the template produces::" |
| 132 |
msgstr "如果Asimov的书《Second Foundation》属于《Foundation》丛书,那么模板将生成:" |
| 133 |
|
| 134 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:50 |
| 135 |
msgid "" |
| 136 |
"If a series has not been entered for the book then the template produces::" |
| 137 |
msgstr "如果尚未输入该书的丛书,则模板将生成:" |
| 138 |
|
| 139 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:54 |
| 140 |
msgid "" |
| 141 |
"The template processor automatically removes multiple slashes and leading or" |
| 142 |
" trailing spaces." |
| 143 |
msgstr "模板处理器会自动去除多余的斜杠以及开头和结尾的空格。" |
| 144 |
|
| 145 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:57 |
| 146 |
msgid "Advanced formatting" |
| 147 |
msgstr "高级格式" |
| 148 |
|
| 149 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:59 |
| 150 |
msgid "" |
| 151 |
"In addition to metadata substitution, templates can conditionally include " |
| 152 |
"additional text and control how substituted data is formatted." |
| 153 |
msgstr "除了元数据替换之外,模板还可以有条件地包含附加文本,并控制替换数据的格式。" |
| 154 |
|
| 155 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:61 |
| 156 |
msgid "**Conditionally including text**" |
| 157 |
msgstr "**有条件地包含文本**" |
| 158 |
|
| 159 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:63 |
| 160 |
msgid "" |
| 161 |
"Sometimes you want text to appear in the output only if a field is not " |
| 162 |
"empty. A common case is ``series`` and ``series_index`` where you want " |
| 163 |
"either nothing or the two values separated by a hyphen. calibre handles this" |
| 164 |
" case using a special ``template expression`` syntax." |
| 165 |
msgstr "有时,您希望仅当字段不为空时文本才出现在输出中。 常见的情况是“series”和“series_index”,其中您不需要任何内容或用连字符分隔两个值。 calibre 使用特殊的“模板表达式”语法来处理这种情况。" |
| 166 |
|
| 167 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:65 |
| 168 |
msgid "" |
| 169 |
"For example and using the above Foundation example, assume you want the " |
| 170 |
"template to produce `Foundation - 3 - Second Foundation`. This template " |
| 171 |
"produces that output:" |
| 172 |
msgstr "例如,使用上面的 Foundation 示例,假设您希望模板生成“Foundation - 3 - Second Foundation”。此模板将生成以下输出:" |
| 173 |
|
| 174 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:67 |
| 175 |
msgid "``{series} - {series_index} - {title}``" |
| 176 |
msgstr "``{series} - {series_index} - {title}``" |
| 177 |
|
| 178 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:69 |
| 179 |
msgid "" |
| 180 |
"However, if a book has no series the template will produce `- - the title`, " |
| 181 |
"which is probably not what you want. Generally, people want the result be " |
| 182 |
"the title without the extraneous hyphens. You can accomplish this using the " |
| 183 |
"following template syntax:" |
| 184 |
msgstr "但是,如果一本书没有系列,模板将生成“- - 标题”,这可能不是您想要的。 一般来说,人们希望结果是没有无关连字符的标题。 您可以使用以下模板语法来完成此操作:" |
| 185 |
|
| 186 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:71 |
| 187 |
msgid "``{field:|prefix_text|suffix_text}``" |
| 188 |
msgstr "``{field:|prefix_text|suffix_text}``" |
| 189 |
|
| 190 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:73 |
| 191 |
msgid "" |
| 192 |
"This ``template expression`` says that if ``field`` has the value `XXXX` " |
| 193 |
"then the result will be `prefix_textXXXXXsuffix_text`. If ``field`` is empty" |
| 194 |
" (has no value) then the result will be the empty string (nothing) because " |
| 195 |
"the prefix and suffix are ignored. The prefix and suffix can contain blanks." |
| 196 |
msgstr "这个“模板表达式”表示,如果“field”的值为“XXXX”,那么结果将为“prefix_textXXXXXsuffix_text”。 如果“field”为空(没有值),那么结果将是空字符串(什么也没有),因为前缀和后缀被忽略。 前缀和后缀可以包含空格。" |
| 197 |
|
| 198 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:75 |
| 199 |
msgid "" |
| 200 |
"**Do not use subtemplates (`{ ... }`) or functions (see below) in the prefix" |
| 201 |
" or the suffix.**" |
| 202 |
msgstr "**不要在“前缀”(prefix)或“后缀”(suffix)中使用子模板(`{ ... }`)或函数(见下文)。**" |
| 203 |
|
| 204 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:77 |
| 205 |
msgid "" |
| 206 |
"Using this syntax, we can solve the above no-series problem with the " |
| 207 |
"template::" |
| 208 |
msgstr "使用这种语法,我们可以通过以下模板来解决上述提到的“无丛书名”问题::" |
| 209 |
|
| 210 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:81 |
| 211 |
msgid "" |
| 212 |
"The hyphens will be included only if the book has a series index, which it " |
| 213 |
"has only if it has a series. Continuing the Foundation example again, the " |
| 214 |
"template will produce `Foundation - 1 - Second Foundation`." |
| 215 |
msgstr "仅当该书具有系列索引时才会包含连字符,而该索引仅当它具有系列时才包含。 再次继续 Foundation 示例,模板将生成“Foundation - 1 - Second Foundation”。" |
| 216 |
|
| 217 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:83 |
| 218 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:293 |
| 219 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:469 |
| 220 |
msgid "Notes:" |
| 221 |
msgstr "注意:" |
| 222 |
|
| 223 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:85 |
| 224 |
msgid "" |
| 225 |
"You must include the colon after the ``lookup name`` if you are using a " |
| 226 |
"prefix or a suffix." |
| 227 |
msgstr "如果使用前缀或后缀,则必须在“查找名称”后面包含冒号。" |
| 228 |
|
| 229 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:86 |
| 230 |
msgid "" |
| 231 |
"You must use either no or both ``|`` characters. Using one, as in ``{field:|" |
| 232 |
" - }``, is not allowed." |
| 233 |
msgstr "你必须要么完全不使用 ``|`` 字符,要么同时使用两个。像 ``{field:| - }``这样只使用一个 | 是不被允许的。" |
| 234 |
|
| 235 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:87 |
| 236 |
msgid "" |
| 237 |
"It is OK to provide no text for either the prefix or the suffix, such as in " |
| 238 |
"``{series:|| - }``. The template ``{title:||}`` is the same as ``{title}``." |
| 239 |
msgstr "可以不为前缀或后缀提供任何文本,例如 ``{series:|| - }``是允许的。模板 ``{title:||}`` 与 ``{title:||}`` 是等效的。" |
| 240 |
|
| 241 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:89 |
| 242 |
msgid "**Formatting**" |
| 243 |
msgstr "**格式化**" |
| 244 |
|
| 245 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:91 |
| 246 |
msgid "" |
| 247 |
"Suppose you want the ``series_index`` to be formatted as three digits with " |
| 248 |
"leading zeros. This does the trick:" |
| 249 |
msgstr "假设你希望将 ``series_index``格式化为三位数,并在前面补零。这段代码就能实现这个效果:" |
| 250 |
|
| 251 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:93 |
| 252 |
msgid "``{series_index:0>3s}`` - Three digits with leading zeros" |
| 253 |
msgstr "``{series_index:0>3s}`` - 三位数,前面补零" |
| 254 |
|
| 255 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:95 |
| 256 |
msgid "For trailing zeros, use:" |
| 257 |
msgstr "若要在后面补零,请使用:" |
| 258 |
|
| 259 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:97 |
| 260 |
msgid "``{series_index:0<3s}`` - Three digits with trailing zeros" |
| 261 |
msgstr "``{series_index:0<3s}`` - - 三位数,后面补零" |
| 262 |
|
| 263 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:99 |
| 264 |
msgid "" |
| 265 |
"If you use series indices with fractional values, e.g., 1.1, you might want " |
| 266 |
"the decimal points to line up. For example, you might want the indices 1 and" |
| 267 |
" 2.5 to appear as 01.00 and 02.50 so that they will sort correctly on a " |
| 268 |
"device that does lexical sorting. To do this, use:" |
| 269 |
msgstr "如果您使用带有小数值的系列索引,例如 1.1,您可能希望小数点对齐。 例如,您可能希望索引 1 和 2.5 显示为 01.00 和 02.50,以便它们在进行词法排序的设备上正确排序。 为此,请使用:" |
| 270 |
|
| 271 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:101 |
| 272 |
msgid "" |
| 273 |
"``{series_index:0>5.2f}`` - Five characters consisting of two digits with " |
| 274 |
"leading zeros, a decimal point, then 2 digits after the decimal point." |
| 275 |
msgstr "``{series_index:0>5.2f}`` - 总共五个字符:前面补零的两位整数,一个小数点,和小数点后两位数字。" |
| 276 |
|
| 277 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:103 |
| 278 |
msgid "If you want only the first two letters of the data, use:" |
| 279 |
msgstr "如果你只想保留数据的前两个字母,请使用:" |
| 280 |
|
| 281 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:105 |
| 282 |
msgid "" |
| 283 |
"``{author_sort:.2}`` - Only the first two letters of the author sort name" |
| 284 |
msgstr "``{author_sort:.2}`` - 仅显示作者排序名称(author sort name)的前两个字母" |
| 285 |
|
| 286 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:107 |
| 287 |
msgid "" |
| 288 |
"Much of the calibre template language formatting comes from Python. For more" |
| 289 |
" details on the syntax of these advanced formatting operations see the " |
| 290 |
"`Python documentation " |
| 291 |
"<https://docs.python.org/3/library/string.html#formatstrings>`_." |
| 292 |
msgstr "大部分 calibre 模板语言格式都来自 Python。 有关这些高级格式化操作的语法的更多详细信息,请参阅“Python 文档 <https://docs.python.org/3/library/string.html#formatstrings>”_。" |
| 293 |
|
| 294 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:111 |
| 295 |
msgid "Using templates to define custom columns" |
| 296 |
msgstr "使用模板来定义自定义栏目" |
| 297 |
|
| 298 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:113 |
| 299 |
msgid "" |
| 300 |
"Templates can be used to display information that isn't in calibre metadata," |
| 301 |
" or to display metadata differently from calibre's normal format. For " |
| 302 |
"example, you might want to show the ``ISBN``, a field that calibre does not " |
| 303 |
"display. You can accomplish this creating a custom column with the type " |
| 304 |
"`Column built from other columns` (hereafter called `composite columns`) and" |
| 305 |
" providing a template to generate the displayed text. The column will " |
| 306 |
"display the result of evaluating the template. For example, to display the " |
| 307 |
"ISBN, create the column and enter ``{identifiers:select(isbn)}`` in the " |
| 308 |
"template box. To display a column containing the values of two series custom" |
| 309 |
" columns, separated by a comma, use ``{#series1:||,}{#series2}``." |
| 310 |
msgstr "模板可用于显示 calibre 元数据中没有的信息,或以不同于 calibre 正常格式的方式显示元数据。 例如,您可能想要显示“ISBN”,这是 calibre 不显示的字段。 您可以通过创建类型为“从其他列构建的列”(以下称为“复合列”)的自定义列来完成此操作,并提供一个模板来生成显示的文本。 该列将显示评估模板的结果。 例如,要显示 ISBN,请创建列并在模板框中输入“{identifiers:select(isbn)}”。 要显示包含两个系列自定义列的值(以逗号分隔)的列,请使用``{#series1:||,}{#series2}``。" |
| 311 |
|
| 312 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:115 |
| 313 |
msgid "Composite columns can use any template option, including formatting." |
| 314 |
msgstr "组合列可以使用任何模板选项,包括格式化功能。" |
| 315 |
|
| 316 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:117 |
| 317 |
msgid "" |
| 318 |
"Note: You cannot edit the data displayed in a composite column. Instead you " |
| 319 |
"edit the source columns. If you edit a composite column, for example by " |
| 320 |
"double-clicking it, calibre will open the template for editing, not the " |
| 321 |
"underlying data." |
| 322 |
msgstr "注意:您无法编辑复合列中显示的数据。 相反,您可以编辑源列。 如果您编辑复合列,例如通过双击它,calibre 将打开模板进行编辑,而不是基础数据。" |
| 323 |
|
| 324 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:121 |
| 325 |
msgid "Templates and plugboards" |
| 326 |
msgstr "模板与元数据处理规则" |
| 327 |
|
| 328 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:123 |
| 329 |
msgid "" |
| 330 |
"Plugboards are used for changing the metadata written into books during " |
| 331 |
"send-to-device and save-to-disk operations. A plugboard permits you to " |
| 332 |
"specify a template to provide the data to write into the book's metadata. " |
| 333 |
"You can use plugboards to modify the following fields: authors, author_sort," |
| 334 |
" language, publisher, tags, title, title_sort. This feature helps people who" |
| 335 |
" want to use different metadata in books on devices to solve sorting or " |
| 336 |
"display issues." |
| 337 |
msgstr "插件板用于在发送到设备和保存到磁盘操作期间更改写入书籍的元数据。 插件板允许您指定一个模板来提供要写入书籍元数据的数据。 您可以使用插件板修改以下字段:作者、author_sort、语言、出版商、标签、书名、title_sort。 此功能可以帮助想要在设备上使用图书中的不同元数据的人们解决排序或显示问题。" |
| 338 |
|
| 339 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:125 |
| 340 |
msgid "" |
| 341 |
"When you create a plugboard, you specify the format and device for which the" |
| 342 |
" plugboard is to be used. A special device is provided, ``save_to_disk``, " |
| 343 |
"that is used when saving formats (as opposed to sending them to a device). " |
| 344 |
"Once you have chosen the format and device, you choose the metadata fields " |
| 345 |
"to change, providing templates to supply the new values. These templates are" |
| 346 |
" `connected` to their destination fields, hence the name `plugboards`. You " |
| 347 |
"can of course use composite columns in these templates." |
| 348 |
msgstr "创建插接板时,您可以指定插接板要使用的格式和设备。 提供了一个特殊的设备“save_to_disk”,在保存格式时使用(而不是将它们发送到设备)。 选择格式和设备后,您可以选择要更改的元数据字段,并提供模板来提供新值。 这些模板“连接”到其目标字段,因此称为“插件板”。 您当然可以在这些模板中使用复合列。" |
| 349 |
|
| 350 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:127 |
| 351 |
msgid "" |
| 352 |
"Plugboards are quite flexible and can be written in Single Function Mode, " |
| 353 |
"Template Program Mode, General Program Mode, or Python Template mode." |
| 354 |
msgstr "处理规则功能非常灵活,可以使用“单函数模式”、“模板程序模式”、“通用程序模式”或“Python 模板模式”进行编写。" |
| 355 |
|
| 356 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:129 |
| 357 |
msgid "" |
| 358 |
"When a plugboard might apply (Content server, save to disk, or send to " |
| 359 |
"device), calibre searches the defined plugboards to choose the correct one " |
| 360 |
"for the given format and device. For example, to find the appropriate " |
| 361 |
"plugboard for an EPUB book being sent to an ANDROID device, calibre searches" |
| 362 |
" the plugboards using the following search order:" |
| 363 |
msgstr "当插件板可能适用时(内容服务器、保存到磁盘或发送到设备),calibre 会搜索定义的插件板,为给定的格式和设备选择正确的插件板。 例如,要为发送到 ANDROID 设备的 EPUB 图书找到合适的插件板,calibre 使用以下搜索顺序搜索插件板:" |
| 364 |
|
| 365 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:133 |
| 366 |
msgid "" |
| 367 |
"a plugboard with an exact match on format and device, e.g., ``EPUB`` and " |
| 368 |
"``ANDROID``" |
| 369 |
msgstr "一条针对格式和设备进行了精确匹配的处理规则,例如:格式为``EPUB``且设备为``ANDROID``。" |
| 370 |
|
| 371 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:134 |
| 372 |
msgid "" |
| 373 |
"a plugboard with an exact match on format and the special ``any device`` " |
| 374 |
"choice, e.g., ``EPUB`` and ``any device``" |
| 375 |
msgstr "一条针对格式进行了精确匹配、但设备选择为特殊的 ``any device``(任何设备)的处理规则,例如:格式为``EPUB``且设备为 ``any device``" |
| 376 |
|
| 377 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:135 |
| 378 |
msgid "" |
| 379 |
"a plugboard with the special ``any format`` choice and an exact match on " |
| 380 |
"device, e.g., ``any format`` and ``ANDROID``" |
| 381 |
msgstr "一条格式选择为特殊的 ``any format ``(任何格式)、但针对设备进行了精确匹配的处理规则,例如:格式为 ``any format `` 且设备为 ``ANDROID ``。" |
| 382 |
|
| 383 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:136 |
| 384 |
msgid "a plugboard with ``any format`` and ``any device``" |
| 385 |
msgstr "一条格式为 ``any format``(任何格式)且设备为 ``any device``(任何设备)的处理规则" |
| 386 |
|
| 387 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:138 |
| 388 |
msgid "" |
| 389 |
"The tags and authors fields have special treatment, because both of these " |
| 390 |
"fields can hold more than one item. A book can have many tags and many " |
| 391 |
"authors. When you specify that one of these two fields is to be changed, the" |
| 392 |
" template's result is examined to see if more than one item is there. For " |
| 393 |
"tags, the result is cut apart wherever calibre finds a comma. For example, " |
| 394 |
"if the template produces the value ``Thriller, Horror``, then the result " |
| 395 |
"will be two tags, ``Thriller`` and ``Horror``. There is no way to put a " |
| 396 |
"comma in the middle of a tag." |
| 397 |
msgstr "标签和作者字段有特殊处理,因为这两个字段都可以容纳多个项目。 一本书可以有多个标签和多个作者。 当您指定要更改这两个字段之一时,将检查模板的结果以查看是否存在多个项目。 对于标签,只要 calibre 找到逗号,结果就会被分割。 例如,如果模板生成值“Thriller, Horror”,则结果将是两个标签“Thriller”和“Horror”。 无法在标签中间放置逗号。" |
| 398 |
|
| 399 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:141 |
| 400 |
msgid "" |
| 401 |
"The same thing happens for authors, but using a different character for the " |
| 402 |
"cut, a `&` (ampersand) instead of a comma. For example, if the template " |
| 403 |
"produces the value ``Blogs, Joe&Posts, Susan``, then the book will end up " |
| 404 |
"with two authors, ``Blogs, Joe`` and ``Posts, Susan``. If the template " |
| 405 |
"produces the value ``Blogs, Joe;Posts, Susan``, then the book will have one " |
| 406 |
"author with a rather strange name." |
| 407 |
msgstr "作者也会发生同样的情况,但使用不同的字符进行剪切,即“&”(与号)而不是逗号。 例如,如果模板生成值“Blogs, Joe&Posts, Susan”,则该书最终将有两个作者:“Blogs, Joe”和“Posts, Susan”。 如果模板生成值“博客,乔;帖子,苏珊”,那么这本书将有一位作者的名字相当奇怪。" |
| 408 |
|
| 409 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:143 |
| 410 |
msgid "" |
| 411 |
"Plugboards affect the metadata written into the book when it is saved to " |
| 412 |
"disk or written to the device. Plugboards do not affect the metadata used by" |
| 413 |
" ``save to disk`` and ``send to device`` to create the file names. Instead, " |
| 414 |
"file names are constructed using the templates entered on the appropriate " |
| 415 |
"preferences window." |
| 416 |
msgstr "当将书籍保存到磁盘或写入设备时,插件板会影响写入书中的元数据。 插件板不会影响“保存到磁盘”和“发送到设备”用来创建文件名的元数据。 相反,文件名是使用在适当的首选项窗口中输入的模板构建的。" |
| 417 |
|
| 418 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:148 |
| 419 |
msgid "Using functions in templates - Single Function Mode" |
| 420 |
msgstr "在模板中使用函数 - 单函数模式" |
| 421 |
|
| 422 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:150 |
| 423 |
msgid "" |
| 424 |
"Suppose you want to display the value of a field in upper case when that " |
| 425 |
"field is normally in title case. You can do this using `template functions`." |
| 426 |
" For example, to display the title in upper case use the ``uppercase`` " |
| 427 |
"function, as in ``{title:uppercase()}``. To display it in title case, use " |
| 428 |
"``{title:titlecase()}``." |
| 429 |
msgstr "假设您想要以大写形式显示某个字段的值,而该字段通常为标题大写形式。 您可以使用“模板函数”来完成此操作。 例如,要以大写形式显示标题,请使用“uppercase”函数,如“{title:uppercase()}”。 要以标题大小写显示它,请使用``{title:titlecase()}``。" |
| 430 |
|
| 431 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:152 |
| 432 |
msgid "" |
| 433 |
"Functions go into the format part of the template, after the ``:`` and " |
| 434 |
"before the first ``|`` or the closing ``}`` if no prefix/suffix is used. If " |
| 435 |
"you have both a format and a function reference, the function comes after a " |
| 436 |
"second ``:``. Functions return the value of the column specified in the " |
| 437 |
"template, suitably modified." |
| 438 |
msgstr "函数进入模板的格式部分,在 ``:`` 之后和第一个 ``|`` 之前,或者如果没有使用前缀/后缀,则在结束的 ``}`` 之前。 如果您同时具有格式和函数引用,则该函数位于第二个 ``:`` 后面。 函数返回模板中指定的列的值,经过适当修改。" |
| 439 |
|
| 440 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:154 |
| 441 |
msgid "The syntax for using functions is one of::" |
| 442 |
msgstr "使用函数的语法形式为以下之一:: " |
| 443 |
|
| 444 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:161 |
| 445 |
msgid "" |
| 446 |
"Function names must always be followed by opening and closing parentheses. " |
| 447 |
"Some functions require extra values (arguments), and these go inside the " |
| 448 |
"parentheses. Arguments are separated by commas. Literal commas (commas as " |
| 449 |
"text, not argument separators) must be preceded by a backslash (``\\``) . " |
| 450 |
"The last (or only) argument cannot contain a textual closing parenthesis." |
| 451 |
msgstr "函数名称后面必须始终跟有左括号和右括号。 有些函数需要额外的值(参数),这些值位于括号内。 参数之间用逗号分隔。 文字逗号(逗号作为文本,而不是参数分隔符)前面必须有反斜杠 (``\\``) 。 最后一个(或唯一的)参数不能包含文本右括号。" |
| 452 |
|
| 453 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:163 |
| 454 |
msgid "" |
| 455 |
"Functions are evaluated before format specifications and the prefix/suffix. " |
| 456 |
"See further down for an example of using both a format and a function." |
| 457 |
msgstr "函数会在格式规范(format specifications)以及前缀/后缀(prefix/suffix)之前执行评估。有关同时使用格式和函数的示例,请参阅下文。" |
| 458 |
|
| 459 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:165 |
| 460 |
msgid "" |
| 461 |
"**Important**: If you have programming experience, please note that the " |
| 462 |
"syntax in `Single Function Mode` is not what you expect. Strings are not " |
| 463 |
"quoted and spaces are significant. All arguments are considered to be " |
| 464 |
"constants; there are no expressions." |
| 465 |
msgstr "**重要**:如果您有编程经验,请注意“单函数模式”中的语法不是您所期望的。 字符串不加引号,并且空格很重要。 所有参数都被视为常量; 没有表达式。" |
| 466 |
|
| 467 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:167 |
| 468 |
msgid "" |
| 469 |
"**Do not use subtemplates (`{ ... }`) as function arguments.** Instead, use " |
| 470 |
":ref:`Template Program Mode <template_mode>` and :ref:`General Program Mode " |
| 471 |
"<general_mode>`." |
| 472 |
msgstr "**请勿将子模板({ ... })作为函数参数使用。** 取而代之,请使用 :ref:`模板程序模式<template_mode>` 或 :ref:`通用程序模式<general_mode>`。" |
| 473 |
|
| 474 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:169 |
| 475 |
msgid "Notes on calling functions in Single Function Mode:" |
| 476 |
msgstr "关于在“单函数模式”下调用函数的注意事项:" |
| 477 |
|
| 478 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:171 |
| 479 |
msgid "" |
| 480 |
"When functions are used in Single Function Mode, the first parameter, " |
| 481 |
"``value``, is automatically replaced by the content of the field specified " |
| 482 |
"in the template. For example, when the template ``{title:capitalize()}`` is " |
| 483 |
"processed, the content of the ``title`` field is passed as the parameter " |
| 484 |
"``value`` to the capitalize function." |
| 485 |
msgstr "在“单函数模式”下使用函数时,第一个参数 ``value`` 会自动被模板中指定的字段内容所替换。例如,当处理模板`` {title:capitalize()}`` 时,``title`` 字段的内容会作为 ``value`` 参数传递给 capitalize 函数。" |
| 486 |
|
| 487 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:172 |
| 488 |
msgid "" |
| 489 |
"In the function documentation, the notation ``[something]*`` means that " |
| 490 |
"``something`` can be repeated zero or more times. The notation " |
| 491 |
"``[something]+`` means that the ``something`` is repeated one or more times " |
| 492 |
"(must exist at least one time)." |
| 493 |
msgstr "在函数文档中,标记 ``[something]*``表示 something可重复零次或多次。标记 ``[something]+``表示 ``something``重复一次或多次(必须至少存在一次)。" |
| 494 |
|
| 495 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:173 |
| 496 |
msgid "" |
| 497 |
"Some functions use regular expressions. In the template language regular " |
| 498 |
"expression matching is case-insensitive." |
| 499 |
msgstr "某些函数会使用正则表达式。在模板语言中,正则表达式的匹配是不区分大小写的。" |
| 500 |
|
| 501 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:175 |
| 502 |
msgid "" |
| 503 |
"Functions are documented in :ref:`template_functions_reference`. The " |
| 504 |
"documentation tells you what arguments the functions require and what the " |
| 505 |
"functions do. For example, here is the documentation of the " |
| 506 |
":ref:`ff_ifempty` function." |
| 507 |
msgstr "函数的详细说明可参阅 :ref:`template_functions_reference`函数。该文档会说明各函数所需的参数及其功能。例如,以下是 :ref:`ff_ifempty`函数的说明。" |
| 508 |
|
| 509 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:179 |
| 510 |
msgid "" |
| 511 |
"You see that the function requires two arguments, ``value`` and " |
| 512 |
"``text_if_empty``. However, because we are using Single Function Mode, we " |
| 513 |
"omit the ``value`` argument, passing only ``text_if_empty``. For example, " |
| 514 |
"this template::" |
| 515 |
msgstr "您可以看到该函数需要两个参数:value 和 text_if_empty。但是,由于我们使用的是“单函数模式”,因此可以省略 value 参数,仅传递 text_if_empty。例如,使用如下模板:" |
| 516 |
|
| 517 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:183 |
| 518 |
msgid "" |
| 519 |
"shows the tags for a book, if any. If it has no tags then it shows `No tags " |
| 520 |
"on this book`." |
| 521 |
msgstr "显示该书的标签(如果有)。如果该书没有任何标签,则显示“本书无标签”。" |
| 522 |
|
| 523 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:185 |
| 524 |
msgid "" |
| 525 |
"The following functions are usable in Single Function Mode because their " |
| 526 |
"first parameter is ``value``." |
| 527 |
msgstr "由于下列函数的第一个参数均为 value,因此它们都可以在“单函数模式”下使用:" |
| 528 |
|
| 529 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:227 |
| 530 |
msgid "**Using functions and formatting in the same template**" |
| 531 |
msgstr "在同一个模板中同时使用函数和格式化" |
| 532 |
|
| 533 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:229 |
| 534 |
msgid "" |
| 535 |
"Suppose you have an integer custom column ``#myint`` that you want displayed" |
| 536 |
" with leading zeros, as in ``003``. One way to do this is to use a format of" |
| 537 |
" ``0>3s``. However, by default if a number (integer or float) equals zero " |
| 538 |
"then the value is displayed as the empty string so zero values will produce " |
| 539 |
"the empty string, not ``000``. If you want to see ``000`` values then you " |
| 540 |
"use both the format string and the ``ifempty`` function to change the empty " |
| 541 |
"value back to a zero. The template would be::" |
| 542 |
msgstr "假设您有一个整数自定义列“#myint”,您希望显示前导零,如“003”。 实现此目的的一种方法是使用“0>3s”的格式。 但是,默认情况下,如果数字(整数或浮点数)等于零,则该值将显示为空字符串,因此零值将生成空字符串,而不是“000”。 如果您想查看“000”值,则可以使用格式字符串和“ifempty”函数将空值更改回零。 模板将是:" |
| 543 |
|
| 544 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:233 |
| 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 template::" |
| 548 |
msgstr "请注意,您也可以同时使用前缀和后缀。如果您希望数字显示为 [003] 或 [000],请使用如下模板:" |
| 549 |
|
| 550 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:240 |
| 551 |
msgid "General Program Mode" |
| 552 |
msgstr "通用程序模式" |
| 553 |
|
| 554 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:242 |
| 555 |
msgid "" |
| 556 |
"`General Program Mode` (`GPM`) replaces `template expressions` with a " |
| 557 |
"program written in the `template language`. The syntax of the language is " |
| 558 |
"defined by the following grammar::" |
| 559 |
msgstr "“通用程序模式 (GPM)”会将“模板表达式”替换为一段使用“模板语言”编写的程序。该语言的语法由以下文法定义:" |
| 560 |
|
| 561 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:295 |
| 562 |
msgid "" |
| 563 |
"a ``top_expression`` always has a value. The value of an ``expression_list``" |
| 564 |
" is the value of the last ``top_expression`` in the list. For example, the " |
| 565 |
"value of the expression list ``1;2;'foobar';3`` is ``3``." |
| 566 |
msgstr "top_expression(顶层表达式)始终具有一个值。expression_list(表达式列表)的值是列表中最后一个 top_expression 的值。例如,表达式列表 1;2;'foobar';3 的值是 3。" |
| 567 |
|
| 568 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:296 |
| 569 |
msgid "In a logical context, any non-empty value is ``True``" |
| 570 |
msgstr "在逻辑语境中,任何非空值(non-empty value)均被视为 True(真)。" |
| 571 |
|
| 572 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:297 |
| 573 |
msgid "In a logical context, the empty value is ``False``" |
| 574 |
msgstr "在逻辑语境中,空值(empty value)被视为 False(假)。" |
| 575 |
|
| 576 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:298 |
| 577 |
msgid "" |
| 578 |
"Strings and numbers can be used interchangeably. For example, ``10`` and " |
| 579 |
"``'10'`` are the same thing." |
| 580 |
msgstr "字符串和数字可以互换使用。例如,10 和 '10' 是完全相同的。" |
| 581 |
|
| 582 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:299 |
| 583 |
msgid "" |
| 584 |
"Comments are lines starting with a '#' character, possibly preceded by " |
| 585 |
"blanks or tabs." |
| 586 |
msgstr "注释是以 # 字符开头的行,其前面可以包含空格或制表符(tabs)。" |
| 587 |
|
| 588 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:301 |
| 589 |
msgid "**Operator precedence**" |
| 590 |
msgstr "运算符优先级" |
| 591 |
|
| 592 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:303 |
| 593 |
msgid "" |
| 594 |
"The operator precedence (order of evaluation) from highest (evaluated first)" |
| 595 |
" to lowest (evaluated last) is:" |
| 596 |
msgstr "运算符优先级(求值顺序)从最高(最先求值)到最低(最后求值)依次为:" |
| 597 |
|
| 598 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:305 |
| 599 |
msgid "" |
| 600 |
"Function calls, constants, parenthesized expressions, statement expressions," |
| 601 |
" assignment expressions, field references." |
| 602 |
msgstr "函数调用、常量、括号表达式、语句表达式、赋值表达式、字段引用。" |
| 603 |
|
| 604 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:306 |
| 605 |
msgid "" |
| 606 |
"Unary plus (``+``) and minus (``-``). These operators evaluate right to " |
| 607 |
"left." |
| 608 |
msgstr "一元正号 (+) 和一元负号 (-)。这些运算符按从右至左的顺序求值。" |
| 609 |
|
| 610 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:308 |
| 611 |
msgid "" |
| 612 |
"These and all the other arithmetic operators return integers if the " |
| 613 |
"expression results in a fractional part equal to zero. For example, if an " |
| 614 |
"expression returns ``3.0`` it is changed to ``3``." |
| 615 |
msgstr "这些运算符以及所有其他算术运算符,在表达式结果的小数部分为零时,都会返回整数。例如,如果表达式的结果为 3.0,它将被转换为 3。" |
| 616 |
|
| 617 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:309 |
| 618 |
msgid "" |
| 619 |
"Multiply (``*``) and divide (``/``). These operators are associative and " |
| 620 |
"evaluate left to right. Use parentheses if you want to change the order of " |
| 621 |
"evaluation." |
| 622 |
msgstr "乘法 (*) 和除法 (/)。这些运算符具有结合性,且按从左至右的顺序求值。如果您想改变求值顺序,请使用括号。" |
| 623 |
|
| 624 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:310 |
| 625 |
msgid "" |
| 626 |
"Add (``+``) and subtract (``-``). These operators are associative and " |
| 627 |
"evaluate left to right." |
| 628 |
msgstr "加法 (+) 和减法 (-)。这些运算符具有结合性,且按从左至右的顺序求值。" |
| 629 |
|
| 630 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:311 |
| 631 |
msgid "" |
| 632 |
"Numeric and string comparisons. These operators return ``'1'`` if the " |
| 633 |
"comparison succeeds, otherwise the empty string (``''``). Comparisons are " |
| 634 |
"not associative: ``a < b < c`` is a syntax error." |
| 635 |
msgstr "数值与字符串比较。如果比较成功,这些运算符返回 '1',否则返回空字符串 ('')。比较运算符不具备结合性:例如 a < b < c 是语法错误。" |
| 636 |
|
| 637 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:312 |
| 638 |
msgid "" |
| 639 |
"String concatenation (``&``). The ``&`` operator returns a string formed by " |
| 640 |
"concatenating the left-hand and right-hand expressions. Example: ``'aaa' & " |
| 641 |
"'bbb'`` returns ``'aaabbb'``. The operator is associative and evaluates left" |
| 642 |
" to right." |
| 643 |
msgstr "字符串拼接 (&)。& 运算符返回由左侧表达式和右侧表达式连接而成的字符串。例如:'aaa' & 'bbb' 返回 'aaabbb'。该运算符具有结合性,且按从左至右的顺序求值。" |
| 644 |
|
| 645 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:313 |
| 646 |
msgid "" |
| 647 |
"Unary logical not (``!``). This operator returns ``'1'`` if the expression " |
| 648 |
"is False (evaluates to the empty string), otherwise ``''``." |
| 649 |
msgstr "一元逻辑非 (!)。如果表达式为“假”(求值为空字符串),则此运算符返回 '1';否则返回 ''(空字符串)。" |
| 650 |
|
| 651 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:314 |
| 652 |
msgid "" |
| 653 |
"Logical and (``&&``). This operator returns '1' if both the left-hand and " |
| 654 |
"right-hand expressions are True, or the empty string ``''`` if either is " |
| 655 |
"False. It is associative, evaluates left to right, and does `short-" |
| 656 |
"circuiting <https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_." |
| 657 |
msgstr "逻辑与 (&&)。如果左侧和右侧表达式均为“真”(True),则此运算符返回 '1';如果其中任何一个为“假”(False),则返回空字符串 ''。该运算符具有结合性,按从左至右的顺序求值,并支持`短路计算 (short-circuiting) <https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_。" |
| 658 |
|
| 659 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:315 |
| 660 |
msgid "" |
| 661 |
"Logical or (``||``). This operator returns ``'1'`` if either the left-hand " |
| 662 |
"or right-hand expression is True, or ``''`` if both are False. It is " |
| 663 |
"associative, evaluates left to right, and does `short-circuiting " |
| 664 |
"<https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_. It is an " |
| 665 |
"`inclusive or`, returning ``'1'`` if both the left- and right-hand " |
| 666 |
"expressions are True." |
| 667 |
msgstr "逻辑或 (``||``)。 如果左侧表达式或右侧表达式为 True,则此运算符返回 ``'1'``;如果均为 False,则返回 ``''``。 它是关联的,从左到右求值,并进行“短路”<https://chortle.ccsu.edu/java5/Notes/chap40/ch40_2.html>`_。 它是一个“包含或”,如果左侧和右侧表达式都为 True,则返回“'1””。" |
| 668 |
|
| 669 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:317 |
| 670 |
msgid "**Field references**" |
| 671 |
msgstr "**字段引用**" |
| 672 |
|
| 673 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:319 |
| 674 |
msgid "" |
| 675 |
"A ``field_reference`` evaluates to the value of the metadata field named by " |
| 676 |
"lookup name that follows the ``$`` or ``$$``. Using ``$`` is equivalent to " |
| 677 |
"using the :ref:`ff_field` function. Using ``$$`` is equivalent to using the " |
| 678 |
":ref:`ff_raw_field` function. Examples::" |
| 679 |
msgstr "field_reference(字段引用)的求值结果是 $ 或 $$ 之后所接“查找名称”(lookup name)对应的元数据字段值。使用 $ 等同于使用 :ref:`ff_field` 函数;使用 $$ 则等同于使用 :ref:`ff_raw_field` 函数。示例如下::" |
| 680 |
|
| 681 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:326 |
| 682 |
msgid "**If expressions**" |
| 683 |
msgstr "**If 表达式**" |
| 684 |
|
| 685 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:328 |
| 686 |
msgid "" |
| 687 |
"``If`` expressions first evaluate the ``condition``. If the ``condition`` is" |
| 688 |
" True (a non-empty value) then the ``expression_list`` in the ``then`` " |
| 689 |
"clause is evaluated. If it is False then if present the ``expression_list`` " |
| 690 |
"in the ``elif`` or ``else`` clause is evaluated. The ``elif`` and ``else`` " |
| 691 |
"parts are optional. The words ``if``, ``then``, ``elif``, ``else``, and " |
| 692 |
"``fi`` are reserved; you cannot use them as identifier names. You can put " |
| 693 |
"newlines and white space wherever they make sense. The ``condition`` is a " |
| 694 |
"``top_expression`` not an ``expression_list``; semicolons are not allowed. " |
| 695 |
"The ``expression_lists`` are semicolon-separated sequences of " |
| 696 |
"``top_expressions``. An ``if`` expression returns the result of the last " |
| 697 |
"``top_expression`` in the evaluated ``expression_list``, or the empty string" |
| 698 |
" if no expression list was evaluated." |
| 699 |
msgstr "``If`` 表达式首先评估``condition``。 如果“condition”为 True(非空值),则评估“then”子句中的“expression_list”。 如果为 False,则评估“elif”或“else”子句中的“expression_list”。 ``elif`` 和 ``else`` 部分是可选的。 单词“if”、“then”、“elif”、“else”和“fi”被保留; 您不能将它们用作标识符名称。 您可以在任何有意义的地方放置换行符和空格。 “condition”是“top_expression”,而不是“expression_list”; 不允许使用分号。 “表达式列表”是以分号分隔的“top_表达式”序列。 ``if`` 表达式返回已计算的 ``expression_list`` 中最后一个 ``top_expression`` 的结果,如果没有计算表达式列表,则返回空字符串。" |
| 700 |
|
| 701 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:330 |
| 702 |
msgid "Examples::" |
| 703 |
msgstr "示例::" |
| 704 |
|
| 705 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:343 |
| 706 |
msgid "Nested ``if`` example::" |
| 707 |
msgstr "嵌套 if 示例::" |
| 708 |
|
| 709 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:356 |
| 710 |
msgid "" |
| 711 |
"As said above, an ``if`` produces a value. This means that all the following" |
| 712 |
" are equivalent::" |
| 713 |
msgstr "如上所述,if 语句会产生一个值。这意味着以下所有写法都是等效的::" |
| 714 |
|
| 715 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:362 |
| 716 |
msgid "" |
| 717 |
"For example, this program returns the value of the ``series`` column if the " |
| 718 |
"book has a series, otherwise the value of the ``title`` column::" |
| 719 |
msgstr "例如,如果书籍有关联的丛书,此程序将返回 series(丛书)列的值,否则返回 title(书名)列的值::" |
| 720 |
|
| 721 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:366 |
| 722 |
msgid "**For expressions**" |
| 723 |
msgstr "**For表达式**" |
| 724 |
|
| 725 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:368 |
| 726 |
msgid "" |
| 727 |
"The ``for`` expression iterates over a list of values, processing them one " |
| 728 |
"at a time. The ``list_expression`` must evaluate either to a metadata field " |
| 729 |
"``lookup name`` e.g., ``tags`` or ``#genre``, or to a list of values. The " |
| 730 |
":ref:`ff_range` generates a list of numbers. If the result is a valid " |
| 731 |
"``lookup name`` then the field's value is fetched and the separator " |
| 732 |
"specified for that field type is used. If the result isn't a valid lookup " |
| 733 |
"name then it is assumed to be a list of values. The list is assumed to be " |
| 734 |
"separated by commas unless the optional keyword ``separator`` is supplied, " |
| 735 |
"in which case the list values must be separated by the result of evaluating " |
| 736 |
"the ``separator_expr``. A separator cannot be used if the list is generated " |
| 737 |
"by ``range()``. Each value in the list is assigned to the specified variable" |
| 738 |
" then the ``expression_list`` is evaluated. You can use ``break`` to jump " |
| 739 |
"out of the loop, and ``continue`` to jump to the beginning of the loop for " |
| 740 |
"the next iteration." |
| 741 |
msgstr "for 表达式会迭代一个值列表,并逐个处理这些值。其中 list_expression(列表表达式)必须求值为元数据字段的“查找名称”(如 tags 或 #genre),或者求值为一个值列表。:ref:ff_range 函数可用于生成数字列表。如果求值结果是一个有效的“查找名称”,系统将获取该字段的值,并使用该字段类型指定的默认分隔符。如果结果不是有效的查找名称,则将其视为普通的值列表。除非提供了可选关键字 separator(分隔符),否则默认列表以逗号分隔;若提供了该关键字,则列表值必须以 separator_expr 的求值结果进行分隔。注意,如果列表是由 range() 生成的,则不能使用自定义分隔符。列表中的每个值都会被分配给指定的变量,然后执行 expression_list(表达式列表)。你可以使用 break 跳出循环,或使用 continue 跳回循环开头进行下一次迭代。" |
| 742 |
|
| 743 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:370 |
| 744 |
msgid "" |
| 745 |
"Example: This template removes the first hierarchical name for each value in" |
| 746 |
" Genre (``#genre``), constructing a list with the new names::" |
| 747 |
msgstr "示例:此模板会移除“类型 (#genre)”字段中每个值的第一个层级名称,并用处理后的新名称构建一个列表:" |
| 748 |
|
| 749 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:380 |
| 750 |
msgid "" |
| 751 |
"If the original Genre is `History.Military, Science Fiction.Alternate " |
| 752 |
"History, ReadMe` then the template returns `Military, Alternate History, " |
| 753 |
"ReadMe`. You could use this template in calibre's :guilabel:`Edit metadata " |
| 754 |
"in bulk -> Search & replace` with :guilabel:`Search for` set to ``template``" |
| 755 |
" to strip off the first level of the hierarchy and assign the resulting " |
| 756 |
"value to Genre." |
| 757 |
msgstr "如果原始类型是“History.Military, Science Fiction.Alternate History, ReadMe”,则模板将返回“Military, Alternate History, ReadMe”。 您可以在 calibre 的“批量编辑元数据 -> 搜索和替换”中使用此模板,并将“搜索”设置为“模板”,以剥离层次结构的第一级并将结果值分配给类型。" |
| 758 |
|
| 759 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:383 |
| 760 |
msgid "" |
| 761 |
"Note: the last line in the template, ``new_tags``, isn't strictly necessary " |
| 762 |
"in this case because ``for`` returns the value of the last top_expression in" |
| 763 |
" the expression list. The value of an assignment is the value of its " |
| 764 |
"expression, so the value of the ``for`` statement is what was assigned to " |
| 765 |
"``new_tags``." |
| 766 |
msgstr "注意:在这种情况下,模板中的最后一行“new_tags”并不是绝对必要的,因为“for”返回表达式列表中最后一个 top_expression 的值。 赋值的值是其表达式的值,因此“for”语句的值就是分配给“new_tags”的值。" |
| 767 |
|
| 768 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:385 |
| 769 |
msgid "**with expressions**" |
| 770 |
msgstr "**with表达式**" |
| 771 |
|
| 772 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:387 |
| 773 |
msgid "The ``with`` expression:" |
| 774 |
msgstr " ``with`` 表达式:" |
| 775 |
|
| 776 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:389 |
| 777 |
msgid "" |
| 778 |
"changes the current book to the book with calibre book id (an integer) " |
| 779 |
"produced by evaluating the ``top_expression``." |
| 780 |
msgstr "将当前书籍切换为由 top_expression 求值生成的 Calibre 书籍 ID(整数)所对应的书籍。" |
| 781 |
|
| 782 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:390 |
| 783 |
msgid "runs the ``expression_list``." |
| 784 |
msgstr "运行 ``expression_list``." |
| 785 |
|
| 786 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:391 |
| 787 |
msgid "then resets the current book back to what it was." |
| 788 |
msgstr "随后将当前书籍重置回其原本的状态。" |
| 789 |
|
| 790 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:393 |
| 791 |
msgid "" |
| 792 |
"The ``with`` expression returns the result of the last ``top_expression`` in" |
| 793 |
" the evaluated ``expression_list``, or the empty string if no expression " |
| 794 |
"list was evaluated." |
| 795 |
msgstr "with 表达式返回所执行的 expression_list 中最后一个 top_expression 的计算结果;如果没有执行任何表达式列表,则返回空字符串。" |
| 796 |
|
| 797 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:396 |
| 798 |
msgid "" |
| 799 |
"For example, this template returns a list of the titles of each book " |
| 800 |
"selected in the GUI::" |
| 801 |
msgstr "示例:此模板会返回一个列表,其中包含当前在GUI中所选中的每本书的书名:" |
| 802 |
|
| 803 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:408 |
| 804 |
msgid "**Return stmt**" |
| 805 |
msgstr "**Return 语句**" |
| 806 |
|
| 807 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:410 |
| 808 |
msgid "" |
| 809 |
"Return the value of the ``expression``. If executed in a function then it " |
| 810 |
"returns the value of the expression to the caller. If executed in the " |
| 811 |
"outermost context (the template) then it sets the value of the template to " |
| 812 |
"the value of the expression and exits the template." |
| 813 |
msgstr "返回 expression(表达式)的值。如果在函数内部执行,它会将该值返回给调用者。如果在最外层上下文(即模板本身)中执行,它会将模板的最终值设定为该表达式的值并退出模板。" |
| 814 |
|
| 815 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:412 |
| 816 |
msgid "**Function definition**" |
| 817 |
msgstr "**函数定义**" |
| 818 |
|
| 819 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:414 |
| 820 |
msgid "" |
| 821 |
"If you have repeated code in a template then you can put that code into a " |
| 822 |
"local function. The ``def`` keyword starts the definition. It is followed by" |
| 823 |
" the function name, the argument list, then the code in the function. The " |
| 824 |
"function definition ends with the ``fed`` keyword." |
| 825 |
msgstr "如果你在模板中有重复的代码,可以将其放入一个局部函数中。def 关键字标志着定义的开始,其后依次是函数名、参数列表以及函数体内的代码。函数定义以 fed 关键字结束。" |
| 826 |
|
| 827 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:416 |
| 828 |
msgid "" |
| 829 |
"Arguments are positional. When a function is called the supplied arguments " |
| 830 |
"are matched left to right against the defined parameters, with the value of " |
| 831 |
"the argument assigned to the parameter. It is an error to provide more " |
| 832 |
"arguments than defined parameters. Parameters can have default values, such " |
| 833 |
"as ``a = 25``. If an argument is not supplied for that parameter then the " |
| 834 |
"default value is used, otherwise the parameter is set to the empty string." |
| 835 |
msgstr "参数是立场性的。 调用函数时,提供的参数会从左到右与定义的参数进行匹配,并将参数的值分配给参数。 提供的参数多于定义的参数是错误的。 参数可以有默认值,例如“a = 25”。 如果没有为该参数提供参数,则使用默认值,否则该参数将设置为空字符串。" |
| 836 |
|
| 837 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:418 |
| 838 |
msgid "The ``return`` statement can be used in a local function." |
| 839 |
msgstr "return 语句可以在局部函数中使用。" |
| 840 |
|
| 841 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:420 |
| 842 |
msgid "A function must be defined before it can be used." |
| 843 |
msgstr "函数必须先定义才能使用。" |
| 844 |
|
| 845 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:422 |
| 846 |
msgid "" |
| 847 |
"Example: This template computes an approximate duration in years, months, " |
| 848 |
"and days from a number of days. The function ``to_plural()`` formats the " |
| 849 |
"computed values. Note that the example also uses the ``&`` operator::" |
| 850 |
msgstr "示例:此模板根据总天数计算出大概的年、月、日时长。其中 to_plural() 函数用于格式化计算出的数值(处理复数形式)。请注意,此示例还使用了字符串连接符 &::" |
| 851 |
|
| 852 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:437 |
| 853 |
msgid "**Relational operators**" |
| 854 |
msgstr "**关系运算符**" |
| 855 |
|
| 856 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:439 |
| 857 |
msgid "" |
| 858 |
"Relational operators return ``'1'`` if the comparison is true, otherwise the" |
| 859 |
" empty string (``''``)." |
| 860 |
msgstr "如果比较结果为真(true),关系运算符将返回 '1';否则返回空字符串('')。" |
| 861 |
|
| 862 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:441 |
| 863 |
msgid "" |
| 864 |
"There are two forms of relational operators: string comparisons and numeric " |
| 865 |
"comparisons." |
| 866 |
msgstr "关系运算符有两种形式:字符串比较和数值比较。" |
| 867 |
|
| 868 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:443 |
| 869 |
msgid "" |
| 870 |
"String comparisons do case-insensitive string comparison using lexical " |
| 871 |
"order. The supported string comparison operators are ``==``, ``!=``, ``<``, " |
| 872 |
"``<=``, ``>``, ``>=``, ``in``, ``inlist``, and ``inlist_field``. For the " |
| 873 |
"``in``, ``inlist``, and ``inlist_field`` operators, the result of the left " |
| 874 |
"hand expression is interpreted as a regular expression pattern. They are " |
| 875 |
"true if the value of left-hand regular expression matches the value of the " |
| 876 |
"right hand expression. The regular expressions are case-insensitive." |
| 877 |
msgstr "字符串比较使用词典顺序进行不区分大小写的比较。支持的字符串比较运算符包括 ==、!=、<、<=、>、>=、in、inlist 以及 inlist_field。对于 in、inlist 和 inlist_field 运算符,左侧表达式的结果被视为正则表达式模式;如果左侧的正则表达式与右侧表达式的值匹配,则结果为真。这些正则表达式同样不区分大小写。" |
| 878 |
|
| 879 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:446 |
| 880 |
msgid "" |
| 881 |
"The ``inlist`` operator is true if the left hand regular expression matches " |
| 882 |
"any one of the items in the right hand list where the items in the list are " |
| 883 |
"separated by commas. The ``inlist_field`` operator is true if the left hand " |
| 884 |
"regular expression matches any of the items in the field (column) named by " |
| 885 |
"the right hand expression, using the separator defined for the field. NB: " |
| 886 |
"the ``inlist_field`` operator requires the right hand expression to evaluate" |
| 887 |
" to a field name, while the ``inlist`` operator requires the right hand " |
| 888 |
"expression to evaluate to a string containing a comma-separated list. " |
| 889 |
"Because of this difference, ``inlist_field`` is substantially faster than " |
| 890 |
"``inlist`` because no string conversions or list constructions are done." |
| 891 |
msgstr "如果左侧的正则表达式匹配右侧列表中的任何一项(列表项以逗号分隔),则 inlist 运算符为真。如果左侧的正则表达式匹配由右侧表达式命名的字段(列)中的任何一项,则 inlist_field 运算符为真,匹配时使用该字段定义的专用分隔符。注意:inlist_field 要求右侧表达式的计算结果为一个“字段名”,而 inlist 要求右侧表达式的结果为一个“包含逗号分隔列表的字符串”。由于这种差异,inlist_field 的执行速度明显快于 inlist,因为它不需要进行字符串转换或列表构建。" |
| 892 |
|
| 893 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:448 |
| 894 |
msgid "" |
| 895 |
"The numeric comparison operators are ``==#``, ``!=#``, ``<#``, ``<=#``, " |
| 896 |
"``>#``, ``>=#``. The left and right expressions must evaluate to numeric " |
| 897 |
"values with two exceptions: both the string value \"None\" (undefined field)" |
| 898 |
" and the empty string evaluate to the value zero." |
| 899 |
msgstr "数值比较运算符包括 ==#、!=#、<#、<=#、># 和 >=#。左侧和右侧的表达式必须计算为数值,但有两个例外:字符串值 \"None\"(未定义字段)和空字符串都会被视为数值 0。" |
| 900 |
|
| 901 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:450 |
| 902 |
msgid "Examples:" |
| 903 |
msgstr "例如:" |
| 904 |
|
| 905 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:452 |
| 906 |
msgid "" |
| 907 |
"``program: field('series') == 'foo'`` returns ``'1'`` if the book's series " |
| 908 |
"is `foo`, otherwise ``''``." |
| 909 |
msgstr "program: field('series') == 'foo' 如果书籍的丛书名为 foo,则返回 '1',否则返回空字符串('')。" |
| 910 |
|
| 911 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:453 |
| 912 |
msgid "" |
| 913 |
"``program: 'f.o' in field('series')`` returns ``'1'`` if the book's series " |
| 914 |
"matches the regular expression ``f.o`` (e.g., `foo`, `Off Onyx`, etc.), " |
| 915 |
"otherwise ``''``." |
| 916 |
msgstr "program: 'f.o' in field('series') 如果书籍的丛书名匹配正则表达式 f.o(例如:foo、Off Onyx 等),则返回 '1',否则返回空字符串('')。" |
| 917 |
|
| 918 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:454 |
| 919 |
msgid "" |
| 920 |
"``program: 'science' inlist $#genre`` returns ``'1'`` if any of the values " |
| 921 |
"retrieved from the book's genres match the regular expression ``science``, " |
| 922 |
"e.g., `Science`, `History of Science`, `Science Fiction` etc., otherwise " |
| 923 |
"``''``." |
| 924 |
msgstr "program: 'science' inlist $#genre 如果从书籍的“类型(genre)”列中获取的任何一个值匹配正则表达式 science,则返回 '1',否则返回空字符串('')。例如,它能匹配 Science、History of Science、Science Fiction等。" |
| 925 |
|
| 926 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:455 |
| 927 |
msgid "" |
| 928 |
"``program: '^science$' inlist $#genre`` returns ``'1'`` if any of the book's" |
| 929 |
" genres exactly match the regular expression ``^science$``, e.g., `Science`," |
| 930 |
" otherwise ``''``. The genres `History of Science` and `Science Fiction` " |
| 931 |
"don't match." |
| 932 |
msgstr "program: '^science$' inlist $#genre 如果书籍的“类型(genre)”列中有任何一项与正则表达式 ^science$ 完全匹配(例如 Science),则返回 '1',否则返回空字符串('')。这种情况下,History of Science 和 Science Fiction 将不会匹配。" |
| 933 |
|
| 934 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:456 |
| 935 |
msgid "" |
| 936 |
"``program: 'asimov' inlist $authors`` returns ``'1'`` if any author matches " |
| 937 |
"the regular expression ``asimov``, e.g., `Asimov, Isaac` or `Isaac Asimov`, " |
| 938 |
"otherwise ``''``." |
| 939 |
msgstr "program: 'asimov' inlist $authors 如果作者列表中的任何一位作者匹配正则表达式 asimov(例如 Asimov, Isaac 或 Isaac Asimov),则返回 '1',否则返回空字符串('')。" |
| 940 |
|
| 941 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:457 |
| 942 |
msgid "" |
| 943 |
"``program: 'asimov' inlist_field 'authors'`` returns ``'1'`` if any author " |
| 944 |
"matches the regular expression ``asimov``, e.g., `Asimov, Isaac` or `Isaac " |
| 945 |
"Asimov`, otherwise ``''``." |
| 946 |
msgstr "program: 'asimov' inlist_field 'authors' 如果作者列中的任何一位作者匹配正则表达式 asimov(例如 Asimov, Isaac 或 Isaac Asimov),则返回 '1',否则返回空字符串('')。" |
| 947 |
|
| 948 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:458 |
| 949 |
msgid "" |
| 950 |
"``program: 'asimov$' inlist_field 'authors'`` returns ``'1'`` if any author " |
| 951 |
"matches the regular expression ``asimov$``, e.g., `Isaac Asimov`, otherwise " |
| 952 |
"``''``. It doesn't match `Asimov, Isaac` because of the ``$`` anchor in the " |
| 953 |
"regular expression." |
| 954 |
msgstr "program: 'asimov$' inlist_field 'authors' 如果作者列中的任何一位作者匹配正则表达式 asimov$(例如 Isaac Asimov),则返回 '1',否则返回空字符串('')。由于正则表达式中使用了 $ 锚点,它不会匹配 Asimov, Isaac。" |
| 955 |
|
| 956 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:459 |
| 957 |
msgid "" |
| 958 |
"``program: if field('series') != 'foo' then 'bar' else 'mumble' fi`` returns" |
| 959 |
" ``'bar'`` if the book's series is not `foo`. Otherwise it returns " |
| 960 |
"``'mumble'``." |
| 961 |
msgstr "program: if field('series') != 'foo' then 'bar' else 'mumble' fi 如果书籍的丛书名不是 foo,则返回 'bar';否则返回 'mumble'。" |
| 962 |
|
| 963 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:460 |
| 964 |
msgid "" |
| 965 |
"``program: if field('series') == 'foo' || field('series') == '1632' then " |
| 966 |
"'yes' else 'no' fi`` returns ``'yes'`` if series is either `foo` or `1632`, " |
| 967 |
"otherwise ``'no'``." |
| 968 |
msgstr "program: if field('series') == 'foo' || field('series') == '1632' then 'yes' else 'no' fi 如果丛书名是 foo 或 1632,则返回 'yes',否则返回 'no'。" |
| 969 |
|
| 970 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:461 |
| 971 |
msgid "" |
| 972 |
"``program: if '^(foo|1632)$' in field('series') then 'yes' else 'no' fi`` " |
| 973 |
"returns ``'yes'`` if series is either `foo` or `1632`, otherwise ``'no'``." |
| 974 |
msgstr "program: if '^(foo|1632)$' in field('series') then 'yes' else 'no' fi 如果丛书名是 foo 或 1632,则返回 'yes',否则返回 'no'。" |
| 975 |
|
| 976 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:462 |
| 977 |
msgid "" |
| 978 |
"``program: if 11 > 2 then 'yes' else 'no' fi`` returns ``'no'`` because the " |
| 979 |
"``>`` operator does a lexical comparison." |
| 980 |
msgstr "program: if 11 > 2 then 'yes' else 'no' fi 返回 'no',因为 > 运算符执行的是词典顺序(字符串)比较。" |
| 981 |
|
| 982 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:463 |
| 983 |
msgid "" |
| 984 |
"``program: if 11 ># 2 then 'yes' else 'no' fi`` returns ``'yes'`` because " |
| 985 |
"the ``>#`` operator does a numeric comparison." |
| 986 |
msgstr "program: if 11 ># 2 then 'yes' else 'no' fi 返回 'yes',因为 ># 运算符执行的是数值比较。" |
| 987 |
|
| 988 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:465 |
| 989 |
msgid "**Functions in General Program Mode**" |
| 990 |
msgstr "**通用程序模式中的函数**" |
| 991 |
|
| 992 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:467 |
| 993 |
msgid "" |
| 994 |
"See :ref:`template_functions_reference` for the list of functions built into" |
| 995 |
" the template language." |
| 996 |
msgstr "关于模板语言内置的函数列表,请参阅:ref:`template_functions_reference` 。" |
| 997 |
|
| 998 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:471 |
| 999 |
msgid "" |
| 1000 |
"As opposed to :ref:`Single Function Mode <single_mode>`, in General Program " |
| 1001 |
"Mode you must specify the first parameter ``value``." |
| 1002 |
msgstr "与 :ref:`Single Function Mode<single_mode>不同,在通用程序模式下,你必须指定第一个参数 value。" |
| 1003 |
|
| 1004 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:472 |
| 1005 |
msgid "All parameters are expression_lists (see the grammar above)." |
| 1006 |
msgstr "所有参数均为 expression_lists(表达式列表,参见上文的语法说明)。" |
| 1007 |
|
| 1008 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:477 |
| 1009 |
msgid "More complex programs in template expressions - Template Program Mode" |
| 1010 |
msgstr "模板表达式中的复杂程序 —— 模板程序模式" |
| 1011 |
|
| 1012 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:479 |
| 1013 |
msgid "" |
| 1014 |
"`Template Program Mode` (`TPM`) is a blend of :ref:`General Program Mode " |
| 1015 |
"<general_mode>` and :ref:`Single Function Mode <single_mode>`. `TPM` differs" |
| 1016 |
" from Single Function Mode in that it permits writing template expressions " |
| 1017 |
"that refer to other metadata fields, use nested functions, modify variables," |
| 1018 |
" and do arithmetic. It differs from `General Program Mode` in that the " |
| 1019 |
"template is contained between ``{`` and ``}`` characters and doesn't begin " |
| 1020 |
"with the word ``program:``. The program portion of the template is a General" |
| 1021 |
" Program Mode expression list." |
| 1022 |
msgstr "“模板程序模式”(“TPM”) 是“通用程序模式 <general_mode>”和“单功能模式 <single_mode>”的混合。 “TPM”与单函数模式的不同之处在于它允许编写引用其他元数据字段的模板表达式、使用嵌套函数、修改变量和进行算术。 它与“通用程序模式”的不同之处在于,模板包含在“{”和“}”字符之间,并且不以单词“program:”开头。 模板的程序部分是通用程序模式表达式列表。" |
| 1023 |
|
| 1024 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:482 |
| 1025 |
msgid "" |
| 1026 |
"Example: assume you want a template to show the series for a book if it has " |
| 1027 |
"one, otherwise show the value of a custom field #genre. You cannot do this " |
| 1028 |
"in the :ref:`Single Function Mode <single_mode>` because you cannot make " |
| 1029 |
"reference to another metadata field within a template expression. In `TPM` " |
| 1030 |
"you can, as the following expression demonstrates::" |
| 1031 |
msgstr "示例:假设您希望模板显示一本书的系列,如果有,否则显示自定义字段 #genre 的值。 您无法在“单函数模式 <single_mode>”中执行此操作,因为您无法引用模板表达式中的另一个元数据字段。 在“TPM”中,您可以,如以下表达式所示:" |
| 1032 |
|
| 1033 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:487 |
| 1034 |
msgid "The example shows several things:" |
| 1035 |
msgstr "该示例展示了以下几点:" |
| 1036 |
|
| 1037 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:489 |
| 1038 |
msgid "" |
| 1039 |
"`TPM` is used if the expression begins with ``:'`` and ends with ``'}``. " |
| 1040 |
"Anything else is assumed to be in :ref:`Single Function Mode <single_mode>`." |
| 1041 |
msgstr "如果表达式以 :' 开头并以 '} 结尾,则使用 TPM(模板程序模式)。除此之外的任何内容都将被视为处于 :ref:`Single Function Mode<single_mode>`下" |
| 1042 |
|
| 1043 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:491 |
| 1044 |
msgid "" |
| 1045 |
"If the template contains a prefix and suffix, the expression ends with " |
| 1046 |
"``'|`` where the ``|`` is the delimiter for the prefix. Example::" |
| 1047 |
msgstr "如果模板包含前缀和后缀,则表达式以 '| 结尾,其中 | 是前缀的分隔符。示例如下::" |
| 1048 |
|
| 1049 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:495 |
| 1050 |
msgid "" |
| 1051 |
"Functions must be given all their arguments. For example, the standard " |
| 1052 |
"built-in functions must be given the initial parameter ``value``." |
| 1053 |
msgstr "调用函数时必须提供其所有参数。例如,标准内置函数必须被赋予初始参数 value。" |
| 1054 |
|
| 1055 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:496 |
| 1056 |
msgid "" |
| 1057 |
"The variable ``$`` is usable as the ``value`` argument and stands for the " |
| 1058 |
"value of the field named in the template, ``series`` in this case." |
| 1059 |
msgstr "变量 $ 可作为 value 参数使用,它代表模板中所指定字段的值(在本例中为 series 丛书字段)。" |
| 1060 |
|
| 1061 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:497 |
| 1062 |
msgid "white space is ignored and can be used anywhere within the expression." |
| 1063 |
msgstr "空格将被忽略,并可以用于表达式中的任何位置。" |
| 1064 |
|
| 1065 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:498 |
| 1066 |
msgid "" |
| 1067 |
"constant strings are enclosed in matching quotes, either ``'`` or ``\"``." |
| 1068 |
msgstr "常量字符串需封闭在成对的引号中,使用单引号 ' 或双引号 \" 均可。" |
| 1069 |
|
| 1070 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:500 |
| 1071 |
msgid "" |
| 1072 |
"In `TPM`, using ``{`` and ``}`` characters in string literals can lead to " |
| 1073 |
"errors or unexpected results because they confuse the template processor. It" |
| 1074 |
" tries to treat them as template expression boundaries, not characters. In " |
| 1075 |
"some but not all cases you can replace a ``{`` with ``[[`` and a ``}`` with " |
| 1076 |
"`]]`. Advice: if your program contains ``{`` and ``}`` characters then you " |
| 1077 |
"should use `General Program Mode`." |
| 1078 |
msgstr "在 TPM(模板程序模式)中,在字符串字面量中使用 { 和 } 字符可能会导致错误或意外结果,因为它们会干扰模板解析器。解析器会尝试将它们视为模板表达式的分隔边界,而不是普通字符。在某些(但非所有)情况下,你可以用 [[ 替换 {,用 ]] 替换 }。建议:如果你的程序包含 { 和 } 字符,则应使用通用程序模式。" |
| 1079 |
|
| 1080 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:505 |
| 1081 |
msgid "Python Template Mode" |
| 1082 |
msgstr "Python 模板模式" |
| 1083 |
|
| 1084 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:507 |
| 1085 |
msgid "" |
| 1086 |
"Python Template Mode (PTM) lets you write templates using native Python and " |
| 1087 |
"the `calibre API <https://manual.calibre-ebook.com/develop.html#api-" |
| 1088 |
"documentation-for-various-parts-of-calibre>`_. The database API will be of " |
| 1089 |
"most use; further discussion is beyond the scope of this manual. PTM " |
| 1090 |
"templates are faster and can do more complicated operations but you must " |
| 1091 |
"know how to write code in Python using the calibre API." |
| 1092 |
msgstr "Python 模板模式 (PTM) 允许你使用原生 Python 语言和 `calibre API <https://manual.calibre-ebook.com/develop.html#api-documentation-for-various-parts-of-calibre>`_来编写模板。其中数据库 API(database API)最为常用;更深入的讨论超出了本手册的范围。PTM 模板运行速度更快,且能执行更复杂的逻辑操作,但前提是你必须了解如何使用 calibre API 编写 Python 代码。" |
| 1093 |
|
| 1094 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:509 |
| 1095 |
msgid "A PTM template begins with:" |
| 1096 |
msgstr "PTM 模板以以下内容开头:" |
| 1097 |
|
| 1098 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:527 |
| 1099 |
msgid "" |
| 1100 |
"You can add the above text to your template using the context menu, usually " |
| 1101 |
"accessed with a right click. The comments are not significant and can be " |
| 1102 |
"removed. You must use python indenting." |
| 1103 |
msgstr "你可以通过右键点击调出的上下文菜单(右键菜单)将上述文本添加到模板中。其中的注释并不重要,可以删除。但你必须使用 Python 缩进规范。" |
| 1104 |
|
| 1105 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:529 |
| 1106 |
msgid "" |
| 1107 |
"The context object supports ``str(context)`` that returns a string of the " |
| 1108 |
"context's contents, and ``context.attributes`` that returns a list of the " |
| 1109 |
"attribute names in the context." |
| 1110 |
msgstr "context 对象支持使用 str(context) 来返回其包含内容的字符串,同时也支持使用 context.attributes 来返回该上下文中所有属性名称的列表。" |
| 1111 |
|
| 1112 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:531 |
| 1113 |
msgid "" |
| 1114 |
"The ``context.funcs`` attribute allows calling Built-in and User template " |
| 1115 |
"functions, and Stored GPM/Python templates, so that you can execute them " |
| 1116 |
"directly in your code. The functions are retrieved using their names. If the" |
| 1117 |
" name conflicts with a Python keyword, add an underscore to the end of the " |
| 1118 |
"name. Examples:" |
| 1119 |
msgstr "``context.funcs`` 属性允许调用内置和用户模板函数以及存储的 GPM/Python 模板,以便您可以直接在代码中执行它们。 使用函数的名称来检索函数。 如果名称与 Python 关键字冲突,请在名称末尾添加下划线。 例子:" |
| 1120 |
|
| 1121 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:538 |
| 1122 |
msgid "" |
| 1123 |
"Here is an example of a PTM template that produces a list of all the authors" |
| 1124 |
" for a series. The list is stored in a `Column built from other columns, " |
| 1125 |
"behaves like tags`. It shows in :guilabel:`Book details` and has the " |
| 1126 |
":guilabel:`on separate lines` checked (in :guilabel:`Preferences->Look & " |
| 1127 |
"feel->Book details`). That option requires the list to be comma-separated. " |
| 1128 |
"To satisfy that requirement the template converts commas in author names to " |
| 1129 |
"semicolons then builds a comma-separated list of authors. The authors are " |
| 1130 |
"then sorted, which is why the template uses author_sort." |
| 1131 |
msgstr "以下是 PTM 模板的示例,该模板生成一个系列的所有作者的列表。 该列表存储在“从其他列构建的列,行为类似于标签”中。 它显示在“书籍详细信息”中,并选中“在单独的行上”(在“首选项->外观->书籍详细信息”中)。 该选项要求列表以逗号分隔。 为了满足该要求,模板将作者姓名中的逗号转换为分号,然后构建以逗号分隔的作者列表。 然后对作者进行排序,这就是模板使用author_sort的原因。" |
| 1132 |
|
| 1133 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:559 |
| 1134 |
msgid "The output in :guilabel:`Book details` looks like this:" |
| 1135 |
msgstr "“:guilabel:图书详情”面板中的输出效果如下:" |
| 1136 |
|
| 1137 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:561 |
| 1138 |
msgid "E-book conversion dialog" |
| 1139 |
msgstr "电子书转换对话" |
| 1140 |
|
| 1141 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:569 |
| 1142 |
msgid "Templates and URLs" |
| 1143 |
msgstr "模板与 URL" |
| 1144 |
|
| 1145 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:571 |
| 1146 |
msgid "You can use templates to construct URLs. Two cases are described here:" |
| 1147 |
msgstr "你可以使用模板来构建 URL。这里描述了两种情况:" |
| 1148 |
|
| 1149 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:573 |
| 1150 |
msgid "Custom column :guilabel:`Book details` search URLs" |
| 1151 |
msgstr "自定义列:“:guilabel:图书详情”搜索 URL" |
| 1152 |
|
| 1153 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:574 |
| 1154 |
msgid "The calibre URL scheme" |
| 1155 |
msgstr "calibre URL协议" |
| 1156 |
|
| 1157 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:576 |
| 1158 |
msgid "**Custom column book details search URLs**" |
| 1159 |
msgstr "**自定义列:图书详情搜索 URL**" |
| 1160 |
|
| 1161 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:578 |
| 1162 |
msgid "" |
| 1163 |
"When you create a custom column you can provide a URL to be used in " |
| 1164 |
":guilabel:`Book details` using a template. For example, if you have a custom" |
| 1165 |
" column for `Translators` you can define a URL to take you to a site for " |
| 1166 |
"translators. Book details search URLs can be provided for `Text`, " |
| 1167 |
"`Enumerated`, `Series`, and `Column built from other column` column types." |
| 1168 |
msgstr "当你创建自定义列时,可以使用模板提供一个用于“:guilabel:图书详情”面板的 URL。例如,如果你有一个名为“译者”(Translators)的自定义列,你可以定义一个 URL,点击后跳转到某个译者相关的网站。图书详情搜索 URL 适用于“文本”(Text)、“枚举”(Enumerated)、“丛书”(Series)以及“从其他列构建的列”(Column built from other column)等列类型。" |
| 1169 |
|
| 1170 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:580 |
| 1171 |
msgid "" |
| 1172 |
"When an item with a `search template` is clicked in :guilabel:`Book details`" |
| 1173 |
" the template is evaluated. It is provided the normal book metadata. It is " |
| 1174 |
"also provided three additional fields:" |
| 1175 |
msgstr "当在“:guilabel:图书详情”面板中点击一个带有“搜索模板”的项目时,该模板将被执行。系统会为其提供常规的书籍元数据,此外还会额外提供三个字段:" |
| 1176 |
|
| 1177 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:582 |
| 1178 |
msgid "``item_value``: the value of the clicked item." |
| 1179 |
msgstr "item_value:被点击项目的具体内容。" |
| 1180 |
|
| 1181 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:583 |
| 1182 |
msgid "" |
| 1183 |
"``item_value_quoted``: the value of clicked item, URL-encoded. Special " |
| 1184 |
"characters are escaped to make them valid in URLs and spaces are replaced by" |
| 1185 |
" ``'+'`` (plus) signs." |
| 1186 |
msgstr "item_value_quoted:被点击项目的 URL 编码值。特殊字符将被转义以确保在 URL 中有效,空格则会被替换为 '+'(加号)。" |
| 1187 |
|
| 1188 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:584 |
| 1189 |
msgid "" |
| 1190 |
"``item_value_no_plus``: the value of clicked item, URL-encoded. Special " |
| 1191 |
"characters are escaped to make them valid in URLs and spaces are replaced by" |
| 1192 |
" the ``%20``, not plus." |
| 1193 |
msgstr "item_value_no_plus:被点击项目的 URL 编码值。特殊字符将被转义以确保在 URL 中有效,空格将被替换为 %20,而不是加号。" |
| 1194 |
|
| 1195 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:586 |
| 1196 |
msgid "" |
| 1197 |
"There are several ways to construct the URL. The following use Wikipedia as " |
| 1198 |
"an example." |
| 1199 |
msgstr "构建 URL 有多种方式。以下以维基百科(Wikipedia)为例。" |
| 1200 |
|
| 1201 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:588 |
| 1202 |
msgid "The simplest is a basic template::" |
| 1203 |
msgstr "最简单的是基础模板::" |
| 1204 |
|
| 1205 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:592 |
| 1206 |
msgid "" |
| 1207 |
"In some cases you might want to do more processing. There are four template " |
| 1208 |
"functions you can use, depending on the complexity of the processing." |
| 1209 |
msgstr "在某些情况下,你可能希望进行更多的处理。根据处理过程的复杂程度,有四种模板函数可供使用。" |
| 1210 |
|
| 1211 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:599 |
| 1212 |
msgid "" |
| 1213 |
"For example, assume you have a custom column `Translators` " |
| 1214 |
"(``#translators``) where the names are `Last name, First name`. You might " |
| 1215 |
"need to convert the name to `First name Last name` when creating the URL. " |
| 1216 |
"You can use the :ref:`ff_make_url` function to do this::" |
| 1217 |
msgstr "例如,假设你有一个名为‘译者’(#translators)的自定义列,其中的姓名格式为‘姓, 名’。在创建 URL 时,你可能需要将姓名转换为‘名 姓’。你可以使用 :ref:ff_make_url 函数来实现这一点::" |
| 1218 |
|
| 1219 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:603 |
| 1220 |
msgid "" |
| 1221 |
"If we assume that the translator's name is `Boy-Żeleński, Tadeusz` then the " |
| 1222 |
"above template produces the link::" |
| 1223 |
msgstr "假设译者的姓名是 Boy-Żeleński, Tadeusz,那么上述模板将生成如下链接::" |
| 1224 |
|
| 1225 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:607 |
| 1226 |
msgid "" |
| 1227 |
"Note that the person's first name is now first, the space is now a plus, and" |
| 1228 |
" that the non-English characters in the last name are URL-encoded." |
| 1229 |
msgstr "请注意,现在名字(First name)排在了前面,空格被替换成了加号(+),并且姓氏中的非英语字符已进行了 URL 编码。" |
| 1230 |
|
| 1231 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:609 |
| 1232 |
msgid "" |
| 1233 |
"The functions :ref:`ff_make_url_extended`, :ref:`ff_query_string`, and " |
| 1234 |
":ref:`ff_encode_for_url` might be useful depending upon any additional " |
| 1235 |
"processing complexity." |
| 1236 |
msgstr "根据后续处理的复杂程度, :ref:`ff_make_url_extended`, :ref:`ff_query_string`, 以及 :ref:`ff_encode_for_url` 这些函数可能也会非常有用。" |
| 1237 |
|
| 1238 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:611 |
| 1239 |
msgid "**The calibre URL scheme**" |
| 1240 |
msgstr "**calibre URL协议**" |
| 1241 |
|
| 1242 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:613 |
| 1243 |
msgid "" |
| 1244 |
"Calibre supports several different URLs to navigate your calibre libraries. " |
| 1245 |
"This section shows how to use templates to construct some of the URLs. See " |
| 1246 |
":doc:`url_scheme` for details on the URLs available." |
| 1247 |
msgstr "Calibre 支持多种不同的 URL 用于导航你的 Calibre 书库。本节将展示如何使用模板来构建其中的部分 URL。有关可用 URL 的详细信息,请参阅 :doc:`url_scheme` 。" |
| 1248 |
|
| 1249 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:616 |
| 1250 |
msgid "Switch to a specific library. The syntax of this URL is::" |
| 1251 |
msgstr "切换到特定的书库。此 URL 的语法如下::" |
| 1252 |
|
| 1253 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:620 |
| 1254 |
msgid "" |
| 1255 |
"``Library_Name`` must be replaced with the name of the calibre library you " |
| 1256 |
"wish to open. The library name is shown in the title bar of the window. It " |
| 1257 |
"is a simple name, not the file path to the library. You must spell it as " |
| 1258 |
"shown in the title bar, including letter case. The character ``_`` " |
| 1259 |
"(underscore) stands for the current library. If the name contains any spaces" |
| 1260 |
" or special characters then it must be hex encoded using the " |
| 1261 |
":ref:`ff_to_hex` function, as in the following example::" |
| 1262 |
msgstr "Library_Name 必须替换为你希望打开的 Calibre 书库的名称。书库名称显示在窗口的标题栏中。它是一个简单的名称,而不是书库的文件路径。你必须按照标题栏中显示的名称书写,包括字母的大小写。字符 _(下划线)代表当前书库。如果名称包含任何空格或特殊字符,则必须使用 :ref:ff_to_hex 函数进行十六进制编码,如下例所示::" |
| 1263 |
|
| 1264 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:628 |
| 1265 |
msgid "The template generates the URL::" |
| 1266 |
msgstr "该模板将生成 URL::" |
| 1267 |
|
| 1268 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:632 |
| 1269 |
msgid "" |
| 1270 |
"You can replace the ``current_library_name()`` function with the actual name" |
| 1271 |
" of the library, as in::" |
| 1272 |
msgstr "你可以将 current_library_name() 函数替换为书库的实际名称,例如::" |
| 1273 |
|
| 1274 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:636 |
| 1275 |
msgid "" |
| 1276 |
"Links to show books. These links select a book in the calibre library. The " |
| 1277 |
"syntax for this URL is::" |
| 1278 |
msgstr "显示书籍的链接。这些链接用于在 Calibre 书库中选中某本书。此 URL 的语法如下::" |
| 1279 |
|
| 1280 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:640 |
| 1281 |
msgid "" |
| 1282 |
"The ``book id`` is the numeric calibre id for the book, available to " |
| 1283 |
"templates as ``$id``. As above, the library name might need to be hex " |
| 1284 |
"encoded. Here is an example::" |
| 1285 |
msgstr "book id 是 Calibre 为书籍分配的数字 ID,在模板中可以通过 $id 获取。与前文相同,书库名称可能需要进行十六进制编码。示例如下::" |
| 1286 |
|
| 1287 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:645 |
| 1288 |
msgid "It produces the URL::" |
| 1289 |
msgstr "它生成如下的 URL::" |
| 1290 |
|
| 1291 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:649 |
| 1292 |
msgid "" |
| 1293 |
"Searching for books. These links search for books in the specified calibre " |
| 1294 |
"library. The syntax for this URL is::" |
| 1295 |
msgstr "搜索书籍。这些链接用于在指定的 Calibre 书库中搜索书籍。此 URL 的语法如下::" |
| 1296 |
|
| 1297 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:654 |
| 1298 |
msgid "" |
| 1299 |
"where `query` is any valid calibre search expression. You must hex encode " |
| 1300 |
"any query containing spaces or special characters, which generally means all" |
| 1301 |
" of them. For example, the calibre search expression for searching for a " |
| 1302 |
"hierarchical tag beginning with 'AA' is ``tags:\"=.AA\"``. This template " |
| 1303 |
"constructs a search URL for that expression::" |
| 1304 |
msgstr "其中 query 是任何有效的 Calibre 搜索表达式。如果查询内容包含空格或特殊字符(通常所有查询都包含),则必须进行十六进制编码。例如,搜索以‘AA’开头的层级标签,其 Calibre 搜索表达式为 tags:\"=.AA\"。以下模板为该表达式构建了一个搜索 URL::" |
| 1305 |
|
| 1306 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:660 |
| 1307 |
msgid "The resulting URL is::" |
| 1308 |
msgstr "生成的 URL 如下::" |
| 1309 |
|
| 1310 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:664 |
| 1311 |
msgid "" |
| 1312 |
"Here is an example of the same URL built using the " |
| 1313 |
":ref:``ff_make_url_extended`` function instead of :ref:`ff_strcat`::" |
| 1314 |
msgstr "以下是使用:ref:``ff_make_url_extended`` 函数代替 :ref:`ff_strcat` 构建相同 URL 的示例::" |
| 1315 |
|
| 1316 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:669 |
| 1317 |
msgid "" |
| 1318 |
"Open a book details window on a book in some library. The syntax for this " |
| 1319 |
"URL is::" |
| 1320 |
msgstr "在某个书库中打开书籍详情窗口。此 URL 的语法如下::" |
| 1321 |
|
| 1322 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:673 |
| 1323 |
msgid "An example template is::" |
| 1324 |
msgstr "示例模板如下::" |
| 1325 |
|
| 1326 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:677 |
| 1327 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:694 |
| 1328 |
msgid "which produces the URL::" |
| 1329 |
msgstr "生成如下的 URL::" |
| 1330 |
|
| 1331 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:681 |
| 1332 |
msgid "" |
| 1333 |
"Open the notes associated with an author/series/etc. The syntax of the URL " |
| 1334 |
"is::" |
| 1335 |
msgstr "打开与作者、丛书等相关联的备注。此 URL 的语法如下::" |
| 1336 |
|
| 1337 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:686 |
| 1338 |
msgid "" |
| 1339 |
"``Field_Name`` is the lookup name of the field. If the field is a custom " |
| 1340 |
"column then replace the ``#`` character with an underscore (``_``). " |
| 1341 |
"``Item_Id`` is the internal numeric ID of the value in the field. There " |
| 1342 |
"isn't a template function that returns the ``Item_Id``, so templates will " |
| 1343 |
"normally use the second form, ``Hex_Encoded_Item_Name``. Here is a sample " |
| 1344 |
"template that opens the note for the person ``Boy-Żeleński, Tadeusz`` in the" |
| 1345 |
" field ``#authtest``::" |
| 1346 |
msgstr "Field_Name 是该字段的查找名称(Lookup name)。如果该字段是自定义列,请将 # 字符替换为下划线(_)。Item_Id 是该字段值在内部的数字 ID。由于目前没有返回 Item_Id 的模板函数,因此模板通常使用第二种形式,即 Hex_Encoded_Item_Name(经十六进制编码的项目名称)。以下是一个示例模板,用于打开 #authtest 字段中名为 Boy-Żeleński, Tadeusz 这一作者的备注::" |
| 1347 |
|
| 1348 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:700 |
| 1349 |
msgid "Stored templates" |
| 1350 |
msgstr "保存的模板" |
| 1351 |
|
| 1352 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:702 |
| 1353 |
msgid "" |
| 1354 |
"Both :ref:`General Program Mode <general_mode>` and :ref:`Python Template " |
| 1355 |
"Mode <python_mode>` support saving templates and calling those templates " |
| 1356 |
"from another template, much like calling stored functions. You save " |
| 1357 |
"templates using :guilabel:`Preferences->Advanced->Template functions`. More " |
| 1358 |
"information is provided in that dialog. You call a template the same way you" |
| 1359 |
" call a function, passing positional arguments if desired. An argument can " |
| 1360 |
"be any expression. Examples of calling a template, assuming the stored " |
| 1361 |
"template is named ``foo``:" |
| 1362 |
msgstr "“通用程序模式 <general_mode>”和“Python 模板模式 <python_mode>”都支持保存模板并从另一个模板调用这些模板,就像调用存储的函数一样。 您可以使用“首选项->高级->模板功能”保存模板。 该对话框中提供了更多信息。 您可以像调用函数一样调用模板,并根据需要传递位置参数。 参数可以是任何表达式。 调用模板的示例,假设存储的模板名为“foo”:" |
| 1363 |
|
| 1364 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:704 |
| 1365 |
msgid "``foo()`` -- call the template passing no arguments." |
| 1366 |
msgstr "foo() —— 调用该模板函数且不传递任何参数。" |
| 1367 |
|
| 1368 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:705 |
| 1369 |
msgid "" |
| 1370 |
"``foo(a, b)`` call the template passing the values of the two variables " |
| 1371 |
"``a`` and ``b``." |
| 1372 |
msgstr "foo(a, b) —— 调用该模板函数并传递变量 a 和 b 的值。" |
| 1373 |
|
| 1374 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:706 |
| 1375 |
msgid "" |
| 1376 |
"``foo(if field('series') then field('series_index') else 0 fi)`` -- if the " |
| 1377 |
"book has a ``series`` then pass the ``series_index``, otherwise pass the " |
| 1378 |
"value ``0``." |
| 1379 |
msgstr "foo(if field('series') then field('series_index') else 0 fi) —— 如果书籍有“丛书,则传递其“丛书编号”(series_index);否则传递值 0。" |
| 1380 |
|
| 1381 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:708 |
| 1382 |
msgid "" |
| 1383 |
"In GPM you retrieve the arguments passed in the call to the stored template " |
| 1384 |
"using the ``arguments`` function. It both declares and initializes local " |
| 1385 |
"variables, effectively parameters. The variables are positional; they get " |
| 1386 |
"the value of the parameter given in the call in the same position. If the " |
| 1387 |
"corresponding parameter is not provided in the call then ``arguments`` " |
| 1388 |
"assigns that variable the provided default value. If there is no default " |
| 1389 |
"value then the variable is set to the empty string. For example, the " |
| 1390 |
"following ``arguments`` function declares 2 variables, ``key``, " |
| 1391 |
"``alternate``::" |
| 1392 |
msgstr "在 GPM 中,您可以使用“arguments”函数检索在调用存储模板时传递的参数。 它声明并初始化局部变量,即有效的参数。 变量是位置变量; 他们在同一位置获取调用中给出的参数值。 如果调用中未提供相应的参数,则“arguments”会为该变量分配提供的默认值。 如果没有默认值,则该变量将设置为空字符串。 例如,以下“arguments”函数声明 2 个变量“key”、“alternate”:" |
| 1393 |
|
| 1394 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:712 |
| 1395 |
msgid "Examples, again assuming the stored template is named ``foo``:" |
| 1396 |
msgstr "示例(同样假设存档模板名称为 foo):" |
| 1397 |
|
| 1398 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:714 |
| 1399 |
msgid "" |
| 1400 |
"``foo('#myseries')`` -- argument ``key`` is assigned the value " |
| 1401 |
"``'myseries'`` and the argument ``alternate`` is assigned the default value " |
| 1402 |
"``'series'``." |
| 1403 |
msgstr "foo('#myseries') —— 参数 key 被赋值为 'myseries',而参数 alternate 则被赋予默认值 'series'。" |
| 1404 |
|
| 1405 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:715 |
| 1406 |
msgid "" |
| 1407 |
"``foo('series', '#genre')`` the variable ``key`` is assigned the value " |
| 1408 |
"``'series'`` and the variable ``alternate`` is assigned the value " |
| 1409 |
"``'#genre'``." |
| 1410 |
msgstr "foo('series', '#genre') —— 变量 key 被赋值为 'series',变量 alternate 被赋值为 '#genre'。" |
| 1411 |
|
| 1412 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:716 |
| 1413 |
msgid "" |
| 1414 |
"``foo()`` -- the variable ``key`` is assigned the empty string and the " |
| 1415 |
"variable ``alternate`` is assigned the value ``'series'``." |
| 1416 |
msgstr "foo() —— 变量 key 被赋值为空字符串,而变量 alternate 则被赋予值 'series'。" |
| 1417 |
|
| 1418 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:718 |
| 1419 |
msgid "" |
| 1420 |
"In PTM the arguments are passed in the ``arguments`` parameter, which is a " |
| 1421 |
"list of strings. There isn't any way to specify default values. You must " |
| 1422 |
"check the length of the ``arguments`` list to be sure that the number of " |
| 1423 |
"arguments is what you expect." |
| 1424 |
msgstr "在PTM中,参数在“arguments”参数中传递,该参数是字符串列表。没有任何方法可以指定默认值。您必须检查“参数”列表的长度,以确保参数的数量符合您的期望。" |
| 1425 |
|
| 1426 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:720 |
| 1427 |
msgid "" |
| 1428 |
"An easy way to test stored templates is using the ``Template tester`` " |
| 1429 |
"dialog. For ease of access give it a keyboard shortcut in " |
| 1430 |
":guilabel:`Preferences->Advanced->Keyboard shortcuts->Template tester`. " |
| 1431 |
"Giving the ``Stored templates`` dialog a shortcut will help switching more " |
| 1432 |
"rapidly between the tester and editing the stored template's source code." |
| 1433 |
msgstr "测试存储模板的一种简单方法是使用“模板测试器”对话框。 为了便于访问,请在“首选项->高级->键盘快捷键->模板测试器”中为其提供键盘快捷键。 为“存储的模板”对话框提供快捷方式将有助于在测试器和编辑存储的模板的源代码之间更快地切换。" |
| 1434 |
|
| 1435 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:723 |
| 1436 |
msgid "Providing additional information to templates" |
| 1437 |
msgstr "为模板提供额外信息" |
| 1438 |
|
| 1439 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:725 |
| 1440 |
msgid "" |
| 1441 |
"A developer can choose to pass additional information to the template " |
| 1442 |
"processor, such as application-specific book metadata or information about " |
| 1443 |
"what the processor is being asked to do. A template can access this " |
| 1444 |
"information and use it during the evaluation." |
| 1445 |
msgstr "开发人员可以选择将附加信息传递给模板处理器,例如应用程序特定的书籍元数据或有关处理器被要求执行什么的信息。模板可以访问此信息并在评估期间使用它。" |
| 1446 |
|
| 1447 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:727 |
| 1448 |
msgid "**Developer: how to pass additional information**" |
| 1449 |
msgstr "**开发者:如何传递额外信息**" |
| 1450 |
|
| 1451 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:729 |
| 1452 |
msgid "" |
| 1453 |
"The additional information is a Python dictionary containing pairs " |
| 1454 |
"``variable_name: variable_value`` where the values must be strings. The " |
| 1455 |
"template can access the dictionary, creating template local variables named " |
| 1456 |
"``variable_name`` containing the value ``variable_value``. The user cannot " |
| 1457 |
"change the name so it is best to use names that won't collide with other " |
| 1458 |
"template local variables, for example by prefixing the name with an " |
| 1459 |
"underscore." |
| 1460 |
msgstr "附加信息是一个包含“变量名:变量值”对的 Python 字典,其中值必须是字符串。 模板可以访问字典,创建名为“variable_name”的模板局部变量,其中包含值“variable_value”。 用户无法更改名称,因此最好使用不会与其他模板局部变量冲突的名称,例如在名称前添加下划线。" |
| 1461 |
|
| 1462 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:731 |
| 1463 |
msgid "" |
| 1464 |
"This dictionary is passed to the template processor (the ``formatter``) " |
| 1465 |
"using the named parameter ``global_vars=your_dict``. The full method " |
| 1466 |
"signature is::" |
| 1467 |
msgstr "该字典通过命名参数 global_vars=your_dict 传递给模板处理器(即 formatter)。完整的方法签名如下::" |
| 1468 |
|
| 1469 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:739 |
| 1470 |
msgid "**Template writer: how to access the additional information**" |
| 1471 |
msgstr "**模板编写者:如何访问额外信息**" |
| 1472 |
|
| 1473 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:741 |
| 1474 |
msgid "" |
| 1475 |
"You access the additional information (the ``globals`` dictionary) in a " |
| 1476 |
"template using the template function::" |
| 1477 |
msgstr "您可以在模板中使用以下模板函数来访问额外信息(即 globals 字典)::" |
| 1478 |
|
| 1479 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:745 |
| 1480 |
msgid "" |
| 1481 |
"where ``id`` is any legal variable name. This function checks whether the " |
| 1482 |
"additional information provided by the developer contains the name. If it " |
| 1483 |
"does then the function assigns the provided value to a template local " |
| 1484 |
"variable with that name. If the name is not in the additional information " |
| 1485 |
"and if an ``expression`` is provided, the ``expression`` is evaluated and " |
| 1486 |
"the result is assigned to the local variable. If neither a value nor an " |
| 1487 |
"expression is provided, the function assigns the empty string (``''``) to " |
| 1488 |
"the local variable." |
| 1489 |
msgstr "其中“id”是任何合法的变量名称。 该函数检查开发者提供的附加信息中是否包含该名称。 如果是,则该函数将提供的值分配给具有该名称的模板局部变量。 如果附加信息中没有该名称,并且提供了“表达式”,则计算“表达式”并将结果分配给局部变量。 如果既没有提供值也没有提供表达式,函数会将空字符串 (``''``) 分配给局部变量。" |
| 1490 |
|
| 1491 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:747 |
| 1492 |
msgid "" |
| 1493 |
"A template can set a value in the ``globals`` dictionary using the template " |
| 1494 |
"function::" |
| 1495 |
msgstr "模板可以使用以下模板函数在 globals 字典中设置值::" |
| 1496 |
|
| 1497 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:751 |
| 1498 |
msgid "" |
| 1499 |
"This function sets the ``globals`` dictionary key:value pair ``id:value`` " |
| 1500 |
"where ``value`` is the value of the template local variable ``id``. If that " |
| 1501 |
"local variable doesn't exist then ``value`` is set to the result of " |
| 1502 |
"evaluating ``expression``." |
| 1503 |
msgstr "此函数用于设置“全局范围”词典,key:value配对``id:value`` ,其中“value”是模板局部变量“id”的值。如果该局部变量不存在,则将“value”设置为“表达式”的求值结果。" |
| 1504 |
|
| 1505 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:754 |
| 1506 |
msgid "Notes on the difference between modes" |
| 1507 |
msgstr "关于不同模式之间差异的注释" |
| 1508 |
|
| 1509 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:756 |
| 1510 |
msgid "" |
| 1511 |
"The three program modes, :ref:`Single Function Mode <single_mode>` (SFM), " |
| 1512 |
":ref:`Template Program Mode <template_mode>` (`TPM`), and :ref:`General " |
| 1513 |
"Program Mode <general_mode>` (`GPM`), work differently. SFM is intended to " |
| 1514 |
"be 'simple' so it hides a lot of programming language bits." |
| 1515 |
msgstr "三种程序模式::ref:`Single Function Mode <single_mode>` (SFM), :ref:`Template Program Mode<template_mode> ` (`TPM`), 以及 :ref:`General Program Mode<general_mode> ` (`GPM`),的工作方式各不相同。SFM 旨在保持‘简单’,因此它隐藏了许多编程语言的细节。" |
| 1516 |
|
| 1517 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:758 |
| 1518 |
msgid "Differences:" |
| 1519 |
msgstr "差异:" |
| 1520 |
|
| 1521 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:760 |
| 1522 |
msgid "" |
| 1523 |
"In SFM the value of the column is always passed as an 'invisible' first " |
| 1524 |
"argument to a function included in the template." |
| 1525 |
msgstr "在单函数模式(SFM)中,列的值总是作为‘不可见’的第一个参数,传递给模板中所包含的函数。" |
| 1526 |
|
| 1527 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:761 |
| 1528 |
msgid "" |
| 1529 |
"SFM doesn't support the difference between variables and strings; all values" |
| 1530 |
" are strings." |
| 1531 |
msgstr "SFM 不支持变量与字符串之间的区别;所有值都被视为字符串。" |
| 1532 |
|
| 1533 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:762 |
| 1534 |
msgid "" |
| 1535 |
"The following SFM template returns either the series name or the string \"no" |
| 1536 |
" series\"::" |
| 1537 |
msgstr "以下 SFM 模板会返回丛书名称,或者返回字符串“no series”::" |
| 1538 |
|
| 1539 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:766 |
| 1540 |
msgid "The equivalent template in `TPM` is ::" |
| 1541 |
msgstr "在 TPM(模板程序模式)中,等效的模板为::" |
| 1542 |
|
| 1543 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:770 |
| 1544 |
msgid "The equivalent template in `GPM` is::" |
| 1545 |
msgstr "在 GPM(通用程序模式)中,等效的模板为::" |
| 1546 |
|
| 1547 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:774 |
| 1548 |
msgid "" |
| 1549 |
"The first argument to ``ifempty`` is the value of the field ``series``. The " |
| 1550 |
"second argument is the string ``no series``. In SFM the first argument, the " |
| 1551 |
"value of the field, is automatically passed (the invisible argument)." |
| 1552 |
msgstr "ifempty 的第一个参数是 series 字段的值。第二个参数是字符串 no series。在单函数模式(SFM)中,第一个参数(即字段的值)是自动传递的(即不可见参数)。" |
| 1553 |
|
| 1554 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:775 |
| 1555 |
msgid "" |
| 1556 |
"Several template functions, for example ``booksize()`` and " |
| 1557 |
"``current_library_name()``, take no arguments. Because of the 'invisible " |
| 1558 |
"argument' you cannot use these functions in SFM." |
| 1559 |
msgstr "一些模板函数(例如 booksize() 和 current_library_name())不接受任何参数。由于存在‘不可见参数’,您无法在单函数模式(SFM)中使用这些函数。" |
| 1560 |
|
| 1561 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:776 |
| 1562 |
msgid "" |
| 1563 |
"Nested functions, where a function calls another function to compute an " |
| 1564 |
"argument, cannot be used in SFM. For example this template, intended to " |
| 1565 |
"return the first 5 characters of the series value uppercased, won't work in " |
| 1566 |
"SFM::" |
| 1567 |
msgstr "嵌套函数,指其中一个函数调用另一个函数来计算参数,不能在SFM中使用。例如,此模板旨在返回升级后的系列值的前5个字符,在SFM中不起作用:" |
| 1568 |
|
| 1569 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:780 |
| 1570 |
msgid "" |
| 1571 |
"`TPM` and `GPM` support nested functions. The above template in `TPM` would " |
| 1572 |
"be::" |
| 1573 |
msgstr "TPM 和 GPM 支持嵌套函数。上述模板在 TPM(模板程序模式)中应为::" |
| 1574 |
|
| 1575 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:784 |
| 1576 |
msgid "In `GPM` it would be::" |
| 1577 |
msgstr "在 GPM(通用程序模式)中,它应为::" |
| 1578 |
|
| 1579 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:788 |
| 1580 |
msgid "" |
| 1581 |
"As noted in the above :ref:`Template Program Mode <template_mode>` section, " |
| 1582 |
"using ``{`` and ``}`` characters in `TPM` string literals can lead to errors" |
| 1583 |
" or unexpected results because they confuse the template processor. It tries" |
| 1584 |
" to treat them as template boundaries, not characters. In some but not all " |
| 1585 |
"cases you can replace a ``{`` with ``[[`` and a ``}`` with `]]`. Generally, " |
| 1586 |
"if your program contains ``{`` and ``}`` characters then you should use " |
| 1587 |
"`General Program Mode`." |
| 1588 |
msgstr "如上面“模板程序模式 1”部分所述,在“TPM”字符串文字中使用“{”和“}”字符可能会导致错误或意外结果,因为它们会混淆模板处理器。 它尝试将它们视为模板边界,而不是字符。 在某些情况下,但不是所有情况下,您可以将 ``{`` 替换为 ``[[`` ,将 ``}`` 替换为 `]]` 。 一般来说,如果您的程序包含“{”和“}”字符,那么您应该使用“通用程序模式”。" |
| 1589 |
|
| 1590 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:792 |
| 1591 |
msgid "User-defined Python template functions" |
| 1592 |
msgstr "用户自定义 Python 模板函数" |
| 1593 |
|
| 1594 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:794 |
| 1595 |
msgid "" |
| 1596 |
"You can add your own Python functions to the template processor. Such " |
| 1597 |
"functions can be used in any of the three template programming modes. The " |
| 1598 |
"functions are added by going to :guilabel:`Preferences -> Advanced -> " |
| 1599 |
"Template functions`. Instructions are shown in that dialog. Note that you " |
| 1600 |
"can use `Python Templates` for a similar purpose. As calling user-defined " |
| 1601 |
"functions is faster than calling a Python template, user-defined functions " |
| 1602 |
"might be more efficient depending on the complexity of what the function or " |
| 1603 |
"template does." |
| 1604 |
msgstr "您可以向模板处理器添加自定义的 Python 函数。此类函数可用于三种模板编程模式中的任何一种。通过进入 :guilabel:首选项 -> 高级 -> 模板函数 即可添加这些函数。该对话框中会显示具体的说明。请注意,您也可以出于类似目的使用 Python 模板。由于调用用户自定义函数的执行速度比调用 Python 模板更快,因此根据函数或模板逻辑的复杂程度,用户自定义函数可能会更加高效。" |
| 1605 |
|
| 1606 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:797 |
| 1607 |
msgid "Special notes for using templates in different contexts" |
| 1608 |
msgstr "在不同语境下使用模板的特别说明" |
| 1609 |
|
| 1610 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:799 |
| 1611 |
msgid "" |
| 1612 |
"In the GUI (:guilabel:`Columns made from other columns` and " |
| 1613 |
":guilabel:`Template searches`):" |
| 1614 |
msgstr "在GUI中 (:guilabel:`Columns made from other columns` 和 :guilabel:`Template searches`):" |
| 1615 |
|
| 1616 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:801 |
| 1617 |
msgid "GPM templates work as before." |
| 1618 |
msgstr "GPM(通用程序模式)模板的工作方式与之前相同。" |
| 1619 |
|
| 1620 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:802 |
| 1621 |
msgid "Python templates have full access to the calibre database." |
| 1622 |
msgstr "Python 模板拥有访问 calibre 数据库的完整权限。" |
| 1623 |
|
| 1624 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:804 |
| 1625 |
msgid "In icon rules:" |
| 1626 |
msgstr "在图标规则中:" |
| 1627 |
|
| 1628 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:806 |
| 1629 |
msgid "" |
| 1630 |
"icon rule templates have no book data so field-based functions such as " |
| 1631 |
":ref:`ff_format_date_field`, :ref:`ff_list_count_field`, and " |
| 1632 |
":ref:`ff_check_yes_no` won't work." |
| 1633 |
msgstr "图标规则模板不包含书籍数据,因此基于字段的函数,如 :ref:`ff_format_date_field`, :ref:`ff_list_count_field`, 和 :ref:`ff_check_yes_no` 将无法工作。" |
| 1634 |
|
| 1635 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:808 |
| 1636 |
msgid "In the Content server:" |
| 1637 |
msgstr "在内容服务器中:" |
| 1638 |
|
| 1639 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:810 |
| 1640 |
msgid "" |
| 1641 |
"Templates have access to the new API but not the old API (LibraryDatabase)." |
| 1642 |
msgstr "模板可以访问新的 API,但无法访问旧的 API(LibraryDatabase)。" |
| 1643 |
|
| 1644 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:811 |
| 1645 |
msgid "" |
| 1646 |
"Because of the above, the following formatter functions are not guaranteed " |
| 1647 |
"to work in GPM templates (composite columns, icon rules, etc) and should be " |
| 1648 |
"avoided if you use the content server:" |
| 1649 |
msgstr "由于上述原因,以下格式化函数在 GPM 模板(复合列、图标规则等)中无法保证正常运行;如果您使用内容服务器,应当避免使用这些函数:" |
| 1650 |
|
| 1651 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:813 |
| 1652 |
msgid ":ref:`ff_connected_device_name`" |
| 1653 |
msgstr ":ref:`ff_connected_device_name`" |
| 1654 |
|
| 1655 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:814 |
| 1656 |
msgid ":ref:`ff_connected_device_uuid`" |
| 1657 |
msgstr ":ref:`ff_connected_device_uuid`" |
| 1658 |
|
| 1659 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:815 |
| 1660 |
msgid ":ref:`ff_current_virtual_library_name`" |
| 1661 |
msgstr ":ref:`ff_current_virtual_library_name`" |
| 1662 |
|
| 1663 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:816 |
| 1664 |
msgid ":ref:`ff_is_marked`" |
| 1665 |
msgstr ":ref:`ff_is_marked`" |
| 1666 |
|
| 1667 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:817 |
| 1668 |
msgid ":ref:`ff_virtual_libraries`" |
| 1669 |
msgstr ":ref:`ff_virtual_libraries`" |
| 1670 |
|
| 1671 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:820 |
| 1672 |
msgid "Special notes for save/send templates" |
| 1673 |
msgstr "关于保存/发送模板的特别说明" |
| 1674 |
|
| 1675 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:822 |
| 1676 |
msgid "" |
| 1677 |
"Special processing is applied when a template is used in a :guilabel:`Save " |
| 1678 |
"to disk` or :guilabel:`Send to device` template. The values of the fields " |
| 1679 |
"are cleaned, replacing characters that are special to file systems with " |
| 1680 |
"underscores, including slashes. This means that field text cannot be used to" |
| 1681 |
" create folders. However, slashes are not changed in prefix or suffix " |
| 1682 |
"strings, so slashes in these strings will cause folders to be created. " |
| 1683 |
"Because of this, you can create variable-depth folder structure." |
| 1684 |
msgstr "当模板用于 :guilabe :guilabel:`Save to disk` 或 :guilabel:`Send to device` 时,系统会进行特殊处理。字段的值会被‘清洗’,即文件系统中的特殊字符(包括斜杠)都会被替换为下划线。这意味着字段内的文本不能直接用于创建文件夹。然而,前缀或后缀字符串中的斜杠不会被更改,因此这些字符串中的斜杠会导致文件夹的创建。利用这一特性,您可以创建深度可变的文件夹结构。" |
| 1685 |
|
| 1686 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:824 |
| 1687 |
msgid "" |
| 1688 |
"For example, assume we want the folder structure `series/series_index - " |
| 1689 |
"title`, with the caveat that if series does not exist, then the title should" |
| 1690 |
" be in the top folder. The template to do this is::" |
| 1691 |
msgstr "例如,假设我们想要构建 `series/series_index - title` 这样的文件夹结构,但有一个前提条件:如果‘丛书’(series)不存在,则书名应直接放在根目录(最顶层文件夹)下。实现这一点的模板为::" |
| 1692 |
|
| 1693 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:828 |
| 1694 |
msgid "The slash and the hyphen appear only if series is not empty." |
| 1695 |
msgstr "斜杠和连字符仅在‘丛书’(series)不为空时才会出现。" |
| 1696 |
|
| 1697 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:830 |
| 1698 |
msgid "" |
| 1699 |
"The lookup function lets us do even fancier processing. For example, assume " |
| 1700 |
"that if a book has a series, then we want the folder structure " |
| 1701 |
"`series/series index - title.fmt`. If the book does not have a series then " |
| 1702 |
"we want the folder structure `genre/author_sort/title.fmt`. If the book has " |
| 1703 |
"no genre then we want to use 'Unknown'. We want two completely different " |
| 1704 |
"paths, depending on the value of series." |
| 1705 |
msgstr "查找功能让我们可以进行更高级的处理。 例如,假设一本书有一个系列,那么我们需要文件夹结构“系列/系列索引 - title.fmt”。 如果这本书没有系列,那么我们需要文件夹结构“genre/author_sort/title.fmt”。 如果这本书没有类型,那么我们想使用“未知”。 我们想要两条完全不同的路径,具体取决于系列的值。" |
| 1706 |
|
| 1707 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:832 |
| 1708 |
msgid "To accomplish this, we:" |
| 1709 |
msgstr "为了实现这一目标,我们需要:" |
| 1710 |
|
| 1711 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:834 |
| 1712 |
msgid "" |
| 1713 |
"Create a composite field (give it lookup name #aa) containing " |
| 1714 |
"``{series}/{series_index} - {title}``. If the series is not empty, then this" |
| 1715 |
" template will produce `series/series_index - title`." |
| 1716 |
msgstr "创建一个复合列(其搜索代号设为 #aa),内容为 {series}/{series_index} - {title}。如果‘丛书’(series)不为空,该模板将生成 series/series_index - title。" |
| 1717 |
|
| 1718 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:835 |
| 1719 |
msgid "" |
| 1720 |
"Create a composite field (give it lookup name #bb) containing " |
| 1721 |
"``{#genre:ifempty(Unknown)}/{author_sort}/{title}``. This template produces " |
| 1722 |
"`genre/author_sort/title`, where an empty genre is replaced with `Unknown`." |
| 1723 |
msgstr "创建一个包含“{#genre:ifempty(Unknown)}/{Author_sort}/{title}'的复合字段(为其查找名称#bb)。此模板生成“genre/Author_sort/title”,其中空的genre被“Unknown”替换。" |
| 1724 |
|
| 1725 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:836 |
| 1726 |
msgid "" |
| 1727 |
"Set the save template to ``{series:lookup(.,#aa,#bb)}``. This template " |
| 1728 |
"chooses composite field ``#aa`` if series is not empty and composite field " |
| 1729 |
"``#bb`` if series is empty. We therefore have two completely different save " |
| 1730 |
"paths, depending on whether or not `series` is empty." |
| 1731 |
msgstr "将保存模板设置为“{series:lookup(.,#aa,#bb)}`”。如果系列不为空,则此模板选择复合字段“#aa”,如果系列为空,请选择复合字段。因此,根据“系列”是否为空,我们有两个完全不同的保存路径。" |
| 1732 |
|
| 1733 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:839 |
| 1734 |
msgid "Tips" |
| 1735 |
msgstr "技巧与建议" |
| 1736 |
|
| 1737 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:841 |
| 1738 |
msgid "" |
| 1739 |
"Use the Template Tester to test templates. Add the tester to the context " |
| 1740 |
"menu for books in the library and/or give it a keyboard shortcut." |
| 1741 |
msgstr "使用‘模板测试器’来测试模板。您可以将测试器添加到书籍的右键上下文菜单中,或者为其设置键盘快捷键。" |
| 1742 |
|
| 1743 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:842 |
| 1744 |
msgid "" |
| 1745 |
"Templates can use other templates by referencing composite columns built " |
| 1746 |
"with the desired template. Alternatively, you can use Stored Templates." |
| 1747 |
msgstr "模板可以通过引用基于所需模板构建的‘复合列’来调用其他模板。或者,您也可以使用‘存档模板’。" |
| 1748 |
|
| 1749 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:843 |
| 1750 |
msgid "" |
| 1751 |
"In a plugboard, you can set a field to empty (or whatever is equivalent to " |
| 1752 |
"empty) by using the special template ``{}``. This template will always " |
| 1753 |
"evaluate to an empty string." |
| 1754 |
msgstr "在元数据处理规则中,您可以使用特殊模板 {} 将某个字段设置为空(或等同于空的值)。该模板的结果始终为一个空字符串。" |
| 1755 |
|
| 1756 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:844 |
| 1757 |
msgid "" |
| 1758 |
"The technique described above to show numbers even if they have a zero value" |
| 1759 |
" works with the standard field series_index." |
| 1760 |
msgstr "上述用于即使数值为零也显示数字的技巧,同样适用于标准字段 series_index(丛书编号)。" |
| 1761 |
|
| 1762 |
#: ../../../__w/calibre/calibre/manual/template_lang.rst:849 |
| 1763 |
msgid "Template function reference" |
| 1764 |
msgstr "模板函数参考" |