Debian Codegraph @

translations/manual/zh_CN/develop.po

raw
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 # Lindsey Li <[email protected]>, 2016
7 # CalbireC <[email protected]>, 2020
8 # RERBIN MA, 2025-2026
9 # tony shen <[email protected]>, 2020,2023-2024
10 # yyngfive <[email protected]>, 2023
11 # ZeYu Zhang <[email protected]>, 2016
12 # CalbireC <[email protected]>, 2020
13 msgid ""
14 msgstr ""
15 "Project-Id-Version: calibre\n"
16 "Report-Msgid-Bugs-To: \n"
17 "POT-Creation-Date: 2026-08-06 04:29+0000\n"
18 "PO-Revision-Date: 2014-06-17 08:34+0000\n"
19 "Last-Translator: RERBIN MA, 2025-2026\n"
20 "Language-Team: Chinese (China) (http://app.transifex.com/calibre/calibre/language/zh_CN/)\n"
21 "MIME-Version: 1.0\n"
22 "Content-Type: text/plain; charset=UTF-8\n"
23 "Content-Transfer-Encoding: 8bit\n"
24 "Language: zh_CN\n"
25 "Plural-Forms: nplurals=1; plural=0;\n"
26
27 #: ../../../__w/calibre/calibre/manual/develop.rst:4
28 msgid "Setting up a calibre development environment"
29 msgstr "设置Calibre开发环境"
30
31 #: ../../../__w/calibre/calibre/manual/develop.rst:6
32 msgid ""
33 "calibre is completely open source, licensed under the `GNU GPL v3 "
34 "<https://www.gnu.org/licenses/gpl.html>`_. This means that you are free to "
35 "download and modify the program to your heart's content. In this section, "
36 "you will learn how to get a calibre development environment set up on the "
37 "operating system of your choice. calibre is written primarily in `Python "
38 "<https://www.python.org>`_ with some C/C++ code for speed and system "
39 "interfacing. Note that calibre requires at least Python 3.8."
40 msgstr "calibre是一个完全意义上的开源程序,它采用`GNU GPL v3<https://www.gnu.org/licenses/gpl.html>_`许可证。这意味着你可以按照自己的想法下载并修改该程序。在本节,你将学会如何在你选择的操作系统下建立calibre开发环境。calibre主要使用`Python <https://www.python.org>`_ 编程,为了兼顾系统接口与速度使用了一些C/C+代码。注意,calibre要求Python 3.8及以上版本。"
41
42 #: ../../../__w/calibre/calibre/manual/develop.rst:14
43 msgid "Contents"
44 msgstr "目录"
45
46 #: ../../../__w/calibre/calibre/manual/develop.rst:17
47 msgid "Design philosophy"
48 msgstr "设计理念"
49
50 #: ../../../__w/calibre/calibre/manual/develop.rst:19
51 msgid ""
52 "calibre has its roots in the Unix world, which means that its design is "
53 "highly modular. The modules interact with each other via well defined "
54 "interfaces. This makes adding new features and fixing bugs in calibre very "
55 "easy, resulting in a frenetic pace of development. Because of its roots, "
56 "calibre has a comprehensive command line interface for all its functions, "
57 "documented in :doc:`generated/en/cli-index`."
58 msgstr "calibre源自Unix,它的设计是高度模块化的。模块间相互作用通过定义良好的接口实现。这使在calibre中添加新功能或者修改bug十分方便,这种便利性使calibre的开发很迅速。正因这种模块化设计思想,calibre对所有功能,都有一个完整的命令行接口,可以参考 `generated/zh_CN/cli-index`进行了解。"
59
60 #: ../../../__w/calibre/calibre/manual/develop.rst:24
61 msgid ""
62 "The modular design of calibre is expressed via ``Plugins``. There is a "
63 ":ref:`tutorial <customize>` on writing calibre plugins. For example, adding "
64 "support for a new device to calibre typically involves writing fewer than "
65 "100 lines of code in the form of a device driver plugin. You can browse the "
66 "`built-in drivers "
67 "<https://github.com/kovidgoyal/calibre/tree/master/src/calibre/devices>`_. "
68 "Similarly, adding support for new conversion formats involves writing "
69 "input/output format plugins. Another example of the modular design is the "
70 ":ref:`recipe system <news>` for fetching news. For more examples of plugins "
71 "designed to add features to calibre, see the `Index of plugins "
72 "<https://www.mobileread.com/forums/showthread.php?p=1362767#post1362767>`_."
73 msgstr "模块化设计的思想通过“插件”体现出来。关于“插件”的编写,这里有一份教程 :ref:`tutorial <customize>`。举个例子,如果要给calibre添加一个新的设备支持,一般只需要利用设备驱动插件范式写不到100行代码即可。你能从获取`built-in drivers <https://github.com/kovidgoyal/calibre/tree/master/src/calibre/devices>`_。类似地,为新的转换格式添加支持,也只需要改写输入/输出格式插件。模块化设计的另一个例子是抓取新闻,`recipe system <news>`。对于更多可加入calibre的插件,可以参考 `Index of plugins <https://www.mobileread.com/forums/showthread.php?p=1362767#post1362767>`_。"
74
75 #: ../../../__w/calibre/calibre/manual/develop.rst:34
76 msgid "Code layout"
77 msgstr "代码布局"
78
79 #: ../../../__w/calibre/calibre/manual/develop.rst:36
80 msgid ""
81 "All the calibre Python code is in the ``calibre`` package. This package "
82 "contains the following main sub-packages"
83 msgstr "所有calibre的Python代码都在``calibre``包中。它包含了以下的主要子包。"
84
85 #: ../../../__w/calibre/calibre/manual/develop.rst:38
86 msgid ""
87 "devices - All the device drivers. Just look through some of the built-in "
88 "drivers to get an idea for how they work."
89 msgstr "设备 -- 所有的设备驱动器。通过浏览部分内置驱动器来获取他们的运作方式。"
90
91 #: ../../../__w/calibre/calibre/manual/develop.rst:40
92 msgid ""
93 "For details, see: ``devices.interface`` which defines the interface "
94 "supported by device drivers and ``devices.usbms`` which defines a generic "
95 "driver that connects to a USBMS device. All USBMS based drivers in calibre "
96 "inherit from it."
97 msgstr "更多细节可以参考,:``devices.interface``。这其中定义了被驱动器支持的接口,。另外``devices.usbms``也值得关注,它定义了一个连接了usbms设备的通用驱动器。 在calibre中,所有的基于usbms的驱动器都继承自它.。"
98
99 #: ../../../__w/calibre/calibre/manual/develop.rst:43
100 msgid ""
101 "e-books - All the e-book conversion/metadata code. A good starting point is"
102 " ``calibre.ebooks.conversion.cli`` which is the module powering the "
103 ":command:`ebook-convert` command. The conversion process is controlled via "
104 "``conversion.plumber``. The format independent code is all in ``ebooks.oeb``"
105 " and the format dependent code is in ``ebooks.format_name``."
106 msgstr "电子书 - 所有电子书转换/元数据代码。 一个好的起点是“calibre.ebooks.conversion.cli”,它是为 ebook-convert 命令提供动力的模块。 转换过程是通过“conversion.plumber”控制的。 与格式无关的代码全部在“ebooks.oeb”中,与格式相关的代码在“ebooks.format_name”中。"
107
108 #: ../../../__w/calibre/calibre/manual/develop.rst:47
109 msgid ""
110 "Metadata reading, writing, and downloading is all in ``ebooks.metadata``"
111 msgstr "元数据的读取、写入和下载都在``ebooks.metadata``中"
112
113 #: ../../../__w/calibre/calibre/manual/develop.rst:48
114 msgid ""
115 "Conversion happens in a pipeline, for the structure of the pipeline, see "
116 ":ref:`conversion-introduction`. The pipeline consists of an input plugin, "
117 "various transforms and an output plugin. The code that constructs and drives"
118 " the pipeline is in :file:`plumber.py`. The pipeline works on a "
119 "representation of an e-book that is like an unzipped epub, with manifest, "
120 "spine, toc, guide, html content, etc. The class that manages this "
121 "representation is OEBBook in ``ebooks.oeb.base``. The various "
122 "transformations that are applied to the book during conversions live in "
123 ":file:`oeb/transforms/*.py`. And the input and output plugins live in "
124 ":file:`conversion/plugins/*.py`."
125 msgstr "转换发生在传输途径中,传输途径的结构请参见“转换简介”。 该传输途径由输入插件、各种转换和输出插件组成。 构建和驱动传输途径的代码位于“plumber.py”中。 该传输途径适用于电子书的表示,就像解压的 epub,具有清单、书脊、目录、指南、html 内容等。管理此表示的类是“ebooks.oeb.base”中的 OEBBook 。 在转换过程中应用于本书的各种转换位于“oeb/transforms/*.py”中。 输入和输出插件位于“conversion/plugins/*.py”中。"
126
127 #: ../../../__w/calibre/calibre/manual/develop.rst:58
128 msgid ""
129 "E-book editing happens using a different container object. It is documented "
130 "in :ref:`polish_api`."
131 msgstr "电子书编辑使用不同的容器对象。详见 `polish_api`。"
132
133 #: ../../../__w/calibre/calibre/manual/develop.rst:61
134 msgid ""
135 "db - The database back-end. See :ref:`db_api` for the interface to the "
136 "calibre library."
137 msgstr "db -- 数据库后端。参考`db_api`了解calibre的接口。"
138
139 #: ../../../__w/calibre/calibre/manual/develop.rst:63
140 msgid "Content server: ``srv`` is the calibre Content server."
141 msgstr "内容服务器: \"srv\"是calibre的内容服务器。"
142
143 #: ../../../__w/calibre/calibre/manual/develop.rst:65
144 msgid ""
145 "gui2 - The Graphical User Interface. GUI initialization happens in "
146 "``gui2.main`` and ``gui2.ui``. The e-book-viewer is in ``gui2.viewer``. The "
147 "e-book editor is in ``gui2.tweak_book``."
148 msgstr "gui2 -- 图形用户接口。GUI初始化位于``gui2.main``与``gui2.ui``。电子书浏览器位于``gui2.viewer``。电子书编辑器位于``gui2.tweak_book``。"
149
150 #: ../../../__w/calibre/calibre/manual/develop.rst:67
151 msgid ""
152 "If you want to locate the entry points for all the various calibre "
153 "executables, look at the ``entry_points`` structure in `linux.py "
154 "<https://github.com/kovidgoyal/calibre/blob/master/src/calibre/linux.py>`_."
155 msgstr "如果要定位所有各种Calibre可执行文件的入口点,请在“linux.py <https://github.com/kovidgoyal/calibre/blob/master/src/calibre/linux.py>”中查看``entry_points``结构_。"
156
157 #: ../../../__w/calibre/calibre/manual/develop.rst:71
158 msgid ""
159 "If you need help understanding the code, post in the `development forum "
160 "<https://www.mobileread.com/forums/forumdisplay.php?f=240>`_ and you will "
161 "most likely get help from one of calibre's many developers."
162 msgstr "如果你不理解某些代码,你可以在`development forum <https://www.mobileread.com/forums/forumdisplay.php?f=240>`_中提出,你很可能会得到其他开发者的帮助。"
163
164 #: ../../../__w/calibre/calibre/manual/develop.rst:75
165 msgid "Getting the code"
166 msgstr "得到代码"
167
168 #: ../../../__w/calibre/calibre/manual/develop.rst:77
169 msgid ""
170 "You can get the calibre source code in two ways, using a version control "
171 "system or directly downloading a :website_base:`tarball <dist/src>`."
172 msgstr "你可以通过两种方式获取calibre的源代码:使用版本控制系统或者直接下载:website_base:`源码<dist/src>`"
173
174 #: ../../../__w/calibre/calibre/manual/develop.rst:80
175 msgid ""
176 "calibre uses `Git <https://www.git-scm.com/>`_, a distributed version "
177 "control system. Git is available on all the platforms calibre supports. "
178 "After installing Git, you can get the calibre source code with the command::"
179 msgstr "calibre使用`Git <https://www.git-scm.com/>`_,一个分布式版本控制系统。Git在所有calibre支持的平台上均可用。安装Git后,你就可以通过下面命令获得源码:"
180
181 #: ../../../__w/calibre/calibre/manual/develop.rst:86
182 msgid ""
183 "On Windows you will need the complete path name, that will be something like"
184 " :file:`C:\\\\Program Files\\\\Git\\\\git.exe`."
185 msgstr "在 Windows 上,您将需要完整的路径名,类似于文件“C:\\\\Program Files\\\\Git\\\\git.exe”。"
186
187 #: ../../../__w/calibre/calibre/manual/develop.rst:88
188 msgid ""
189 "calibre is a very large project with a very long source control history, so "
190 "the above can take a while (10 mins to an hour depending on your internet "
191 "speed)."
192 msgstr "calibre是一个拥有很长时间版本管理历史的大项目,所以下载源码可能需要一点时间(10分钟到1小时,取决于你的网速)。"
193
194 #: ../../../__w/calibre/calibre/manual/develop.rst:91
195 msgid ""
196 "If you want to get the code faster, the source code for the latest release "
197 "is always available as an :website_base:`archive <dist/src>`."
198 msgstr "如果你想更快地获取源码,可以从:website_base:`归档 <dist/src>`页面下载最新的版本。"
199
200 #: ../../../__w/calibre/calibre/manual/develop.rst:94
201 msgid "To update a branch to the latest code, use the command::"
202 msgstr "升级一个分支到最新版本,可以使用命令:"
203
204 #: ../../../__w/calibre/calibre/manual/develop.rst:98
205 msgid ""
206 "You can also browse the code at `GitHub "
207 "<https://github.com/kovidgoyal/calibre>`_."
208 msgstr "你也可以从`GitHub <https://github.com/kovidgoyal/calibre>`_上获得源码。"
209
210 #: ../../../__w/calibre/calibre/manual/develop.rst:101
211 msgid "Submitting your changes to be included"
212 msgstr "提交要包含的修改"
213
214 #: ../../../__w/calibre/calibre/manual/develop.rst:103
215 msgid ""
216 "If you only plan to make a few small changes, you can make your changes and "
217 "create a \"merge directive\" which you can then attach to a ticket in the "
218 "calibre `bug tracker <https://bugs.launchpad.net/calibre>`_. To do this, "
219 "make your changes, then run::"
220 msgstr "如果你只计划做一些小修改,你可以做出修改并创建一个\"merge directive\",然后将其附加到calibre的`bug tracker <https://bugs.launchpad.net/calibre>`_中。如果需要这样做,可以使用下列命令:"
221
222 #: ../../../__w/calibre/calibre/manual/develop.rst:111
223 msgid ""
224 "This will create a :file:`my-changes` file in the current folder, simply "
225 "attach that to a ticket on the calibre `bug tracker "
226 "<https://bugs.launchpad.net/calibre>`_. Note that this will include *all* "
227 "the commits you have made. If you only want to send some commits, you have "
228 "to change ``origin/master`` above. To send only the last commit, use::"
229 msgstr "这将在当前文件夹中创建一个文件:`my changes'文件,只需将其附加到calibre `bug tracker上的票证上即可<https://bugs.launchpad.net/calibre>`_。请注意,这将包括您所做的所有提交。如果您只想发送一些提交,则必须更改上面的“origin/master”。要只发送最后一次提交,请使用:"
230
231 #: ../../../__w/calibre/calibre/manual/develop.rst:119
232 msgid ""
233 "To send the last *n* commits, replace *1* with *n*, for example, for the "
234 "last 3 commits::"
235 msgstr "要发送最后 *n* 次提交,请将 *1* 替换为 *n*,例如,对于最后 3 次提交:"
236
237 #: ../../../__w/calibre/calibre/manual/develop.rst:124
238 msgid "Be careful to not include merges when using ``HEAD~n``."
239 msgstr "当使用``HEAD~n``时,小心不要包含合并。"
240
241 #: ../../../__w/calibre/calibre/manual/develop.rst:126
242 msgid ""
243 "If you plan to do a lot of development on calibre, then the best method is "
244 "to create a `GitHub <https://github.com>`__ account. Below is a basic guide "
245 "to setting up your own fork of calibre in a way that will allow you to "
246 "submit pull requests for inclusion into the main calibre repository:"
247 msgstr "如果您计划在 calibre 上进行大量开发,那么最好的方法是创建一个 `GitHub <https://github.com>`__ 帐户。 以下是设置您自己的 calibre 分支的基本指南,该指南允许您提交拉取请求以包含到主 calibre 存储库中:"
248
249 #: ../../../__w/calibre/calibre/manual/develop.rst:131
250 msgid ""
251 "Setup git on your machine as described in this article: `Setup Git "
252 "<https://help.github.com/articles/set-up-git>`_"
253 msgstr "按这篇文章在你的电脑上安装git:`Setup Git <https://help.github.com/articles/set-up-git>`_"
254
255 #: ../../../__w/calibre/calibre/manual/develop.rst:132
256 msgid ""
257 "Setup ssh keys for authentication to GitHub, as described here: `Generating "
258 "SSH keys <https://help.github.com/articles/generating-ssh-keys>`_"
259 msgstr "设置ssh密钥以进行GitHub身份验证,参考这里:`Generating SSH keys <https://help.github.com/articles/generating-ssh-keys>`_"
260
261 #: ../../../__w/calibre/calibre/manual/develop.rst:133
262 msgid ""
263 "Go to https://github.com/kovidgoyal/calibre and click the :guilabel:`Fork` "
264 "button."
265 msgstr "访问 https://github.com/kovidgoyal/calibre 并单击“Fork”按钮。"
266
267 #: ../../../__w/calibre/calibre/manual/develop.rst:134
268 msgid "In a Terminal do::"
269 msgstr "在终端下这样做:"
270
271 #: ../../../__w/calibre/calibre/manual/develop.rst:139
272 msgid ""
273 "Replace <username> above with your GitHub username. That will get your fork "
274 "checked out locally."
275 msgstr "用你的GitHub用户名代替<username>。这将使本地校验你的分支。"
276
277 #: ../../../__w/calibre/calibre/manual/develop.rst:140
278 msgid ""
279 "You can make changes and commit them whenever you like. When you are ready "
280 "to have your work merged, do a::"
281 msgstr "无论何时你都能修改代码并提交。当你准备好待合并部分时,这样做:"
282
283 #: ../../../__w/calibre/calibre/manual/develop.rst:144
284 msgid ""
285 "and go to ``https://github.com/<username>/calibre`` and click the "
286 ":guilabel:`Pull Request` button to generate a pull request that can be "
287 "merged."
288 msgstr "进入 ``https://github.com/<username>/calibre`` 点击 :guilabel:`Pull Request` 按钮,产生一个可被合并的pull请求。"
289
290 #: ../../../__w/calibre/calibre/manual/develop.rst:145
291 msgid ""
292 "You can update your local copy with code from the main repo at any time by "
293 "doing::"
294 msgstr "你能从主仓库中更新你的本地代码副本,使用:"
295
296 #: ../../../__w/calibre/calibre/manual/develop.rst:150
297 msgid ""
298 "You should also keep an eye on the calibre `development forum "
299 "<https://www.mobileread.com/forums/forumdisplay.php?f=240>`_. Before making "
300 "major changes, you should discuss them in the forum or contact Kovid "
301 "directly (his email address is all over the source code)."
302 msgstr "您还应该关注 calibre `开发论坛 <https://www.mobileread.com/forums/forumdisplay.php?f=240>`_。 在进行重大更改之前,您应该在论坛中讨论它们或直接联系 Kovid(他的电子邮件地址遍布源代码)。"
303
304 #: ../../../__w/calibre/calibre/manual/develop.rst:156
305 msgid "Windows development environment"
306 msgstr "Windows开发环境"
307
308 #: ../../../__w/calibre/calibre/manual/develop.rst:158
309 #: ../../../__w/calibre/calibre/manual/develop.rst:192
310 #: ../../../__w/calibre/calibre/manual/develop.rst:229
311 msgid ""
312 "You must also get the calibre source code separately as described above."
313 msgstr "你必须想上文所述的那样先得到calibre的源码。"
314
315 #: ../../../__w/calibre/calibre/manual/develop.rst:160
316 msgid ""
317 "Install calibre normally, using the `Windows installer <https://calibre-"
318 "ebook.com/download_windows>`__. Then open a Command Prompt and change to the"
319 " previously checked out calibre code folder. For example::"
320 msgstr "正常安装Calibre,使用`Windows Installer<https://calibre-ebook.com/download_windows>`__。然后打开命令提示符并切换到先前检出的口径代码文件夹。例如:"
321
322 #: ../../../__w/calibre/calibre/manual/develop.rst:165
323 #: ../../../__w/calibre/calibre/manual/develop.rst:241
324 msgid "calibre is the folder that contains the src and resources sub-folders."
325 msgstr "Calibre是包含src和resource子文件夹的文件夹。"
326
327 #: ../../../__w/calibre/calibre/manual/develop.rst:167
328 msgid ""
329 "The next step is to set the environment variable ``CALIBRE_DEVELOP_FROM`` to"
330 " the absolute path of the src folder. So, following the example above, it "
331 "would be ``C:\\Users\\kovid\\work\\calibre\\src``. `Here is a short guide "
332 "<https://docs.python.org/using/windows.html#excursus-setting-environment-"
333 "variables>`_ to setting environment variables on Windows."
334 msgstr "下一步是将环境变量``CALIBRE_DEVELOP_FROM``设置为src文件夹的绝对路径。因此,按照上面的示例,它应该是``C:\\Users\\kovid\\work\\calibre\\src`。以下是<https://docs.python.org/using/windows.html#excursus-setting-environment-variables>`_在Windows上设置环境变量的简短指南。"
335
336 #: ../../../__w/calibre/calibre/manual/develop.rst:172
337 msgid ""
338 "Once you have set the environment variable, open a new command prompt and "
339 "check that it was correctly set by using the command::"
340 msgstr "一旦你设置了环境变量,你可以打开一个新的命令行,通过下面的命令检查环境变量是否设置成功:"
341
342 #: ../../../__w/calibre/calibre/manual/develop.rst:177
343 #: ../../../__w/calibre/calibre/manual/develop.rst:260
344 msgid ""
345 "Setting this environment variable means that calibre will now load all its "
346 "Python code from the specified location."
347 msgstr "设置环境变量意味着calibre现在可以从指定位置载入它的所有Python代码。"
348
349 #: ../../../__w/calibre/calibre/manual/develop.rst:179
350 msgid ""
351 "That's it! You are now ready to start hacking on the calibre code. For "
352 "example, open the file :file:`src\\\\calibre\\\\__init__.py` in your "
353 "favorite editor and add the line::"
354 msgstr "就是这样!你已经可以开始为calibre编写代码了。举例。用你最喜欢的编辑器打开文件 :file:`src\\\\calibre\\\\__init__.py` ,在文件开头添加这么一行:"
355
356 #: ../../../__w/calibre/calibre/manual/develop.rst:184
357 #: ../../../__w/calibre/calibre/manual/develop.rst:267
358 msgid ""
359 "near the top of the file. Now run the command :command:`calibredb`. The very"
360 " first line of output should be ``Hello, world!``."
361 msgstr "靠近文件顶部。 现在运行命令“calibredb”。 输出的第一行应该是“Hello, world!”。"
362
363 #: ../../../__w/calibre/calibre/manual/develop.rst:186
364 msgid ""
365 "You can also setup a calibre development environment inside the free "
366 "Microsoft Visual Studio, if you like, following the instructions `here "
367 "<https://www.mobileread.com/forums/showthread.php?t=251201>`_."
368 msgstr "你也可以通过Microsoft Visual Studio建立calibre开发环境。如果你希望这么做,可以参考这里的教程 `here <https://www.mobileread.com/forums/showthread.php?t=251201>`_ 。"
369
370 #: ../../../__w/calibre/calibre/manual/develop.rst:190
371 msgid "macOS development environment"
372 msgstr "macOS开发环境"
373
374 #: ../../../__w/calibre/calibre/manual/develop.rst:194
375 msgid ""
376 "Install calibre normally using the `provided .dmg <https://calibre-"
377 "ebook.com/download_osx>`__. Then open a Terminal and change to the "
378 "previously checked out calibre code folder, for example::"
379 msgstr "使用`提供的.dmg<https://calibre-ebook.com/download_osx>`__.正常安装Calibre。然后打开终端并切换到之前检出的口径代码文件夹,例如:"
380
381 #: ../../../__w/calibre/calibre/manual/develop.rst:199
382 msgid ""
383 "calibre is the folder that contains the src and resources sub-folders. The "
384 "calibre command line tools are found inside the calibre app bundle, in "
385 ":file:`/Applications/calibre.app/Contents/MacOS` you should add this folder "
386 "to your PATH environment variable, if you want to run the command line tools"
387 " easily."
388 msgstr "Calibre是包含src和resource子文件夹的文件夹。Calibre命令行工具位于Calibre应用程序包中,在:file:`/Applications/calibre.app/Contents/MacOS`中,如果您希望轻松运行命令行工具,则应将此文件夹添加到PATH环境变量中。"
389
390 #: ../../../__w/calibre/calibre/manual/develop.rst:205
391 msgid ""
392 "The next step is to create a bash script that will set the environment "
393 "variable ``CALIBRE_DEVELOP_FROM`` to the absolute path of the src folder "
394 "when running calibre in debug mode."
395 msgstr "下一步是创建一个bash脚本,该脚本将在调试模式下运行Calibre时将环境变量``CALIBRE_DEVELOP_FROM``设置为src文件夹的绝对路径。"
396
397 #: ../../../__w/calibre/calibre/manual/develop.rst:208
398 msgid "Create a plain text file::"
399 msgstr "创建一个空文本文件:"
400
401 #: ../../../__w/calibre/calibre/manual/develop.rst:214
402 msgid ""
403 "Save this file as :file:`/usr/local/bin/calibre-develop`, then set its "
404 "permissions so that it can be executed::"
405 msgstr "将此文件保存为 “/usr/local/bin/calibre-develop”,然后设置其权限以便可以执行:"
406
407 #: ../../../__w/calibre/calibre/manual/develop.rst:218
408 msgid "Once you have done this, run::"
409 msgstr "一旦你完成上述步骤,然后可以运行:"
410
411 #: ../../../__w/calibre/calibre/manual/develop.rst:222
412 msgid ""
413 "You should see some diagnostic information in the Terminal window as calibre"
414 " starts up, and you should see an asterisk after the version number in the "
415 "GUI window, indicating that you are running from source."
416 msgstr "当calibre启动时,你最好看终端上的诊断信息。你也应该注意到GUI界面的版本后有一个*号,这表示你从源码运行程序。"
417
418 #: ../../../__w/calibre/calibre/manual/develop.rst:227
419 msgid "Linux development environment"
420 msgstr "Linux开发环境"
421
422 #: ../../../__w/calibre/calibre/manual/develop.rst:231
423 msgid ""
424 "calibre is primarily developed on Linux. You have two choices in setting up "
425 "the development environment. You can install the calibre binary as normal "
426 "and use that as a runtime environment to do your development. This approach "
427 "is similar to that used in Windows and macOS. Alternatively, you can install"
428 " calibre from source. Instructions for setting up a development environment "
429 "from source are in the INSTALL file in the source tree. Here we will address"
430 " using the binary as a runtime, which is the recommended method."
431 msgstr "calibre主要开发环境是Linux。你有两种方法配置开发环境。你可以正常安装calibre,在运行时环境下完成开发。这个方法与Windows与macOS开发类似。或者,从源码进行安装calibre。从源码配置开发环境的命令在源码树中的INSTALL文件。接下来我们将使用第一种方法,这也是推荐的方法。"
432
433 #: ../../../__w/calibre/calibre/manual/develop.rst:237
434 msgid ""
435 "Install calibre using the `binary installer <https://calibre-"
436 "ebook.com/download_linux>`_. Then open a terminal and change to the "
437 "previously checked out calibre code folder, for example::"
438 msgstr "使用`二进制安装程序<https://calibre-ebook.com/download_linux>`_.安装Calibre。然后打开终端,切换到之前检出的calibre代码文件夹,例如:"
439
440 #: ../../../__w/calibre/calibre/manual/develop.rst:243
441 msgid ""
442 "The next step is to set the environment variable ``CALIBRE_DEVELOP_FROM`` to"
443 " the absolute path of the src folder. So, following the example above, it "
444 "would be ``/home/kovid/work/calibre/src``. How to set environment variables "
445 "depends on your Linux distribution and what shell you are using."
446 msgstr "下一步是将环境变量``CALIBRE_DEPLE_FROM``设置为src文件夹的绝对路径。因此,按照上面的示例,它应该是``/home/kovid/work/calibre/src``。如何设置环境变量取决于您的Linux发行版以及您使用的是什么Shell。"
447
448 #: ../../../__w/calibre/calibre/manual/develop.rst:248
449 msgid ""
450 "It is recommended to use the binary installer provided from upstream. Should"
451 " you insist on using a package provided by your distribution, use the "
452 "``CALIBRE_PYTHON_PATH`` and ``CALIBRE_RESOURCES_PATH`` variables instead. "
453 "You can get these by running ``calibre-debug --paths``. But note that "
454 "distribution calibre packages are often terminally broken and are completely"
455 " unsupported."
456 msgstr "建议使用上游提供的二进制安装程序。如果您坚持使用发行版提供的软件包,请改用“CALIBRE_PYTHON_PATH”和“CALIBRE_RESOURCES_PATH”变量。您可以通过运行“calibre-debug --paths”获取这些变量。但请注意,发行版中的 calibre 软件包通常存在问题,并且完全不受支持。"
457
458 #: ../../../__w/calibre/calibre/manual/develop.rst:255
459 msgid ""
460 "Once you have set the environment variable, open a new terminal and check "
461 "that it was correctly set by using the command::"
462 msgstr "一旦你设置了环境变量,打开一个新终端,检查环境变量是否设置正确,使用命令:"
463
464 #: ../../../__w/calibre/calibre/manual/develop.rst:262
465 msgid ""
466 "That's it! You are now ready to start hacking on the calibre code. For "
467 "example, open the file :file:`src/calibre/__init__.py` in your favorite "
468 "editor and add the line::"
469 msgstr "就是这样! 现在您已准备好开始破解 calibre 代码。 例如,在您喜欢的编辑器中打开文件 “src/calibre/__init__.py”并添加以下行:"
470
471 #: ../../../__w/calibre/calibre/manual/develop.rst:270
472 msgid ""
473 "Having separate \"normal\" and \"development\" calibre installs on the same "
474 "computer"
475 msgstr "在一台电脑上同时安装正常模式与开发模式的calibre"
476
477 #: ../../../__w/calibre/calibre/manual/develop.rst:272
478 msgid ""
479 "The calibre source tree is very stable and rarely breaks, but if you feel "
480 "the need to run from source on a separate test library and run the released "
481 "calibre version with your everyday library, you can achieve this easily "
482 "using .bat files or shell scripts to launch calibre. The example below shows"
483 " how to do this on Windows using .bat files (the instructions for other "
484 "platforms are the same, just use a shell script instead of a .bat file)"
485 msgstr "calibre源码树非常稳定,很少崩溃,但如果你需要从源码运行一个测试书库并且你还要运行released版本的calibre作为日常使用。你能方便地通过批处理文件或者shell脚本启动calibre。下面的例子展示如何在Windows上通过批处理文件启动calibre(其他平台的命令也是一样的,只是用shell脚本代替批处理文件)。"
486
487 #: ../../../__w/calibre/calibre/manual/develop.rst:277
488 msgid "To launch the release version of calibre with your everyday library:"
489 msgstr "用常用库启动发布版本的calibre:"
490
491 #: ../../../__w/calibre/calibre/manual/develop.rst:279
492 msgid "calibre-normal.bat::"
493 msgstr "calibre-normal.bat:"
494
495 #: ../../../__w/calibre/calibre/manual/develop.rst:283
496 msgid "calibre-dev.bat::"
497 msgstr "calibre-dev.bat:"
498
499 #: ../../../__w/calibre/calibre/manual/develop.rst:290
500 msgid "Debugging tips"
501 msgstr "Debug技巧"
502
503 #: ../../../__w/calibre/calibre/manual/develop.rst:292
504 msgid ""
505 "Python is a dynamically typed language with excellent facilities for "
506 "introspection. Kovid wrote the core calibre code without once using a "
507 "debugger. There are many strategies to debug calibre code:"
508 msgstr "Python 是一门拥有动态类型的编程语言。它拥有着出色的内省功能。 Kovid 在没有使用调试器的情况下,完成了calibre的核心代码。这里给出一些debug的策略:"
509
510 #: ../../../__w/calibre/calibre/manual/develop.rst:297
511 msgid "Using print statements"
512 msgstr "使用print语句"
513
514 #: ../../../__w/calibre/calibre/manual/develop.rst:299
515 msgid ""
516 "This is Kovid's favorite way to debug. Simply insert print statements at "
517 "points of interest and run your program in the terminal. For example, you "
518 "can start the GUI from the terminal as::"
519 msgstr "这是Kovid最喜欢的Debug方式。只需要在目标点插入print语句,然后在终端运行程序。举例,你能从终端打开GUI界面,像这样:"
520
521 #: ../../../__w/calibre/calibre/manual/develop.rst:304
522 msgid "Similarly, you can start the E-book viewer as::"
523 msgstr "同样,您可以通过以下方式启动电子书阅读器:"
524
525 #: ../../../__w/calibre/calibre/manual/develop.rst:308
526 msgid "The e-book editor can be started as::"
527 msgstr "可以通过以下方式启动电子书编辑器:"
528
529 #: ../../../__w/calibre/calibre/manual/develop.rst:313
530 msgid "Using an interactive Python interpreter"
531 msgstr "使用交互式Python解释器"
532
533 #: ../../../__w/calibre/calibre/manual/develop.rst:315
534 msgid ""
535 "You can insert the following two lines of code to start an interactive "
536 "Python session at that point::"
537 msgstr "你可以插入下面两行代码开启一个交互式Python会话:"
538
539 #: ../../../__w/calibre/calibre/manual/develop.rst:320
540 msgid ""
541 "When running from the command line, this will start an interactive Python "
542 "interpreter with access to all locally defined variables (variables in the "
543 "local scope). The interactive prompt even has :kbd:`Tab` completion for "
544 "object properties and you can use the various Python facilities for "
545 "introspection, such as :func:`dir`, :func:`type`, :func:`repr`, etc."
546 msgstr "当从命令行运行时,这将启动一个交互式的Python解释器,可以访问所有本地定义的变量(本地作用域中的变量)。交互提示符甚至有:按键“Tab”对象属性补全,可以使用各种Python工具进行自省,如“dir”、“type”、“repr”等。"
547
548 #: ../../../__w/calibre/calibre/manual/develop.rst:326
549 msgid "Using the Python debugger as a remote debugger"
550 msgstr "使用Python调试器作为远程调试器"
551
552 #: ../../../__w/calibre/calibre/manual/develop.rst:328
553 msgid ""
554 "You can use the builtin Python debugger (pdb) as a remote debugger from the "
555 "command line. First, start the remote debugger at the point in the calibre "
556 "code you are interested in, like this::"
557 msgstr "您可以从命令行使用内置 Python 调试器 (pdb) 作为远程调试器。 首先,在您感兴趣的 calibre 代码中启动远程调试器,如下所示:"
558
559 #: ../../../__w/calibre/calibre/manual/develop.rst:335
560 msgid ""
561 "Then run calibre, either as normal, or using one of the calibre-debug "
562 "commands described in the previous section. Once the above point in the code"
563 " is reached, calibre will freeze, waiting for the debugger to connect."
564 msgstr "然后运行calibre,正常运行,或者使用上文提到的calibre-debug命令。一旦上述代码完成,calibre会停止,等待调试器的连接。"
565
566 #: ../../../__w/calibre/calibre/manual/develop.rst:339
567 msgid ""
568 "Now open a terminal or command prompt and use the following command to start"
569 " the debugging session::"
570 msgstr "现在打开一个终端或者命令提示符,使用下列命令打开debug会话:"
571
572 #: ../../../__w/calibre/calibre/manual/develop.rst:344
573 msgid ""
574 "You can read about how to use the Python debugger in the `Python stdlib docs"
575 " for the pdb module <https://docs.python.org/library/pdb.html#debugger-"
576 "commands>`_."
577 msgstr "您可以在`关于PDB模块的Python stdlib文档<https://docs.python.org/library/pdb.html#debugger-commands>中`了解如何使用Python调试器。"
578
579 #: ../../../__w/calibre/calibre/manual/develop.rst:348
580 msgid ""
581 "By default, the remote debugger will try to connect on port 4444. You can "
582 "change it, by passing the port parameter to both the set_trace() and the "
583 "cli() functions above, like this: ``set_trace(port=1234)`` and "
584 "``cli(port=1234)``."
585 msgstr "默认情况下,远程调试器连接到端口4444。你也可以通过设置 set_trace() 与 cli() 函数更换端口,像这样: ``set_trace(port=1234)`` and ``cli(port=1234)``。"
586
587 #: ../../../__w/calibre/calibre/manual/develop.rst:354
588 msgid ""
589 "The Python debugger cannot handle multiple threads, so you have to call "
590 "set_trace once per thread, each time with a different port number."
591 msgstr "Python调试器不能控制多线程,所以你不得不在每个线程中使用 set_trace 函数一次,每次都得用一个不同的端口号。"
592
593 #: ../../../__w/calibre/calibre/manual/develop.rst:358
594 msgid "Using the debugger in your favorite Python IDE"
595 msgstr "在自己的IDE环境下使用调试器"
596
597 #: ../../../__w/calibre/calibre/manual/develop.rst:360
598 msgid ""
599 "It is possible to use the builtin debugger in your favorite Python IDE, if "
600 "it supports remote debugging. The first step is to add the calibre src "
601 "checkout to the ``PYTHONPATH`` in your IDE. In other words, the folder you "
602 "set as ``CALIBRE_DEVELOP_FROM`` above, must also be in the ``PYTHONPATH`` of"
603 " your IDE."
604 msgstr "如果内置调试器支持远程调试,则可以在您最喜欢的Python IDE中使用它。第一步是将Calibre src检出添加到IDE中的``PYTHONPATH``中。换句话说,您在上面设置为``CALIBRE_DEVELOP_FROM``的文件夹也必须位于您的IDE的``PYTHONPATH`中。"
605
606 #: ../../../__w/calibre/calibre/manual/develop.rst:365
607 msgid ""
608 "Then place the IDE's remote debugger module into the :file:`src` sub-folder "
609 "of the calibre source code checkout. Add whatever code is needed to launch "
610 "the remote debugger to calibre at the point of interest, for example in the "
611 "main function. Then run calibre as normal. Your IDE should now be able to "
612 "connect to the remote debugger running inside calibre."
613 msgstr "然后将IDE的远程调试器模块放入calibre源代码检测的“src”子文件夹中。 添加启动远程调试器所需的任何代码,以在感兴趣的位置进行校准,例如在主函数中。 然后正常运行 calibre。 您的 IDE 现在应该能够连接到在 calibre 内运行的远程调试器。"
614
615 #: ../../../__w/calibre/calibre/manual/develop.rst:372
616 msgid "Executing arbitrary scripts in the calibre Python environment"
617 msgstr "在calibre的Python环境中执行任意脚本"
618
619 #: ../../../__w/calibre/calibre/manual/develop.rst:374
620 msgid ""
621 "The :command:`calibre-debug` command provides a couple of handy switches to "
622 "execute your own code, with access to the calibre modules::"
623 msgstr "`calibre-debug` 提供了一些方便的开关来执行你自己的代码,并且可以访问calibre模块:"
624
625 #: ../../../__w/calibre/calibre/manual/develop.rst:379
626 msgid ""
627 "is great for testing a little snippet of code on the command line. It works "
628 "in the same way as the -c switch to the Python interpreter::"
629 msgstr "非常适合在命令行上测试一小段代码。它的工作方式与-c切换至Python解释器的方式相同:"
630
631 #: ../../../__w/calibre/calibre/manual/develop.rst:383
632 msgid ""
633 "can be used to execute your own Python script. It works in the same way as "
634 "passing the script to the Python interpreter, except that the calibre "
635 "environment is fully initialized, so you can use all the calibre code in "
636 "your script. To use command line arguments with your script, use the form::"
637 msgstr "可以用来执行自己的Python脚本。 除了完全初始化calibre环境外,它的工作方式与将脚本传递给Python解释器的方式相同,因此您可以在脚本中使用所有calibre代码。 要在脚本中使用命令行参数,请使用以下格式:"
638
639 #: ../../../__w/calibre/calibre/manual/develop.rst:388
640 msgid ""
641 "The ``--`` causes all subsequent arguments to be passed to your script."
642 msgstr "``--`` 会使后面的所有参数被传到你的脚本里。"
643
644 #: ../../../__w/calibre/calibre/manual/develop.rst:392
645 msgid "Running the calibre test suite"
646 msgstr "正在运行 Calibre 测试套件"
647
648 #: ../../../__w/calibre/calibre/manual/develop.rst:394
649 msgid "The calibre test suite can be run by::"
650 msgstr "运行 Calibre 测试套件的方法如下::"
651
652 #: ../../../__w/calibre/calibre/manual/develop.rst:400
653 msgid "Using calibre in your projects"
654 msgstr "在你的项目中使用calibre"
655
656 #: ../../../__w/calibre/calibre/manual/develop.rst:402
657 msgid ""
658 "It is possible to directly use calibre functions/code in your Python "
659 "project. Two ways exist to do this:"
660 msgstr "在你的Python项目中可以直接使用calibre的功能与代码。有两种方法可以这么做:"
661
662 #: ../../../__w/calibre/calibre/manual/develop.rst:405
663 msgid "Binary install of calibre"
664 msgstr "二进制安装calibre"
665
666 #: ../../../__w/calibre/calibre/manual/develop.rst:407
667 msgid ""
668 "If you have a binary install of calibre, you can use the Python interpreter "
669 "bundled with calibre, like this::"
670 msgstr "如果您有calibre的二进制安装,则可以使用calibre附带的Python解释器,如下所示:"
671
672 #: ../../../__w/calibre/calibre/manual/develop.rst:412
673 msgid "Source install on Linux"
674 msgstr "Linux源码安装"
675
676 #: ../../../__w/calibre/calibre/manual/develop.rst:414
677 msgid ""
678 "In addition to using the above technique, if you do a source install on "
679 "Linux, you can also directly import calibre, as follows::"
680 msgstr "除了使用上面的技巧,如果你在Linux中进行源码安装,你可以直接import calibre,就像下面这样:"
681
682 #: ../../../__w/calibre/calibre/manual/develop.rst:422
683 msgid ""
684 "It is essential that you import the init_calibre module before any other "
685 "calibre modules/packages as it sets up the interpreter to run calibre code."
686 msgstr "在将init_calibre模块设置为运行calibre代码的解释器之前,必须先导入init_calibre模块,然后再输入其他calibre模块/软件包。"
687
688 #: ../../../__w/calibre/calibre/manual/develop.rst:426
689 msgid "API documentation for various parts of calibre"
690 msgstr "calibre丰富的API文档"