Skip to content

Commit df9fc6f

Browse files
Copilotmattwang44
andcommitted
Translate additional sections of extending/embedding.po - 54/59 messages complete
Co-authored-by: mattwang44 <[email protected]>
1 parent 86216dd commit df9fc6f

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed

extending/embedding.po

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ msgid ""
276276
"is the routine that you call between both data conversions. When extending, "
277277
"you call a C routine, when embedding, you call a Python routine."
278278
msgstr ""
279+
"如你所見,資料轉換步驟只是被交換來配合跨語言傳輸的不同方向。唯一的差別是你在"
280+
"兩個資料轉換之間呼叫的例程。當擴充時,你呼叫 C 例程,當嵌入時,你呼叫 Python "
281+
"例程。"
279282

280283
#: ../../extending/embedding.rst:144
281284
msgid ""
@@ -284,10 +287,13 @@ msgid ""
284287
"be understood. Since these aspects do not differ from extending the "
285288
"interpreter, you can refer to earlier chapters for the required information."
286289
msgstr ""
290+
"本章不會討論如何將資料從 Python 轉換為 C 以及反之。此外,假設已經理解參考的"
291+
"正確使用和錯誤處理。由於這些方面與擴充直譯器沒有不同,你可以參考前面的章節"
292+
"來取得所需資訊。"
287293

288294
#: ../../extending/embedding.rst:153
289295
msgid "Pure Embedding"
290-
msgstr ""
296+
msgstr "純嵌入"
291297

292298
#: ../../extending/embedding.rst:155
293299
msgid ""
@@ -296,10 +302,12 @@ msgid ""
296302
"directly interact with the application (but that will change in the next "
297303
"section)."
298304
msgstr ""
305+
"第一個程式的目標是執行 Python 腳本中的函式。就像在非常高階介面的章節中一樣,"
306+
"Python 直譯器不會直接與應用程式互動(但這在下一節會改變)。"
299307

300308
#: ../../extending/embedding.rst:160
301309
msgid "The code to run a function defined in a Python script is:"
302-
msgstr ""
310+
msgstr "執行 Python 腳本中定義函式的程式碼是:"
303311

304312
#: ../../extending/embedding.rst:162
305313
msgid ""
@@ -385,6 +393,10 @@ msgid ""
385393
"(let's call the finished executable :program:`call`), and use it to execute "
386394
"a Python script, such as:"
387395
msgstr ""
396+
"此程式碼使用 ``argv[1]`` 載入 Python 腳本,並呼叫 ``argv[2]`` 中命名的函式。"
397+
"其整數引數是 ``argv`` 陣列的其他值。如果你 :ref:`編譯並連結 <compiling>` 此"
398+
"程式(我們稱完成的可執行檔為 :program:`call`),並用它來執行 Python 腳本,"
399+
"例如:"
388400

389401
#: ../../extending/embedding.rst:171
390402
msgid ""
@@ -398,21 +410,26 @@ msgstr ""
398410

399411
#: ../../extending/embedding.rst:180
400412
msgid "then the result should be:"
401-
msgstr ""
413+
msgstr "那麼結果應該是:"
402414

403415
#: ../../extending/embedding.rst:182
404416
msgid ""
405417
"$ call multiply multiply 3 2\n"
406418
"Will compute 3 times 2\n"
407419
"Result of call: 6"
408420
msgstr ""
421+
"$ call multiply multiply 3 2\n"
422+
"Will compute 3 times 2\n"
423+
"Result of call: 6"
409424

410425
#: ../../extending/embedding.rst:188
411426
msgid ""
412427
"Although the program is quite large for its functionality, most of the code "
413428
"is for data conversion between Python and C, and for error reporting. The "
414429
"interesting part with respect to embedding Python starts with ::"
415430
msgstr ""
431+
"雖然對於其功能而言程式相當龐大,但大部分的程式碼是用於 Python 和 C 之間的資料"
432+
"轉換,以及錯誤回報。關於嵌入 Python 的有趣部分開始於 ::"
416433

