# SOME DESCRIPTIVE TITLE. # Copyright (C) Kovid Goyal # This file is distributed under the same license as the calibre package. # # Translators: msgid "" msgstr "" "Project-Id-Version: calibre\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-02-03 02:30+0000\n" "PO-Revision-Date: 2022-02-01 09:40+0000\n" "Last-Translator: Kovid Goyal \n" "Language-Team: Filipino (http://www.transifex.com/calibre/calibre/language/fil/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fil\n" "Plural-Forms: nplurals=2; plural=(n == 1 || n==2 || n==3) || (n % 10 != 4 || n % 10 != 6 || n % 10 != 9);\n" #: ../../__w/calibre/calibre/manual/template_lang.rst:4 msgid "The calibre template language" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:6 msgid "" "The calibre template language is a calibre-specific language used throughout" " calibre for tasks such as specifying file paths, formatting values, and " "computing the value for user-specified columns. Examples:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:8 msgid "" "Specify the folder structure and file names when saving files from the " "calibre library to the disk or e-book reader." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:9 msgid "Define rules for adding icons and colors to the calibre book list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:10 msgid "Define `virtual columns` that contain data from other columns." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:11 msgid "Advanced library searching." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:12 msgid "Advanced metadata search and replace." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:14 msgid "" "The language is built around the notion of a `template`, which specifies " "which book metadata to use, computations on that metadata, and how it is to " "be formatted." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:17 msgid "Basic templates" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:19 msgid "" "A basic template consists one or more ``template expressions``. A ``template" " expression`` consists of text and names in curly brackets (``{}``) that is " "replaced by the corresponding metadata from the book being processed. For " "example, the default template in calibre used for saving books to device has" " 4 ``template expressions``::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:23 msgid "For the book \"The Foundation\" by \"Isaac Asimov\" the will become::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:27 msgid "" "The slashes are not ``template expressions`` because they are in between in " "``{}``. Such text is left where it appears. For example, if the template " "is::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:31 msgid "then for \"The Foundation\" the template produces::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:35 msgid "" "A ``template expression`` can access all the metadata available in calibre, " "including custom columns (columns you create yourself), by using a column's " "``lookup name``. To find the lookup name for a `column` (sometimes called " "`fields`), hover your mouse over the column header in calibre's book list. " "Lookup names for custom columns always begin with ``#``. For series type " "columns there is an additional field named ``#lookup name_index`` that is " "the series index for that book in the series. For example, if you have a " "custom series column named ``#myseries``, there will also be a column named " "``#myseries_index``. The standard series column's index is named " "``series_index``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:37 msgid "In addition to the standard column based fields, you also can use:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:39 msgid "" "``{formats}`` - A list of formats available in the calibre library for a " "book" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:40 msgid "``{identifiers:select(isbn)}`` - The ISBN of the book" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:42 msgid "" "If the metadata for the field for a given book is not defined then the field" " in the template is replaced by the empty string (``''``). For example, " "consider the following template::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:46 msgid "" "If Asimov's book \"Second Foundation\" is in the series \"Foundation\" then " "the template produces::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:50 msgid "" "If a series has not been entered for the book then the template produces::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:54 msgid "" "The template processor automatically removes multiple slashes and leading or" " trailing spaces." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:57 msgid "Advanced formatting" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:59 msgid "" "In addition to metadata substitution, templates can conditionally include " "additional text and control how substituted data is formatted." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:61 msgid "**Conditionally including text**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:63 msgid "" "Sometimes you want text to appear in the output only if a field is not " "empty. A common case is ``series`` and ``series_index`` where you want " "either nothing or the two values separated by a hyphen. calibre handles this" " case using a special ``template expression`` syntax." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:65 msgid "" "For example and using the above Foundation example, assume you want the " "template to produce `Foundation - 3 - Second Foundation`. This template " "produces that output:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:67 msgid "``{series} - {series_index} - {title}``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:69 msgid "" "However, if a book has no series the template will produce `- - the title`, " "which is probably not what you want. Generally, people want the result be " "the title without the extraneous hyphens. You can accomplish this using the " "following template syntax:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:71 msgid "``{field:|prefix_text|suffix_text}``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:73 msgid "" "This ``template expression`` says that if ``field`` has the value `XXXX` " "then the result will be `prefix_textXXXXXsuffix_text`. If ``field`` is empty" " (has no value) then the result will be the empty string (nothing) because " "the prefix and suffix are ignored. The prefix and suffix can contain blanks." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:75 msgid "" "**Do not use subtemplates (`{ ... }`) or functions (see below) in the prefix" " or the suffix.**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:77 msgid "" "Using this syntax, we can solve the above no-series problem with the " "template::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:81 msgid "" "The hyphens will be included only if the book has a series index, which it " "has only if it has a series. Continuing the Foundation example again, the " "template will produce `Foundation - 1 - Second Foundation`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:83 #: ../../__w/calibre/calibre/manual/template_lang.rst:249 msgid "Notes:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:85 msgid "" "You must include the colon after the ``lookup name`` if you are using a " "prefix or a suffix." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:86 msgid "" "You must either use either no or both ``|`` characters. Using one, as in " "``{field:| - }``, is not allowed." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:87 msgid "" "It is OK to provide no text for either the prefix or the suffix, such as in " "``{series:|| - }``. The template ``{title:||}`` is the same as ``{title}``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:89 msgid "**Formatting**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:91 msgid "" "Suppose you want the ``series_index`` to be formatted as three digits with " "leading zeros. This does the trick:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:93 msgid "``{series_index:0>3s}`` - Three digits with leading zeros" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:95 msgid "For trailing zeros, use:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:97 msgid "``{series_index:0<3s}`` - Three digits with trailing zeros" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:99 msgid "" "If you use series indices with fractional values, e.g., 1.1, you might want " "the decimal points to line up. For example, you might want the indices 1 and" " 2.5 to appear as 01.00 and 02.50 so that they will sort correctly on a " "device that does lexical sorting. To do this, use:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:101 msgid "" "``{series_index:0>5.2f}`` - Five characters consisting of two digits with " "leading zeros, a decimal point, then 2 digits after the decimal point." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:103 msgid "If you want only the first two letters of the data, use:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:105 msgid "" "``{author_sort:.2}`` - Only the first two letters of the author sort name" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:107 msgid "" "Much of the calibre template language formatting comes from Python. For more" " details on the syntax of these advanced formatting operations see the " "`Python documentation " "`_." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:111 msgid "Using templates to define custom columns" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:113 msgid "" "Templates can be used to display information that isn't in calibre metadata," " or to display metadata differently from calibre's normal format. For " "example, you might want to show the ``ISBN``, a field that calibre does not " "display. You can accomplish this creating a custom column with the type " "`Column built from other columns` (hereafter called `composite columns`) and" " providing a template to generate the displayed text. The column will " "display the result of evaluating the template. For example, to display the " "ISBN, create the column and enter ``{identifiers:select(isbn)}`` in the " "template box. To display a column containing the values of two series custom" " columns, separated by a comma, use ``{#series1:||,}{#series2}``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:115 msgid "Composite columns can use any template option, including formatting." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:117 msgid "" "Note: You cannot edit the data displayed in a composite column. Instead you " "edit the source columns. If you edit a composite column, for example by " "double-clicking it, calibre will open the template for editing, not the " "underlying data." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:122 msgid "Using functions in templates - Single Function Mode" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:124 msgid "" "Suppose you want to display the value of a field in upper case when that " "field is normally in title case. You can do this using `template functions`." " For example, to display the title in upper case use the ``uppercase`` " "function, as in ``{title:uppercase()}``. To display it in title case, use " "``{title:titlecase()}``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:126 msgid "" "Functions go into the format part of the template, after the ``:`` and " "before the first ``|`` or the closing ``}`` if no prefix/suffix is used. If " "you have both a format and a function reference, the function comes after a " "second ``:``. Functions return the value of the column specified in the " "template, suitably modified." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:128 msgid "The syntax for using functions is one of::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:135 msgid "" "Function names must always be followed by opening and closing parentheses. " "Some functions require extra values (arguments), and these go inside the " "parentheses. Arguments are separated by commas. Literal commas (commas as " "text, not argument separators) must be preceded by a backslash (``\\``) . " "The last (or only) argument cannot contain a textual closing parenthesis." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:137 msgid "" "Functions are evaluated before format specifications and the prefix/suffix. " "See further down for an example of using both a format and a function." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:139 msgid "" "**Important**: If you have programming experience, please note that the " "syntax in `Single Function Mode` is not what you expect. Strings are not " "quoted and spaces are significant. All arguments are considered to be " "constants; there are no expressions." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:141 msgid "" "**Do not use subtemplates (`{ ... }`) as function arguments.** Instead, use " ":ref:`Template Program Mode ` and :ref:`General Program Mode " "`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:143 msgid "" "Some functions require regular expressions. In the template language regular" " expression matching is case-insensitive." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:145 msgid "" "In the function documentation below, the notation ``[something]*`` means " "that ``something`` can be repeated zero or more times. The notation " "``[something]+`` means that the ``something`` is repeated one or more times " "(must exist at least one time)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:147 msgid "The functions intended for use in Single Function Mode are:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:150 msgid "" "``capitalize()`` -- returns the value with the first letter upper case and " "the rest lower case." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:151 msgid "" "``contains(pattern, text if match, text if not match)`` -- checks if the " "value is matched by the regular expression ``pattern``. Returns ``text if " "match`` if the pattern matches the value, otherwise returns ``text if no " "match``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:152 msgid "" "``count(separator)`` -- interprets the value as a list of items separated by" " ``separator`` and returns the number of items in the list. Most lists use a" " comma as the separator, but ``authors`` uses an ampersand (&). Examples: " "``{tags:count(,)}``, ``{authors:count(&)}``. Aliases: ``count()``, " "``list_count()``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:153 msgid "" "``format_number(template)`` -- interprets the value as a number and formats " "that number using a Python formatting template such as ``{0:5.2f}`` or " "``{0:,d}`` or ``${0:5,.2f}``. The formatting template must begin with " "``{0:`` and end with ``}`` as in the above examples. Exception: you can " "leave off the leading \"{0:\" and trailing \"}\" if the format template " "contains only a format. See the template language and the `Python " "documentation " "`_ for more " "examples. Returns the empty string if formatting fails." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:154 msgid "" "``human_readable()`` -- expects the value to be a number and returns a " "string representing that number in KB, MB, GB, etc." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:155 msgid "" "``ifempty(text if empty)`` -- if the value is not empty then return the " "value of the field, otherwise return `text if empty`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:156 msgid "" "``in_list(separator, [ pattern, found_val, ]* not_found_val)`` -- interpret " "the value as a list of items separated by ``separator``, checking the " "``pattern`` against each item in the list. If the ``pattern`` matches an " "item then return ``found_val``, otherwise return ``not_found_val``. The pair" " ``pattern`` and ``found_value`` can be repeated as many times as desired, " "permitting returning different values depending on the item's value. The " "patterns are checked in order, and the first match is returned." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:157 msgid "" "``language_strings(localize)`` -- return the `language names " "`_ for the " "`language codes `_" " passed in as the value. Example: ``{languages:language_strings()}``. If " "``localize`` is zero, return the strings in English. If ``localize`` is not " "zero, return the strings in the language of the current locale. " "``Lang_codes`` is a comma-separated list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:158 msgid "" "``list_item(index, separator)`` -- interpret the value as a list of items " "separated by ``separator``, returning the 'index'th item. The first item is " "number zero. The last item has the index ``-1`` as in " "``list_item(-1,separator)``. If the item is not in the list, then the empty " "string is returned." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:159 msgid "" "``lookup([ pattern, key, ]* else_key)`` -- The patterns will be checked " "against the value in order. If a pattern matches then the value of the field" " named by ``key`` is returned. If no pattern matches then the value of the " "field named by ``else_key`` is returned. See``switch`` (below)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:160 msgid "``lowercase()`` -- returns the value of the field in lower case." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:161 msgid "" "``rating_to_stars(use_half_stars)`` -- Returns the rating as string of star " "(``★``) characters. The value must be a number between 0 and 5. Set " "use_half_stars to 1 if you want half star characters for fractional numbers " "available with custom ratings columns." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:162 msgid "" "``re(pattern, replacement)`` -- return the value after applying the regular " "expression. All instances of ``pattern`` in the value are replaced with " "``replacement``. The template language uses case insensitive `Python regular" " expressions `_." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:163 msgid "" "``select(key)`` -- interpret the value as a comma-separated list of items " "with each item having the form ``id:value`` (the calibre ``identifier`` " "format). The function finds the first pair with the id equal to key and " "returns the corresponding value. If no id matches then the function returns " "the empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:164 msgid "" "``shorten(left chars, middle text, right chars)`` -- Return a shortened " "version of the value, consisting of ``left chars`` characters from the " "beginning of the value, followed by ``middle text``, followed by ``right " "chars`` characters from the end of the value. ``Left chars`` and ``right " "chars`` must be non-negative integers. Example: assume you want to display " "the title with a length of at most 15 characters in length. One template " "that does this is ``{title:shorten(9,-,5)}``. For a book with the title " "`Ancient English Laws in the Times of Ivanhoe` the result will be `Ancient " "E-anhoe`: the first 9 characters of the title, a ``-``, then the last 5 " "characters. If the value's length is less than ``left chars`` + ``right " "chars`` + the length of ``middle text`` then the value will be returned " "unchanged. For example, the title `The Dome` would not be changed." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:165 msgid "" "``str_in_list(separator, [ string, found_val, ]+ not_found_val)`` -- " "interpret the value as a list of items separated by ``separator`` then " "compare ``string`` against each value in the list. The ``string`` is not a " "regular expression. If ``string`` is equal to any item (ignoring case) then " "return the corresponding ``found_val``. If ``string`` contains " "``separators`` then it is also treated as a list and each subvalue is " "checked. The ``string`` and ``found_value`` pairs can be repeated as many " "times as desired, permitting returning different values depending on " "string's value. If none of the strings match then ``not_found_value`` is " "returned. The strings are checked in order. The first match is returned." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:166 msgid "" "``subitems(start_index, end_index)`` -- This function breaks apart lists of " "tag-like hierarchical items such as genres. It interprets the value as a " "comma-separated list of tag-like items, where each item is a period-" "separated list. It returns a new list made by extracting from each item the " "components from ``start_index`` to ``end_index``, then merging the results " "back together. Duplicates are removed. The first subitem in a period-" "separated list has an index of zero. If an index is negative then it counts " "from the end of the list. As a special case, an end_index of zero is assumed" " to be the length of the list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:168 #: ../../__w/calibre/calibre/manual/template_lang.rst:351 msgid "Examples:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:170 msgid "Assuming a #genre column containing `A.B.C`:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:172 msgid "``{#genre:subitems(0,1)}`` returns \"A\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:173 msgid "``{#genre:subitems(0,2)}`` returns \"A.B\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:174 msgid "``{#genre:subitems(1,0)}`` returns \"B.C\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:176 msgid "Assuming a #genre column containing \"A.B.C, D.E\":" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:178 msgid "``{#genre:subitems(0,1)}`` returns \"A, D\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:179 msgid "``{#genre:subitems(0,2)}`` returns \"A.B, D.E\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:181 msgid "" "``sublist(start_index, end_index, separator)`` -- interpret the value as a " "list of items separated by ``separator``, returning a new list made from the" " items from ``start_index`` to ``end_index``. The first item is number zero." " If an index is negative, then it counts from the end of the list. As a " "special case, an end_index of zero is assumed to be the length of the list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:183 msgid "" "Examples assuming that the tags column (which is comma-separated) contains " "\"A, B ,C\":" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:185 msgid "``{tags:sublist(0,1,\\,)}`` returns \"A\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:186 msgid "``{tags:sublist(-1,0,\\,)}`` returns \"C\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:187 msgid "``{tags:sublist(0,-1,\\,)}`` returns \"A, B\"" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:189 msgid "" "``swap_around_articles(separator)`` -- returns the value with articles moved" " to the end. The value can be a list, in which case each item in the list is" " processed. If the value is a list then you must provide the ``separator``. " "If no ``separator`` is provided then the value is treated as being a single " "value, not a list. The `articles` are those used by calibre to generate the " "``title_sort``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:190 msgid "" "``swap_around_comma()`` -- given a value of the form ``B, A``, return ``A " "B``. This is most useful for converting names in LN, FN format to FN LN. If " "there is no comma in the value then the function returns the value " "unchanged." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:191 msgid "" "``switch([pattern, value,]+ else_value)`` -- for each ``pattern, value`` " "pair, checks if the value matches the regular expression ``pattern`` and if " "so returns the associated ``value``. If no ``pattern`` matches, then " "``else_value`` is returned. You can have as many ``pattern, value`` pairs as" " you wish. The first match is returned." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:192 msgid "" "``test(text if not empty, text if empty)`` -- return ``text if not empty`` " "if the value is not empty, otherwise return ``text if empty``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:193 msgid "``titlecase()`` -- returns the value of the field in title case." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:194 msgid "" "``transliterate()`` -- Return a string in a latin alphabet formed by " "approximating the sound of the words in the source field. For example, if " "the source field is ``Фёдор Миха́йлович Достоевский`` this function returns " "``Fiodor Mikhailovich Dostoievskii``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:195 msgid "``uppercase()`` -- returns the value of the field in upper case." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:197 msgid "**Using functions and formatting in the same template**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:199 msgid "" "Suppose you have an integer custom column ``#myint`` that you want displayed" " with leading zeros, as in ``003``. One way to do this is to use a format of" " ``0>3s``. However, by default if a number (integer or float) equals zero " "then the value is displayed as the empty string so zero values will produce " "the empty string, not ``000``. If you want to see ``000`` values then you " "use both the format string and the ``ifempty`` function to change the empty " "value back to a zero. The template would be::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:203 msgid "" "Note that you can use the prefix and suffix as well. If you want the number " "to appear as ``[003]`` or ``[000]``, then use the template::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:210 msgid "General Program Mode" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:212 msgid "" "`General Program Mode` (`GPM`) replaces `template expressions` with a " "program written in the `template language`. The syntax of the language is " "defined by the following grammar::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:251 msgid "" "a ``top_expression`` always has a value. The value of an ``expression_list``" " is the value of the last ``top_expression`` in the list. For example, the " "value of the expression list ``1;2;'foobar';3`` is ``3``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:252 msgid "In a logical context, any non-empty value is ``True``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:253 msgid "In a logical context, the empty value is ``False``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:254 msgid "" "Strings and numbers can be used interchangeably. For example, ``10`` and " "``'10'`` are the same thing." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:255 msgid "" "Comments are lines starting with a '#' character. Comments beginning later " "in a line are not supported." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:257 msgid "**Operator precedence**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:259 msgid "" "The operator precedence (order of evaluation) from highest (evaluated first)" " to lowest (evaluated last) is:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:261 msgid "" "Function calls, constants, parenthesized expressions, statement expressions," " assignment expressions, field references." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:262 msgid "" "Unary plus (``+``) and minus (``-``). These operators evaluate right to " "left." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:264 msgid "" "These and all the other arithmetic operators return integers if the " "expression results in a fractional part equal to zero. For example, if an " "expression returns ``3.0`` it is changed to ``3``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:265 msgid "" "Multiply (``*``) and divide (``/``). These operators are associative and " "evaluate left to right. Use parentheses if you want to change the order of " "evaluation." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:266 msgid "" "Add (``+``) and subtract (``-``). These operators are associative and " "evaluate left to right." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:267 msgid "" "Numeric and string comparisons. These operators return ``'1'`` if the " "comparison succeeds, otherwise the empty string (``''``). Comparisons are " "not associative: ``a < b < c`` is a syntax error." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:268 msgid "" "Unary logical not (``!``). This operator returns ``'1'`` if the expression " "is False (evaluates to the empty string), otherwise ``''``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:269 msgid "" "Logical and (``&&``). This operator returns '1' if both the left-hand and " "right-hand expressions are True, or the empty string ``''`` if either is " "False. It is associative, evaluates left to right, and does `short-" "circuiting `_." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:270 msgid "" "Logical or (``||``). This operator returns ``'1'`` if either the left-hand " "or right-hand expression is True, or ``''`` if both are False. It is " "associative, evaluates left to right, and does `short-circuiting " "`_. It is an " "`inclusive or`, returning ``'1'`` if both the left- and right-hand " "expressions are True." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:272 msgid "**Field references**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:274 msgid "" "A ``field_reference`` evaluates to the value of the metadata field named by " "lookup name that follows the ``$`` or ``$$``. Using ``$`` is equivalent to " "using the ``field()`` function. Using ``$$`` is equivalent to using the " "``raw_field`` function. Examples::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:281 msgid "**If expressions**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:283 msgid "" "``If`` expressions first evaluate the ``condition``. If the ``condition`` is" " True (a non-empty value) then the ``expression_list`` in the ``then`` " "clause is evaluated. If it is False then if present the ``expression_list`` " "in the ``elif`` or ``else`` clause is evaluated. The ``elif`` and ``else`` " "parts are optional. The words ``if``, ``then``, ``elif``, ``else``, and " "``fi`` are reserved; you cannot use them as identifier names. You can put " "newlines and white space wherever they make sense. The ``condition`` is a " "``top_expression`` not an ``expression_list``; semicolons are not allowed. " "The ``expression_lists`` are semicolon-separated sequences of " "``top_expressions``. An ``if`` expression returns the result of the last " "``top_expression`` in the evaluated ``expression_list``, or the empty string" " if no expression list was evaluated." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:285 msgid "Examples::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:298 msgid "Nested ``if`` example::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:311 msgid "" "As said above, an ``if`` produces a value. This means that all the following" " are equivalent::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:317 msgid "" "As a last example, this program returns the value of the ``series`` column " "if the book has a series, otherwise the value of the ``title`` column::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:321 msgid "**For expressions**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:323 msgid "" "The ``for`` expression iterates over a list of values, processing them one " "at a time. The ``list_expression`` must evaluate to either a metadata field " "``lookup name``, for example ``tags`` or ``#genre``, or a list of values. If" " the result is a valid ``lookup name`` then the field's value is fetched and" " the separator specified for that field type is used. If the result isn't a " "valid lookup name then it is assumed to be a list of values. The list is " "assumed to be separated by commas unless the optional keyword ``separator`` " "is supplied, in which case the list values must be separated by the result " "of evaluating the ``separator_expr``. Each value in the list is assigned to " "the specified variable then the ``expression_list`` is evaluated. You can " "use ``break`` to jump out of the loop, and ``continue`` to jump to the " "beginning of the loop for the next iteration." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:325 msgid "" "Example: This template removes the first hierarchical name for each value in" " Genre (``#genre``), constructing a list with the new names::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:335 msgid "" "If the original Genre is `History.Military, Science Fiction.Alternate " "History, ReadMe` then the template returns `Military, Alternate History, " "ReadMe`. You could use this template in calibre's :guilabel:`Edit metadata " "in bulk -> Search & replace` with :guilabel:`Search for` set to ``template``" " to strip off the first level of the hierarchy and assign the resulting " "value to Genre." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:338 msgid "" "Note: the last line in the template, ``new_tags``, isn't strictly necessary " "in this case because ``for`` returns the value of the last top_expression in" " the expression list. The value of an assignment is the value of its " "expression, so the value of the ``for`` statement is what was assigned to " "``new_tags``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:340 msgid "**Relational operators**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:342 msgid "" "Relational operators return ``'1'`` if the comparison is true, otherwise the" " empty string ('')." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:344 msgid "" "There are two forms of relational operators: string comparisons and numeric " "comparisons." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:346 msgid "" "String comparisons do case-insensitive string comparison using lexical " "order. The supported string comparison operators are ``==``, ``!=``, ``<``, " "``<=``, ``>``, ``>=``, ``in``, and ``inlist``. For the ``in`` operator, the " "result of the left hand expression is interpreted as a regular expression " "pattern. The ``in`` operator is True if the value of left-hand regular " "expression matches the value of the right hand expression. The ``inlist`` " "operator is true if the left hand regular expression matches any one of the " "items in the right hand list where the items in the list are separated by " "commas. The matches are case-insensitive." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:349 msgid "" "The numeric comparison operators are ``==#``, ``!=#``, ``<#``, ``<=#``, " "``>#``, ``>=#``. The left and right expressions must evaluate to numeric " "values with two exceptions: both the string value \"None\" (undefined field)" " and the empty string evaluate to the value zero." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:353 msgid "" "``program: field('series') == 'foo'`` returns ``'1'`` if the book's series " "is 'foo', otherwise ``''``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:354 msgid "" "``program: 'f.o' in field('series')`` returns ``'1'`` if the book's series " "matches the regular expression ``f.o`` (e.g., `foo`, `Off Onyx`, etc.), " "otherwise ``''``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:355 msgid "" "``program: 'science' inlist field('#genre')`` returns ``'1'`` if any of the " "book's genres match the regular expression ``science``, e.g., `Science`, " "`History of Science`, `Science Fiction` etc.), otherwise ``''``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:356 msgid "" "``program: '^science$' inlist field('#genre')`` returns ``'1'`` if any of " "the book's genres exactly match the regular expression ``^science$``, e.g., " "`Science`. The genres `History of Science` and `Science Fiction` don't " "match. If there isn't a match then returns ``''``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:357 msgid "" "``program: if field('series') != 'foo' then 'bar' else 'mumble' fi`` returns" " ``'bar'`` if the book's series is not ``foo``. Otherwise it returns " "``'mumble'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:358 msgid "" "``program: if field('series') == 'foo' || field('series') == '1632' then " "'yes' else 'no' fi`` returns ``'yes'`` if series is either ``'foo'`` or " "``'1632'``, otherwise ``'no'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:359 msgid "" "``program: if '^(foo|1632)$' in field('series') then 'yes' else 'no' fi`` " "returns ``'yes'`` if series is either ``'foo'`` or ``'1632'``, otherwise " "``'no'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:360 msgid "" "``program: if 11 > 2 then 'yes' else 'no' fi`` returns ``'no'`` because the " "``>`` operator does a lexical comparison." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:361 msgid "" "``program: if 11 ># 2 then 'yes' else 'no' fi`` returns ``'yes'`` because " "the ``>#`` operator does a numeric comparison." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:363 msgid "**Additional available functions**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:365 msgid "" "The following functions are available in addition to those described in " ":ref:`Single Function Mode `." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:367 msgid "" "In `GPM` the functions described in `Single Function Mode` all require an " "additional first parameter specifying the value to operate upon. All " "parameters are expression_lists (see the grammar above)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:369 msgid "" "``add(x [, y]*)`` -- returns the sum of its arguments. Throws an exception " "if an argument is not a number. In most cases you can use the ``+`` operator" " instead of this function." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:370 msgid "" "``and(value [, value]*)`` -- returns the string \"1\" if all values are not " "empty, otherwise returns the empty string. You can have as many values as " "you want. In most cases you can use the ``&&`` operator instead of this " "function. One reason not to replace ``and`` with ``&&`` is if short-" "circuiting can change the results because of side effects. For example, " "``and(a='',b=5)`` will always do both assignments, where the ``&&`` operator" " won't do the second." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:371 msgid "" "``assign(id, val)`` -- assigns ``val`` to ``id``, then returns ``val``. " "``id`` must be an identifier, not an expression. In most cases you can use " "the ``=`` operator instead of this function." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:372 msgid "" "``approximate_formats()`` -- return a comma-separated list of formats " "associated with the book. There is no guarantee that the list is correct, " "although it probably is. This and other zero-parameter functions can be " "called in Template Program Mode (see below) using the template " "``{:'approximate_formats()'}``. Note that resulting format names are always " "uppercase, as in EPUB. The ``approximate_formats()`` function is " "significantly faster than the ``formats_...`` functions discussed below." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:373 msgid "" "``author_links(val_separator, pair_separator)`` -- returns a string " "containing a list of authors and those authors' link values in the form::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:377 msgid "" "An author is separated from its link value by the ``val_separator`` string " "with no added spaces. ``author:linkvalue`` pairs are separated by the " "``pair_separator`` string argument with no added spaces. It is up to you to " "choose separator strings that do not occur in author names or links. An " "author is included even if the author link is empty." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:378 msgid "" "``author_sorts(val_separator)`` -- returns a string containing a list of " "author's sort values for the authors of the book. The sort is the one in the" " author metadata information (different from the author_sort in books). The " "returned list has the form ``author sort 1`` ``val_separator`` ``author sort" " 2`` etc. with no added spaces. The author sort values in this list are in " "the same order as the authors of the book. If you want spaces around " "``val_separator`` then include them in the ``val_separator`` string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:379 msgid "" "``booksize()`` -- returns the value of the calibre 'size' field. Returns '' " "if there are no formats." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:380 msgid "" "``check_yes_no(field_name, is_undefined, is_false, is_true)`` -- checks if " "the value of the yes/no field named by the lookup name ``field_name`` is one" " of the values specified by the parameters, returning ``'yes'`` if a match " "is found otherwise returning the empty string. Set the parameter " "``is_undefined``, ``is_false``, or ``is_true`` to 1 (the number) to check " "that condition, otherwise set it to 0. Example:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:382 msgid "" "``check_yes_no(\"#bool\", 1, 0, 1)`` returns ``'yes'`` if the yes/no field " "``#bool`` is either True or undefined (neither True nor False)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:384 msgid "" "More than one of ``is_undefined``, ``is_false``, or ``is_true`` can be set " "to 1." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:385 msgid "" "``ceiling(x)`` -- returns the smallest integer greater than or equal to " "``x``. Throws an exception if ``x`` is not a number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:386 msgid "" "``character(character_name)`` -- returns the character named by " "character_name. For example, ``character('newline')`` returns a newline " "character (``'\\n'``). The supported character names are ``newline``, " "``return``, ``tab``, and ``backslash``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:387 msgid "" "``cmp(x, y, lt, eq, gt)`` -- compares ``x`` and ``y`` after converting both " "to numbers. Returns ``lt`` if ``x <# y``, ``eq`` if ``x ==# y``, otherwise " "``gt``. This function can usually be replaced with one of the numeric " "compare operators (``==#``, ``<#``, ``>#``, etc)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:388 msgid "" "``connected_device_name(storage_location_key)`` -- if a device is connected " "then return the device name, otherwise return the empty string. Each storage" " location on a device has its own device name. The ``storage_location_key`` " "names are ``'main'``, ``'carda'`` and ``'cardb'``. This function works only " "in the GUI." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:389 msgid "" "``connected_device_uuid(storage_location_key)`` -- if a device is connected " "then return the device uuid (unique id), otherwise return the empty string. " "Each storage location on a device has a different uuid. The " "``storage_location_key`` location names are ``'main'``, ``'carda'`` and " "``'cardb'``. This function works only in the GUI." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:390 msgid "" "``current_library_name()`` -- return the last name on the path to the " "current calibre library." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:391 msgid "" "``current_library_path()`` -- return the full path to the current calibre " "library." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:392 msgid "" "``current_virtual_library_name()`` -- return the name of the current virtual" " library if there is one, otherwise the empty string. Library name case is " "preserved. Example: ``program: current_virtual_library_name()``. This " "function works only in the GUI." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:393 msgid "" "``date_arithmetic(date, calc_spec, fmt)`` -- Calculate a new date from " "``date`` using ``calc_spec``. Return the new date formatted according to " "optional ``fmt``: if not supplied then the result will be in ISO format. The" " calc_spec is a string formed by concatenating pairs of ``vW`` " "(``valueWhat``) where ``v`` is a possibly-negative number and W is one of " "the following letters:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:395 msgid "``s``: add ``v`` seconds to ``date``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:396 msgid "``m``: add ``v`` minutes to ``date``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:397 msgid "``h``: add ``v`` hours to ``date``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:398 msgid "``d``: add ``v`` days to ``date``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:399 msgid "``w``: add ``v`` weeks to ``date``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:400 msgid "``y``: add ``v`` years to ``date``, where a year is 365 days." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:402 msgid "" "Example: ``'1s3d-1m'`` will add 1 second, add 3 days, and subtract 1 minute " "from ``date``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:403 msgid "" "``days_between(date1, date2)`` -- return the number of days between " "``date1`` and ``date2``. The number is positive if ``date1`` is greater than" " ``date2``, otherwise negative. If either ``date1`` or ``date2`` are not " "dates, the function returns the empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:404 msgid "" "``divide(x, y)`` -- returns ``x / y``. Throws an exception if either ``x`` " "or ``y`` are not numbers. This function can usually be replaced by the ``/``" " operator." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:405 msgid "" "``eval(string)`` -- evaluates the string as a program, passing the local " "variables. This permits using the template processor to construct complex " "results from local variables. In :ref:`Template Program Mode " "`, because the `{` and `}` characters are interpreted before " "the template is evaluated you must use `[[` for the `{` character and `]]` " "for the ``}`` character. They are converted automatically. Note also that " "prefixes and suffixes (the `|prefix|suffix` syntax) cannot be used in the " "argument to this function when using :ref:`Template Program Mode " "`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:406 msgid "" "``field(lookup_name)`` -- returns the value of the metadata field with " "lookup name ``lookup_name``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:407 msgid "" "``field_exists(field_name)`` -- checks if a field (column) with the lookup " "name ``field_name`` exists, returning ``'1'`` if so and the empty string if " "not." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:408 msgid "" "``finish_formatting(val, fmt, prefix, suffix)`` -- apply the format, prefix," " and suffix to a value in the same way as done in a template like " "``{series_index:05.2f| - |- }``. This function is provided to ease " "conversion of complex single-function- or template-program-mode templates to" " `GPM` Templates. For example, the following program produces the same " "output as the above template::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:412 msgid "" "Another example: for the template " "``{series:re(([^\\s])[^\\s]+(\\s|$),\\1)}{series_index:0>2s| - | - " "}{title}`` use::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:421 msgid "" "``first_matching_cmp(val, [ cmp, result, ]* else_result)`` -- compares ``val" " < cmp`` in sequence, returning the associated result for the first " "comparison that succeeds. Returns else_result if no comparison succeeds. " "Example::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:426 msgid "" "returns ``\"large\"``. The same example with a first value of 16 returns " "``\"giant\"``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:428 msgid "" "``first_non_empty(value [, value]*)`` -- returns the first ``value`` that is" " not empty. If all values are empty, then the empty string is returned. You " "can have as many values as you want." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:429 msgid "" "``floor(x)`` -- returns the largest integer less than or equal to ``x``. " "Throws an exception if ``x`` is not a number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:430 msgid "" "``format_date(val, format_string)`` -- format the value, which must be a " "date string, using the format_string, returning a string. The formatting " "codes are:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:432 msgid "``d :`` the day as number without a leading zero (1 to 31)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:433 msgid "``dd :`` the day as number with a leading zero (01 to 31)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:434 msgid "``ddd :`` the abbreviated localized day name (e.g. \"Mon\" to \"Sun\")." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:435 msgid "``dddd :`` the long localized day name (e.g. \"Monday\" to \"Sunday\")." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:436 msgid "``M :`` the month as number without a leading zero (1 to 12)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:437 msgid "``MM :`` the month as number with a leading zero (01 to 12)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:438 msgid "``MMM :`` the abbreviated localized month name (e.g. \"Jan\" to \"Dec\")." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:439 msgid "``MMMM :`` the long localized month name (e.g. \"January\" to \"December\")." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:440 msgid "``yy :`` the year as two digit number (00 to 99)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:441 msgid "``yyyy :`` the year as four digit number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:442 msgid "" "``h :`` the hours without a leading 0 (0 to 11 or 0 to 23, depending on " "am/pm)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:443 msgid "" "``hh :`` the hours with a leading 0 (00 to 11 or 00 to 23, depending on " "am/pm)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:444 msgid "``m :`` the minutes without a leading 0 (0 to 59)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:445 msgid "``mm :`` the minutes with a leading 0 (00 to 59)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:446 msgid "``s :`` the seconds without a leading 0 (0 to 59)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:447 msgid "``ss :`` the seconds with a leading 0 (00 to 59)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:448 msgid "" "``ap :`` use a 12-hour clock instead of a 24-hour clock, with 'ap' " "replaced by the localized string for am or pm." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:449 msgid "" "``AP :`` use a 12-hour clock instead of a 24-hour clock, with 'AP' " "replaced by the localized string for AM or PM." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:450 msgid "" "``iso :`` the date with time and timezone. Must be the only format present." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:451 msgid "" "``to_number :`` convert the date & time into a floating point number (a " "`timestamp`)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:452 msgid "" "``from_number :`` convert a floating point number (a `timestamp`) into an " "``iso`` formatted date. If you want a different date format then add the " "desired formatting string after ``from_number`` and a colon (``:``). " "Example: ``from_number:MMM dd yyyy``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:454 msgid "" "You might get unexpected results if the date you are formatting contains " "localized month names, which can happen if you changed the date format " "tweaks to contain ``MMMM``. In this case, instead of using the ``field()`` " "function as in::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:458 msgid "use the ``raw_field()`` function as in::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:462 msgid "" "``formats_modtimes(date_format_string)`` -- return a comma-separated list of" " colon-separated items ``FMT:DATE`` representing modification times for the " "formats of a book. The ``date_format_string`` parameter specifies how the " "date is to be formatted. See the ``format_date()`` function for details. You" " can use the ``select`` function to get the modification time for a specific" " format. Note that format names are always uppercase, as in EPUB." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:463 msgid "" "``formats_paths()`` -- return a comma-separated list of colon-separated " "items ``FMT:PATH`` giving the full path to the formats of a book. You can " "use the select function to get the path for a specific format. Note that " "format names are always uppercase, as in EPUB." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:464 msgid "" "``formats_sizes()`` -- return a comma-separated list of colon-separated " "``FMT:SIZE`` items giving the sizes in bytes of the formats of a book. You " "can use the select function to get the size for a specific format. Note that" " format names are always uppercase, as in EPUB." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:465 msgid "" "``fractional_part(x)`` -- returns the value after the decimal point. For " "example, ``fractional_part(3.14)`` returns ``0.14``. Throws an exception if " "``x`` is not a number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:466 msgid "" "``has_cover()`` -- return ``'Yes'`` if the book has a cover, otherwise the " "empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:467 msgid "" "``is_marked()`` -- check whether the book is `marked` in calibre. If it is " "then return the value of the mark, either ``'true'`` (lower case) or a " "comma-separated list of named marks. Returns ``''`` (the empty string) if " "the book is not marked. This function works only in the GUI." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:468 msgid "" "``language_codes(lang_strings)`` -- return the `language codes " "`_ for the " "language names passed in `lang_strings`. The strings must be in the language" " of the current locale. ``Lang_strings`` is a comma-separated list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:469 msgid "" "``list_contains(value, separator, [ pattern, found_val, ]* not_found_val)`` " "-- (Alias of ``in_list``) Interpreting the value as a list of items " "separated by ``separator``, evaluate the ``pattern`` against each value in " "the list. If the ``pattern`` matches any value then return ``found_val``, " "otherwise return ``not_found_val``. The ``pattern`` and ``found_value`` can " "be repeated as many times as desired, permitting returning different values " "depending on the search. The patterns are checked in order. The first match " "is returned. Aliases: ``in_list()``, ``list_contains()``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:470 msgid "" "``list_count(value, separator)`` -- interprets ``value`` as a list of items " "separated by ``separator``, returning the count of items in the list. " "Aliases: ``count()``, ``list_count()``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:471 msgid "" "``list_count_matching(list, pattern, separator)`` -- interprets ``list`` as " "a list of items separated by ``separator``, returning the number of items in" " the list that match the regular expression ``pattern``. Aliases: " "``list_count_matching()``, ``count_matching()``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:472 msgid "" "``list_difference(list1, list2, separator)`` -- return a list made by " "removing from ``list1`` any item found in ``list2`` using a case-insensitive" " comparison. The items in ``list1`` and ``list2`` are separated by " "separator, as are the items in the returned list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:473 msgid "" "``list_equals(list1, sep1, list2, sep2, yes_val, no_val)`` -- return " "``yes_val`` if ``list1`` and `list2` contain the same items, otherwise " "return ``no_val``. The items are determined by splitting each list using the" " appropriate separator character (``sep1`` or ``sep2``). The order of items " "in the lists is not relevant. The comparison is case-insensitive." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:474 msgid "" "``list_intersection(list1, list2, separator)`` -- return a list made by " "removing from ``list1`` any item not found in ``list2``, using a case-" "insensitive comparison. The items in ``list1`` and ``list2`` are separated " "by separator, as are the items in the returned list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:475 msgid "" "``list_re(src_list, separator, include_re, opt_replace)`` -- Construct a " "list by first separating ``src_list`` into items using the ``separator`` " "character. For each item in the list, check if it matches ``include_re``. If" " it does then add it to the list to be returned. If ``opt_replace`` is not " "the empty string then apply the replacement before adding the item to the " "returned list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:476 msgid "" "``list_re_group(src_list, separator, include_re, search_re [, " "template_for_group]*)`` -- Like list_re except replacements are not " "optional. It uses ``re_group(item, search_re, template ...)`` when doing the" " replacements." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:477 msgid "" "``list_remove_duplicates(list, separator)`` -- return a list made by " "removing duplicate items in ``list``. If items differ only in case then the " "last is returned. The items in ``list`` are separated by ``separator``, as " "are the items in the returned list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:478 msgid "" "``list_sort(list, direction, separator)`` -- return ``list`` sorted using a " "case-insensitive lexical sort. If ``direction`` is zero, ``list`` is sorted " "ascending, otherwise descending. The list items are separated by " "``separator``, as are the items in the returned list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:479 msgid "" "``list_split(list_val, sep, id_prefix)`` -- splits ``list_val`` into " "separate values using ``sep``, then assigns the values to local variables " "named ``id_prefix_N`` where N is the position of the value in the list. The " "first item has position 0 (zero). The function returns the last element in " "the list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:481 msgid "Example::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:485 msgid "is equivalent to::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:491 msgid "" "``list_union(list1, list2, separator)`` -- return a list made by merging the" " items in ``list1`` and ``list2``, removing duplicate items using a case-" "insensitive comparison. If items differ in case, the one in ``list1`` is " "used. The items in ``list1`` and ``list2`` are separated by ``separator``, " "as are the items in the returned list. Aliases: ``merge_lists()``, " "``list_union()``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:492 msgid "" "``mod(x, y)`` -- returns the ``floor`` of the remainder of ``x / y``. Throws" " an exception if either ``x`` or ``y`` is not a number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:493 msgid "" "``multiply(x [, y]*)`` -- returns the product of its arguments. Throws an " "exception if any argument is not a number. This function can usually be " "replaced by the ``*`` operator." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:494 msgid "" "``not(value)`` -- returns the string \"1\" if the value is empty, otherwise " "returns the empty string. This function can usually be replaced with the " "unary not (``!``) operator." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:495 msgid "" "``ondevice()`` -- return the string ``'Yes'`` if ``ondevice`` is set, " "otherwise return the empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:496 msgid "" "``or(value [, value]*)`` -- returns the string ``'1'`` if any value is not " "empty, otherwise returns the empty string. You can have as many values as " "you want. This function can usually be replaced by the ``||`` operator. A " "reason it cannot be replaced is if short-circuiting will change the results " "because of side effects." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:497 msgid "" "``print(a [, b]*)`` -- prints the arguments to standard output. Unless you " "start calibre from the command line (``calibre-debug -g``), the output will " "go to a black hole. The ``print`` function always returns the empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:498 msgid "" "``raw_field(lookup_name [, optional_default])`` -- returns the metadata " "field named by ``lookup_name`` without applying any formatting. It evaluates" " and returns the optional second argument ``optional_default`` if the " "field's value is undefined (``None``)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:499 msgid "" "``raw_list(lookup_name, separator)`` -- returns the metadata list named by " "``lookup_name`` without applying any formatting or sorting, with the items " "separated by separator." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:500 msgid "" "``re_group(value, pattern [, template_for_group]*)`` -- return a string " "made by applying the regular expression pattern to ``value`` and replacing " "each matched instance with the the value returned by the corresponding " "template. In :ref:`Template Program Mode `, like for the " "``template`` and the ``eval`` functions, you use ``[[`` for ``{`` and ``]]``" " for ``}``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:502 msgid "" "The following example looks for a series with more than one word and " "uppercases the first word::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:506 msgid "" "``round(x)`` -- returns the nearest integer to ``x``. Throws an exception if" " ``x`` is not a number." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:507 msgid "``series_sort()`` -- returns the series sort value." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:508 msgid "" "``strcat(a [, b]*)`` -- can take any number of arguments. Returns a string " "formed by concatenating all the arguments." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:509 msgid "" "``strcat_max(max, string1 [, prefix2, string2]*)`` -- Returns a string " "formed by concatenating the arguments. The returned value is initialized to " "``string1``. Strings made from ``prefix, string`` pairs are added to the end" " of the value as long as the resulting string length is less than ``max``. " "Prefixes can be empty. Returns ``string1`` even if ``string1`` is longer " "than ``max``. You can pass as many ``prefix, string`` pairs as you wish." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:510 msgid "" "``strcmp(x, y, lt, eq, gt)`` -- does a case-insensitive lexical comparison " "of ``x`` and ``y``. Returns ``lt`` if ``x < y``, ``eq`` if ``x == y``, " "otherwise ``gt``. This function can often be replaced by one of the lexical " "comparison operators (``==``, ``>``, ``<``, etc.)" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:511 msgid "``strlen(value)`` -- Returns the length of the string ``value``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:512 msgid "" "``substr(str, start, end)`` -- returns the ``start``'th through the " "``end``'th characters of ``str``. The first character in ``str`` is the " "zero'th character. If ``end`` is negative, then it indicates that many " "characters counting from the right. If ``end`` is zero, then it indicates " "the last character. For example, ``substr('12345', 1, 0)`` returns " "``'2345'``, and ``substr('12345', 1, -1)`` returns ``'234'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:513 msgid "" "``subtract(x, y)`` -- returns ``x - y``. Throws an exception if either ``x``" " or ``y`` are not numbers. This function can usually be replaced by the " "``-`` operator." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:514 msgid "" "``today()`` -- return a date+time string for today (now). This value is " "designed for use in `format_date` or `days_between`, but can be manipulated " "like any other string. The date is in `ISO " "`_ date/time format." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:515 msgid "" "``template(x)`` -- evaluates ``x`` as a template. The evaluation is done in " "its own context, meaning that variables are not shared between the caller " "and the template evaluation." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:520 msgid "More complex programs in template expressions - Template Program Mode" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:522 msgid "" "`Template Program Mode` (`TPM`) is a blend of :ref:`General Program Mode " "` and :ref:`Single Function Mode `. `TPM` differs" " from Single Function Mode in that it permits writing template expressions " "that refer to other metadata fields, use nested functions, modify variables," " and do arithmetic. It differs from `General Program Mode` in that the " "template is contained between ``{`` and ``}`` characters and doesn't begin " "with the word ``program:``. The program portion of the template is a General" " Program Mode expression list." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:525 msgid "" "Example: assume you want a template to show the series for a book if it has " "one, otherwise show the value of a custom field #genre. You cannot do this " "in the :ref:`Single Function Mode ` because you cannot make " "reference to another metadata field within a template expression. In `TPM` " "you can, as the following expression demonstrates::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:530 msgid "The example shows several things:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:532 msgid "" "`TPM` is used if the expression begins with ``:'`` and ends with ``'``. " "Anything else is assumed to be in :ref:`Single Function Mode `." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:533 msgid "" "the variable ``$`` stands for the field named in the template: the " "expression is operating upon, ``#series`` in this case." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:534 msgid "" "functions must be given all their arguments. There is no default value. For " "example, the standard built-in functions must be given an additional initial" " parameter indicating the source field." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:535 msgid "white space is ignored and can be used anywhere within the expression." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:536 msgid "" "constant strings are enclosed in matching quotes, either ``'`` or ``\"``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:538 msgid "" "All the functions listed under `Single Function Mode` and `General Program " "Mode` can be used in `TPM`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:540 msgid "" "In `TPM`, using ``{`` and ``}`` characters in string literals can lead to " "errors or unexpected results because they confuse the template processor. It" " tries to treat them as template expression boundaries, not characters. In " "some but not all cases you can replace a ``{`` with ``[[`` and a ``}`` with " "`]]`. Generally, if your program contains ``{`` and ``}`` characters then " "you should use `General Program Mode`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:542 msgid "" "As with `General Program Mode`, for functions documented under :ref:`Single " "Function Mode ` you must supply the value the function is to " "act upon as the first parameter in addition to the documented parameters. In" " `TPM` you can use ``$`` to access the value specified by the ``lookup " "name`` for the template expression." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:545 msgid "Stored general program mode templates" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:547 msgid "" ":ref:`General Program Mode ` supports saving templates and " "calling those templates from another template, much like calling stored " "functions. You save templates using " ":guilabel:`Preferences->Advanced->Template functions`. More information is " "provided in that dialog. You call a template the same way you call a " "function, passing positional arguments if desired. An argument can be any " "expression. Examples of calling a template, assuming the stored template is " "named ``foo``:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:549 msgid "``foo()`` -- call the template passing no arguments." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:550 msgid "" "``foo(a, b)`` call the template passing the values of the two variables " "``a`` and ``b``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:551 msgid "" "``foo(if field('series') then field('series_index') else 0 fi)`` -- if the " "book has a ``series`` then pass the ``series_index``, otherwise pass the " "value ``0``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:553 msgid "" "You retrieve the arguments passed in the call to the stored template using " "the ``arguments`` function. It both declares and initializes local " "variables, effectively parameters. The variables are positional; they get " "the value of the value given in the call in the same position. If the " "corresponding parameter is not provided in the call then ``arguments`` " "assigns that variable the provided default value. If there is no default " "value then the variable is set to the empty string. For example, the " "following ``arguments`` function declares 2 variables, ``key``, " "``alternate``::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:557 msgid "Examples, again assuming the stored template is named ``foo``:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:559 msgid "" "``foo('#myseries')`` -- argument ``key`` is assigned the value " "``'myseries'`` and the argument ``alternate`` is assigned the default value " "``'series'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:560 msgid "" "``foo('series', '#genre')`` the variable ``key`` is assigned the value " "``'series'`` and the variable ``alternate`` is assigned the value " "``'#genre'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:561 msgid "" "``foo()`` -- the variable ``key`` is assigned the empty string and the " "variable ``alternate`` is assigned the value ``'series'``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:563 msgid "" "An easy way to test stored templates is using the ``Template tester`` " "dialog. For ease of access give it a keyboard shortcut in " ":guilabel:`Preferences->Advanced->Keyboard shortcuts->Template tester`. " "Giving the ``Stored templates`` dialog a shortcut will help switching more " "rapidly between the tester and editing the stored template's source code." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:566 msgid "Providing additional information to templates" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:568 msgid "" "A developer can choose to pass additional information to the template " "processor, such as application-specific book metadata or information about " "what the processor is being asked to do. A template can access this " "information and use it during the evaluation." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:570 msgid "**Developer: how to pass additional information**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:572 msgid "" "The additional information is a Python dictionary containing pairs " "``variable_name: variable_value`` where the values must be strings. The " "template can access the dict, creating template local variables named " "``variable_name`` containing the value ``variable_value``. The user cannot " "change the name so it is best to use names that won't collide with other " "template local variables, for example by prefixing the name with an " "underscore." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:574 msgid "" "This dict is passed to the template processor (the ``formatter``) using the " "named parameter ``global_vars=your_dict``. The full method signature is::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:582 msgid "**Template writer: how to access the additional information**" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:584 msgid "" "You access the additional information (the ``globals`` dict) in a template " "using the template function::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:588 msgid "" "where ``id`` is any legal variable name. This function checks whether the " "additional information provided by the developer contains the name. If it " "does then the function assigns the provided value to a template local " "variable with that name. If the name is not in the additional information " "and if an ``expression`` is provided, the ``expression`` is evaluated and " "the result is assigned to the local variable. If neither a value nor an " "expression is provided, the function assigns the empty string (``''``) to " "the local variable." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:590 msgid "" "A template can set a value in the ``globals`` dict using the template " "function::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:594 msgid "" "This function sets the ``globals`` dict key:value pair ``id:value`` where " "``value`` is the value of the template local variable ``id``. If that local " "variable doesn't exist then ``value`` is set to the result of evaluating " "``expression``." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:597 msgid "Notes on the difference between modes" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:599 msgid "" "The three program modes, :ref:`Single Function Mode ` (SFM), " ":ref:`Template Program Mode ` (`TPM`), and :ref:`General " "Program Mode ` (`GPM`), work differently. SFM is intended to " "be 'simple' so it hides a lot of programming language bits." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:601 msgid "Differences:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:603 msgid "" "In SFM the value of the column is always passed as an 'invisible' first " "argument to a function included in the template." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:604 msgid "" "SFM doesn't support the difference between variables and strings; all values" " are strings." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:605 msgid "" "The following SFM template returns either the series name or the string \"no" " series\"::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:609 msgid "The equivalent template in `TPM` is ::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:613 msgid "The equivalent template in `GPM` is::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:617 msgid "" "The first argument to ``ifempty`` is the value of the field ``series``. The " "second argument is the string ``no series``. In SFM the first argument, the " "value of the field, is automatically passed (the invisible argument)." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:618 msgid "" "Several template functions, for example ``booksize()`` and " "``current_library_name()``, take no arguments. Because of the 'invisible " "argument' you cannot use these functions in SFM." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:619 msgid "" "Nested functions, where a function calls another function to compute an " "argument, cannot be used in SFM. For example this template, intended to " "return the first 5 characters of the series value uppercased, won't work in " "SFM::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:623 msgid "" "`TPM` and `GPM` support nested functions. The above template in `TPM` would " "be::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:627 msgid "In `GPM` it would be::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:631 msgid "" "As noted in the above :ref:`Template Program Mode ` section, " "using ``{`` and ``}`` characters in `TPM` string literals can lead to errors" " or unexpected results because they confuse the template processor. It tries" " to treat them as template boundaries, not characters. In some but not all " "cases you can replace a ``{`` with ``[[`` and a ``}`` with `]]`. Generally, " "if your program contains ``{`` and ``}`` characters then you should use " "`General Program Mode`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:635 msgid "User-defined Python template functions" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:637 msgid "" "You can add your own Python functions to the template processor. Such " "functions can be used in any of the three template programming modes. The " "functions are added by going to :guilabel:`Preferences -> Advanced -> " "Template functions`. Instructions are shown in that dialog." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:640 msgid "Special notes for save/send templates" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:642 msgid "" "Special processing is applied when a template is used in a `save to disk` or" " `send to device` template. The values of the fields are cleaned, replacing " "characters that are special to file systems with underscores, including " "slashes. This means that field text cannot be used to create folders. " "However, slashes are not changed in prefix or suffix strings, so slashes in " "these strings will cause folders to be created. Because of this, you can " "create variable-depth folder structure." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:644 msgid "" "For example, assume we want the folder structure `series/series_index - " "title`, with the caveat that if series does not exist, then the title should" " be in the top folder. The template to do this is::" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:648 msgid "The slash and the hyphen appear only if series is not empty." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:650 msgid "" "The lookup function lets us do even fancier processing. For example, assume " "that if a book has a series, then we want the folder structure " "`series/series index - title.fmt`. If the book does not have a series then " "we want the folder structure `genre/author_sort/title.fmt`. If the book has " "no genre then we want to use 'Unknown'. We want two completely different " "paths, depending on the value of series." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:652 msgid "To accomplish this, we:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:654 msgid "" "Create a composite field (give it lookup name #aa) containing " "``{series}/{series_index} - {title}``. If the series is not empty, then this" " template will produce `series/series_index - title`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:655 msgid "" "Create a composite field (give it lookup name #bb) containing " "``{#genre:ifempty(Unknown)}/{author_sort}/{title}``. This template produces " "`genre/author_sort/title`, where an empty genre is replaced with `Unknown`." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:656 msgid "" "Set the save template to ``{series:lookup(.,#aa,#bb}``. This template " "chooses composite field ``#aa`` if series is not empty and composite field " "``#bb`` if series is empty. We therefore have two completely different save " "paths, depending on whether or not `series` is empty." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:659 msgid "Templates and plugboards" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:661 msgid "" "Plugboards are used for changing the metadata written into books during " "send-to-device and save-to-disk operations. A plugboard permits you to " "specify a template to provide the data to write into the book's metadata. " "You can use plugboards to modify the following fields: authors, author_sort," " language, publisher, tags, title, title_sort. This feature helps people who" " want to use different metadata in books on devices to solve sorting or " "display issues." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:663 msgid "" "When you create a plugboard, you specify the format and device for which the" " plugboard is to be used. A special device is provided, ``save_to_disk``, " "that is used when saving formats (as opposed to sending them to a device). " "Once you have chosen the format and device, you choose the metadata fields " "to change, providing templates to supply the new values. These templates are" " `connected` to their destination fields, hence the name `plugboards`. You " "can of course use composite columns in these templates." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:665 msgid "" "When a plugboard might apply (Content server, save to disk, or send to " "device), calibre searches the defined plugboards to choose the correct one " "for the given format and device. For example, to find the appropriate " "plugboard for an EPUB book being sent to an ANDROID device, calibre searches" " the plugboards using the following search order:" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:669 msgid "" "a plugboard with an exact match on format and device, e.g., ``EPUB`` and " "``ANDROID``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:670 msgid "" "a plugboard with an exact match on format and the special ``any device`` " "choice, e.g., ``EPUB`` and ``any device``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:671 msgid "" "a plugboard with the special ``any format`` choice and an exact match on " "device, e.g., ``any format`` and ``ANDROID``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:672 msgid "a plugboard with ``any format`` and ``any device``" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:674 msgid "" "The tags and authors fields have special treatment, because both of these " "fields can hold more than one item. A book can have many tags and many " "authors. When you specify that one of these two fields is to be changed, the" " template's result is examined to see if more than one item is there. For " "tags, the result is cut apart wherever calibre finds a comma. For example, " "if the template produces the value ``Thriller, Horror``, then the result " "will be two tags, ``Thriller`` and ``Horror``. There is no way to put a " "comma in the middle of a tag." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:677 msgid "" "The same thing happens for authors, but using a different character for the " "cut, a `&` (ampersand) instead of a comma. For example, if the template " "produces the value ``Blogs, Joe&Posts, Susan``, then the book will end up " "with two authors, ``Blogs, Joe`` and ``Posts, Susan``. If the template " "produces the value ``Blogs, Joe;Posts, Susan``, then the book will have one " "author with a rather strange name." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:679 msgid "" "Plugboards affect the metadata written into the book when it is saved to " "disk or written to the device. Plugboards do not affect the metadata used by" " ``save to disk`` and ``send to device`` to create the file names. Instead, " "file names are constructed using the templates entered on the appropriate " "preferences window." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:682 msgid "Tips" msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:684 msgid "" "Use the Template Tester to test templates. Add the tester to the context " "menu for books in the library and/or give it a keyboard shortcut." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:685 msgid "" "Templates can use other templates by referencing composite columns built " "with the desired template. Alternatively, you can use Stored Templates." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:686 msgid "" "In a plugboard, you can set a field to empty (or whatever is equivalent to " "empty) by using the special template ``{}``. This template will always " "evaluate to an empty string." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:687 msgid "" "The technique described above to show numbers even if they have a zero value" " works with the standard field series_index." msgstr "" #: ../../__w/calibre/calibre/manual/template_lang.rst:692 msgid "Function reference" msgstr ""