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