417434
#: ../../extending/embedding.rst:192
418435
msgid ""
@@ -429,6 +446,9 @@ msgid ""
429446
"which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data "
430447
"conversion routine. ::"
431448
msgstr ""
449+
"在初始化直譯器後,腳本使用 :c:func:`PyImport_Import` 載入。此例程需要一個 "
450+
"Python 字串作為其引數,該字串使用 :c:func:`PyUnicode_DecodeFSDefault` 資料"
451+
"轉換例程建構。 ::"
432452

433453
#: ../../extending/embedding.rst:202
434454
msgid ""
@@ -449,6 +469,9 @@ msgid ""
449469
"proceeds by constructing a tuple of arguments as normal. The call to the "
450470
"Python function is then made with::"
451471
msgstr ""
472+
"一旦腳本載入,我們要找的名稱使用 :c:func:`PyObject_GetAttrString` 檢索。如果"
473+
"名稱存在,且回傳的物件是可呼叫的,你可以安全地假設它是一個函式。程式接著以"
474+
"正常方式建構引數元組。對 Python 函式的呼叫接著以下面方式進行 ::"
452475

453476
#: ../../extending/embedding.rst:216
454477
msgid "pValue = PyObject_CallObject(pFunc, pArgs);"
@@ -460,10 +483,12 @@ msgid ""
460483
"reference to the return value of the function. Be sure to release the "
461484
"reference after examining the value."
462485
msgstr ""
486+
"函式回傳時,``pValue`` 要不是 ``NULL`` 就是包含函式回傳值的參考。確保在檢查"
487+
"值之後釋放參考。"
463488

464489
#: ../../extending/embedding.rst:226
465490
msgid "Extending Embedded Python"
466-
msgstr ""
491+
msgstr "擴充嵌入式 Python"
467492

468493
#: ../../extending/embedding.rst:228
469494
msgid ""
@@ -476,6 +501,11 @@ msgid ""
476501
"and write some glue code that gives Python access to those routines, just "
477502
"like you would write a normal Python extension. For example::"
478503
msgstr ""
504+
"到目前為止,嵌入式 Python 直譯器無法存取應用程式本身的功能。Python API 透過"
505+
"擴充嵌入式直譯器來允許這樣做。也就是說,嵌入式直譯器被應用程式提供的例程所"
506+
"擴充。雖然聽起來複雜,但其實沒那麼糟。只要暫時忘記應用程式啟動 Python 直譯器"
507+
"這件事。相反,把應用程式當作一組子程序,並撰寫一些膠合程式碼讓 Python 存取"
508+
"這些例程,就像你撰寫一般 Python 擴充一樣。例如: ::"
479509

480510
#: ../../extending/embedding.rst:237
481511
msgid ""
@@ -515,6 +545,8 @@ msgid ""
515545
"Insert the above code just above the :c:func:`main` function. Also, insert "
516546
"the following two statements before the call to :c:func:`Py_Initialize`::"
517547
msgstr ""
548+
"在 :c:func:`main` 函式的正上方插入上述程式碼。同時,在呼叫 :c:func:"
549+
"`Py_Initialize` 之前插入以下兩個敘述 ::"
518550

519551
#: ../../extending/embedding.rst:270
520552
msgid ""
@@ -530,22 +562,26 @@ msgid ""
530562
"emb.numargs` function accessible to the embedded Python interpreter. With "
531563
"these extensions, the Python script can do things like"
532564
msgstr ""
565+
"這兩行初始化 ``numargs`` 變數,並讓 :func:`!emb.numargs` 函式對嵌入式 Python "
566+
"直譯器可用。有了這些擴充,Python 腳本可以執行以下操作"
533567

534568
#: ../../extending/embedding.rst:277
535569
msgid ""
536570
"import emb\n"
537571
"print(\"Number of arguments\", emb.numargs())"
538572
msgstr ""
573+
"import emb\n"
574+
"print(\"Number of arguments\", emb.numargs())"
539575

540576
#: ../../extending/embedding.rst:282
541577
msgid ""
542578
"In a real application, the methods will expose an API of the application to "
543579
"Python."
544-
msgstr ""
580+
msgstr "在真實的應用程式中,這些方法會向 Python 公開應用程式的 API。"
545581

546582
#: ../../extending/embedding.rst:292
547583
msgid "Embedding Python in C++"
548-
msgstr ""
584+
msgstr "在 C++ 中嵌入 Python"
549585

