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