@@ -35,6 +35,12 @@ msgid ""
3535"writing some scripts in Python. You can also use it yourself if some of the "
3636"functionality can be written in Python more easily."
3737msgstr ""
38+ "前面的章節討論了如何擴充 Python,也就是如何透過附加一個 C 函式庫來擴充 "
39+ "Python 的功能。但也可以反過來做:將 Python 嵌入你的 C/C++ 應用程式中來豐富"
40+ "它。嵌入讓你的應用程式能夠以 Python 而非 C 或 C++ 來實作應用程式的某些功能。"
41+ "這可以用於許多目的;其中一個例子是允許使用者透過撰寫一些 Python 腳本來根據他們"
42+ "的需求客製化應用程式。如果某些功能用 Python 寫起來比較容易,你也可以自己使用"
43+ "這種方法。"
3844
3945#: ../../extending/embedding.rst:20
4046msgid ""
@@ -44,6 +50,10 @@ msgid ""
4450"nothing to do with Python --- instead, some parts of the application "
4551"occasionally call the Python interpreter to run some Python code."
4652msgstr ""
53+ "嵌入 Python 與擴充它類似,但不完全相同。差別在於當你擴充 Python 時,應用程式"
54+ "的主程式仍然是 Python 直譯器,而如果你嵌入 Python,主程式可能與 Python 完全"
55+ "無關 — 相反,應用程式的某些部分偶爾會呼叫 Python 直譯器來執行一些 Python "
56+ "程式碼。"
4757
4858#: ../../extending/embedding.rst:26
4959msgid ""
@@ -54,6 +64,10 @@ msgid ""
5464"Python. Then later you can call the interpreter from any part of the "
5565"application."
5666msgstr ""
67+ "所以如果你要嵌入 Python,你要提供自己的主程式。這個主程式必須做的事情之一是"
68+ "初始化 Python 直譯器。至少,你必須呼叫函式 :c:func:`Py_Initialize`。還有一些"
69+ "可選的呼叫來傳遞命令列引數給 Python。然後你可以在應用程式的任何部分呼叫直譯"
70+ "器。"
5771
5872#: ../../extending/embedding.rst:32
5973msgid ""
@@ -64,6 +78,10 @@ msgid ""
6478"level operations described in the previous chapters to construct and use "
6579"Python objects."
6680msgstr ""
81+ "有幾種不同的方式來呼叫直譯器:你可以傳遞一個包含 Python 敘述的字串給 :c:func:"
82+ "`PyRun_SimpleString`,或者你可以傳遞一個 stdio 檔案指標和檔案名稱(僅用於錯誤"
83+ "訊息中的識別)給 :c:func:`PyRun_SimpleFile`。你也可以呼叫前面章節中描述的較低"
84+ "層級操作來建構和使用 Python 物件。"
6785
6886#: ../../extending/embedding.rst:41
6987msgid ":ref:`c-api-index`"
@@ -74,10 +92,11 @@ msgid ""
7492"The details of Python's C interface are given in this manual. A great deal "
7593"of necessary information can be found here."
7694msgstr ""
95+ "Python 的 C 介面詳細資訊在此手冊中提供。大量必要的資訊可以在這裡找到。"
7796
7897#: ../../extending/embedding.rst:49
7998msgid "Very High Level Embedding"
80- msgstr ""
99+ msgstr "非常高階的嵌入 "
81100
82101#: ../../extending/embedding.rst:51
83102msgid ""
@@ -86,6 +105,8 @@ msgid ""
86105"needing to interact with the application directly. This can for example be "
87106"used to perform some operation on a file. ::"
88107msgstr ""
108+ "嵌入 Python 最簡單的形式是使用非常高階的介面。此介面用於執行 Python 腳本而"
109+ "無需直接與應用程式互動。這例如可以用來對檔案執行一些操作。 ::"
89110
90111#: ../../extending/embedding.rst:56
91112msgid ""
@@ -166,6 +187,9 @@ msgid ""
166187"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-"
167188"string-and-buffers` for a description of this macro."
168189msgstr ""
190+ "``#define PY_SSIZE_T_CLEAN`` 被用來指示某些 API 應該使用 ``Py_ssize_t`` 而不是 "
191+ "``int``。從 Python 3.13 開始不再必要,但我們在這裡保留它以維持向後相容性。"
192+ "關於此巨集的描述請參閱 :ref:`arg-parsing-string-and-buffers`。"
169193
170194#: ../../extending/embedding.rst:97
171195msgid ""
@@ -181,10 +205,17 @@ msgid ""
181205"`PyRun_SimpleFile` function, which saves you the trouble of allocating "
182206"memory space and loading the file contents."
183207msgstr ""
208+ "設定 :c:member:`PyConfig.program_name` 應該在 :c:func:`Py_InitializeFromConfig` "
209+ "之前呼叫,以告知直譯器 Python 執行期函式庫的路徑。接下來,Python 直譯器用 :c:"
210+ "func:`Py_Initialize` 初始化,然後執行一個硬編碼的 Python 腳本來印出日期和時間。"
211+ "之後,:c:func:`Py_FinalizeEx` 呼叫會關閉直譯器,接著程式結束。在真實的程式中,"
212+ "你可能想要從另一個來源取得 Python 腳本,或許是文字編輯器例程、檔案或資料庫。"
213+ "從檔案取得 Python 程式碼可以更好地使用 :c:func:`PyRun_SimpleFile` 函式來完成,"
214+ "這樣可以省去分配記憶體空間和載入檔案內容的麻煩。"
184215
185216#: ../../extending/embedding.rst:112
186217msgid "Beyond Very High Level Embedding: An overview"
187- msgstr ""
218+ msgstr "超越非常高階嵌入:概觀 "
188219
189220#: ../../extending/embedding.rst:114
190221msgid ""
@@ -194,6 +225,9 @@ msgid ""
194225"calls. At the cost of having to write more C code, you can achieve almost "
195226"anything."
196227msgstr ""
228+ "高階介面讓你能夠從應用程式中執行任意的 Python 程式碼片段,但至少可以說交換資料"
229+ "值是相當麻煩的。如果你想要這樣做,你應該使用較低階的呼叫。以必須撰寫更多 C "
230+ "程式碼為代價,你幾乎可以達成任何事情。"
197231
198232#: ../../extending/embedding.rst:119
199233msgid ""
@@ -202,36 +236,39 @@ msgid ""
202236"previous chapters are still valid. To show this, consider what the extension "
203237"code from Python to C really does:"
204238msgstr ""
239+ "應該注意的是,儘管意圖不同,擴充 Python 和嵌入 Python 其實是相當相同的活動。"
240+ "前面章節討論的大部分主題仍然有效。為了說明這一點,考慮從 Python 到 C 的擴充"
241+ "程式碼真正做了什麼:"
205242
206243#: ../../extending/embedding.rst:124
207244msgid "Convert data values from Python to C,"
208- msgstr ""
245+ msgstr "將資料值從 Python 轉換為 C, "
209246
210247#: ../../extending/embedding.rst:126
211248msgid "Perform a function call to a C routine using the converted values, and"
212- msgstr ""
249+ msgstr "使用轉換後的值對 C 例程執行函式呼叫,以及 "
213250
214251#: ../../extending/embedding.rst:128
215252msgid "Convert the data values from the call from C to Python."
216- msgstr ""
253+ msgstr "將呼叫中的資料值從 C 轉換為 Python。 "
217254
218255#: ../../extending/embedding.rst:130
219256msgid "When embedding Python, the interface code does:"
220- msgstr ""
257+ msgstr "當嵌入 Python 時,介面程式碼會: "
221258
222259#: ../../extending/embedding.rst:132
223260msgid "Convert data values from C to Python,"
224- msgstr ""
261+ msgstr "將資料值從 C 轉換為 Python, "
225262
226263#: ../../extending/embedding.rst:134
227264msgid ""
228265"Perform a function call to a Python interface routine using the converted "
229266"values, and"
230- msgstr ""
267+ msgstr "使用轉換後的值對 Python 介面例程執行函式呼叫,以及 "
231268
232269#: ../../extending/embedding.rst:137
233270msgid "Convert the data values from the call from Python to C."
234- msgstr ""
271+ msgstr "將呼叫中的資料值從 Python 轉換為 C。 "
235272
236273#: ../../extending/embedding.rst:139
237274msgid ""
0 commit comments