550586
#: ../../extending/embedding.rst:294
551587
msgid ""
@@ -555,10 +591,13 @@ msgid ""
555591
"and link your program. There is no need to recompile Python itself using C+"
556592
"+."
557593
msgstr ""
594+
"也可以將 Python 嵌入 C++ 程式中;具體如何做取決於所使用的 C++ 系統的細節;"
595+
"一般來說,你需要用 C++ 撰寫主程式,並使用 C++ 編譯器來編譯和連結你的程式。"
596+
"不需要使用 C++ 重新編譯 Python 本身。"
558597

559598
#: ../../extending/embedding.rst:303
560599
msgid "Compiling and Linking under Unix-like systems"
561-
msgstr ""
600+
msgstr "在類 Unix 系統下編譯和連結"
562601

563602
#: ../../extending/embedding.rst:305
564603
msgid ""
@@ -567,6 +606,9 @@ msgid ""
567606
"application, particularly because Python needs to load library modules "
568607
"implemented as C dynamic extensions (:file:`.so` files) linked against it."
569608
msgstr ""
609+
"要找到傳遞給編譯器(和連結器)的正確旗標以便將 Python 直譯器嵌入你的應用程式"
610+
"中,並不一定是簡單的事,特別是因為 Python 需要載入作為 C 動態擴充實作的函式庫"
611+
"模組(:file:`.so` 檔案)並連結到它。"
570612

571613
#: ../../extending/embedding.rst:311
572614
msgid ""
@@ -576,12 +618,15 @@ msgid ""
576618
"available). This script has several options, of which the following will be "
577619
"directly useful to you:"
578620
msgstr ""
621+
"要找出所需的編譯器和連結器旗標,你可以執行作為安裝過程的一部分產生的 :file:"
622+
"`python{X.Y}-config` 腳本(也可能有 :file:`python3-config` 腳本可用)。此腳本"
623+
"有幾個選項,其中以下對你直接有用:"
579624

580625
#: ../../extending/embedding.rst:317
581626
msgid ""
582627
"``pythonX.Y-config --cflags`` will give you the recommended flags when "
583628
"compiling:"
584-
msgstr ""
629+
msgstr "``pythonX.Y-config --cflags`` 會給你編譯時建議的旗標:"
585630

586631
#: ../../extending/embedding.rst:320
587632
msgid ""
@@ -597,7 +642,7 @@ msgstr ""
597642
msgid ""
598643
"``pythonX.Y-config --ldflags --embed`` will give you the recommended flags "
599644
"when linking:"
600-
msgstr ""
645+
msgstr "``pythonX.Y-config --ldflags --embed`` 會給你連結時建議的旗標:"
601646

602647
#: ../../extending/embedding.rst:328
603648
msgid ""
@@ -616,6 +661,8 @@ msgid ""
616661
"that you use the absolute path to :file:`python{X.Y}-config`, as in the "
617662
"above example."
618663
msgstr ""
664+
"為了避免多個 Python 安裝之間的混淆(特別是系統 Python 和你自己編譯的 Python "
665+
"之間),建議你使用 :file:`python{X.Y}-config` 的絕對路徑,如上面的例子所示。"
619666

620667
#: ../../extending/embedding.rst:339
621668
msgid ""
@@ -628,6 +675,11 @@ msgid ""
628675
"extract the configuration values that you will want to combine together. "
629676
"For example:"
630677
msgstr ""
678+
"如果此程序對你不起作用(不保證對所有類 Unix 平台都有效;但是,我們歡迎 :ref:"
679+
"`錯誤回報 <reporting-bugs>`),你將必須閱讀系統關於動態連結的文件和/或檢查 "
680+
"Python 的 :file:`Makefile`(使用 :func:`sysconfig.get_makefile_filename` 來"
681+
"找到其位置)和編譯選項。在這種情況下,:mod:`sysconfig` 模組是一個有用的工具,"
682+
"可以程式化地擷取你想要組合在一起的組態值。例如:"
631683

632684
#: ../../extending/embedding.rst:348
633685
msgid ""

0 commit comments

Comments
 (0)