@@ -7,7 +7,7 @@ msgstr ""
7
7
"Project-Id-Version : Python 3.13\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
9
"POT-Creation-Date : 2024-09-03 11:11+0800\n "
10
- "PO-Revision-Date : 2024-10-03 12:34 +0800\n "
10
+ "PO-Revision-Date : 2024-10-07 17:11 +0800\n "
11
11
"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -444,14 +444,16 @@ msgstr ""
444
444
445
445
#: ../../reference/import.rst:247
446
446
msgid "Import hooks"
447
- msgstr ""
447
+ msgstr "引入掛勾 (Import hooks) "
448
448
449
449
#: ../../reference/import.rst:257
450
450
msgid ""
451
451
"The import machinery is designed to be extensible; the primary mechanism for "
452
452
"this are the *import hooks*. There are two types of import hooks: *meta "
453
453
"hooks* and *import path hooks*."
454
454
msgstr ""
455
+ "引入機制的設計是可擴展的;其主要機制是\\ *引入掛鉤*。引入掛鉤有兩種類型:*元"
456
+ "掛鉤 (meta hooks)* 和\\ *引入路徑掛鉤*。"
455
457
456
458
#: ../../reference/import.rst:261
457
459
msgid ""
@@ -461,6 +463,10 @@ msgid ""
461
463
"modules, or even built-in modules. Meta hooks are registered by adding new "
462
464
"finder objects to :data:`sys.meta_path`, as described below."
463
465
msgstr ""
466
+ "元掛鉤會在引入處理的開始階段被呼叫,除了查找 :data:`sys.modules` 快取外,其他"
467
+ "引入處理還未發生時就會呼叫。這允許元掛鉤覆蓋 :data:`sys.path` 的處理、凍結模"
468
+ "組,甚至是內建模組。元掛鉤透過將新的尋檢器物件添加到 :data:`sys.meta_path` 中"
469
+ "來註冊,具體描述請參閱下列章節。"
464
470
465
471
#: ../../reference/import.rst:267
466
472
msgid ""
@@ -469,10 +475,13 @@ msgid ""
469
475
"encountered. Import path hooks are registered by adding new callables to :"
470
476
"data:`sys.path_hooks` as described below."
471
477
msgstr ""
478
+ "引入路徑掛鉤被視為 :data:`sys.path`\\ (或 ``package.__path__``)處理過程的一"
479
+ "部分來呼叫,當遇到與其相關聯的路徑項目時就會被觸發。引入路徑掛鉤透過將新的可"
480
+ "呼叫對象增加到 :data:`sys.path_hooks` 中來註冊,具體描述請參閱下列章節。"
472
481
473
482
#: ../../reference/import.rst:274
474
483
msgid "The meta path"
475
- msgstr ""
484
+ msgstr "元路徑 "
476
485
477
486
#: ../../reference/import.rst:280
478
487
msgid ""
@@ -485,6 +494,11 @@ msgid ""
485
494
"finder can use any strategy it wants to determine whether it can handle the "
486
495
"named module or not."
487
496
msgstr ""
497
+ "當在 :data:`sys.modules` 中找不到命名模組時,Python 接下來會搜尋 :data:`sys."
498
+ "meta_path`,其中包含一個元路徑尋檢器物件串列。這些尋檢器會依次被查詢,看它們"
499
+ "是否知道如何處理命名模組。元路徑尋檢器必須實作一個名為 :meth:`~importlib.abc."
500
+ "MetaPathFinder.find_spec` 的方法,該方法接收三個引數:名稱、引入路徑和(可選"
501
+ "的)目標模組。元路徑尋檢器可以使用任何策略來確定它是否能處理命名模組。"
488
502
489
503
#: ../../reference/import.rst:289
490
504
msgid ""
@@ -494,6 +508,10 @@ msgid ""
494
508
"returning a spec, then a :exc:`ModuleNotFoundError` is raised. Any other "
495
509
"exceptions raised are simply propagated up, aborting the import process."
496
510
msgstr ""
511
+ "如果元路徑尋檢器知道如何處理命名模組,它會回傳一個規格物件。如果它無法處理命"
512
+ "名模組,則回傳 ``None``。如果 :data:`sys.meta_path` 的處理到達串列的末尾仍未"
513
+ "回傳規格,則會引發 :exc:`ModuleNotFoundError`。任何其他引發的例外將直接向上傳"
514
+ "播,並中止引入過程。"
497
515
498
516
#: ../../reference/import.rst:295
499
517
msgid ""
@@ -508,6 +526,12 @@ msgid ""
508
526
"existing module object that will be the target of loading later. The import "
509
527
"system passes in a target module only during reload."
510
528
msgstr ""
529
+ "元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法會以兩個或"
530
+ "三個引數來呼叫。第一個是被引入模組的完全限定名稱,例如 ``foo.bar.baz``。第二"
531
+ "個引數是用於模組搜尋的路徑條目。對於頂層模組,第二個引數是 ``None``,但對於子"
532
+ "模組或子套件,第二個引數是父套件的 ``__path__`` 屬性的值。如果無法存取相應的 "
533
+ "``__path__`` 屬性,將引發 :exc:`ModuleNotFoundError`。第三個引數是一個現有的"
534
+ "模組物件,該物件將成為後續載入的目標。引入系統只會在重新載入時傳入目標模組。"
511
535
512
536
#: ../../reference/import.rst:306
513
537
msgid ""
@@ -520,13 +544,21 @@ msgid ""
520
544
"__path__, None)``. Once ``foo.bar`` has been imported, the final traversal "
521
545
"will call ``mpf.find_spec(\" foo.bar.baz\" , foo.bar.__path__, None)``."
522
546
msgstr ""
547
+ "對於一個引入請求,元路徑可能會被遍歷多次。例如,假設參與的模組都沒有被快取,"
548
+ "則引入 ``foo.bar.baz`` 將首先執行頂層引入,對每個元路徑尋檢器(``mpf``)呼叫 "
549
+ "``mpf.find_spec(\" foo\" , None, None)``。當 ``foo`` 被引入後,將再次藉由遍歷元"
550
+ "路徑引入 ``foo.bar``,並呼叫 ``mpf.find_spec(\" foo.bar\" , foo.__path__, "
551
+ "None)``。當 ``foo.bar`` 被引入後,最後一次遍歷會呼叫 ``mpf.find_spec(\" foo."
552
+ "bar.baz\" , foo.bar.__path__, None)``。"
523
553
524
554
#: ../../reference/import.rst:316
525
555
msgid ""
526
556
"Some meta path finders only support top level imports. These importers will "
527
557
"always return ``None`` when anything other than ``None`` is passed as the "
528
558
"second argument."
529
559
msgstr ""
560
+ "一些元路徑尋檢器僅支援頂層引入。當第二個引數傳入 ``None`` 以外的值時,這些引"
561
+ "入器將始終回傳 ``None``。"
530
562
531
563
#: ../../reference/import.rst:320
532
564
msgid ""
@@ -535,6 +567,9 @@ msgid ""
535
567
"modules, and one that knows how to import modules from an :term:`import "
536
568
"path` (i.e. the :term:`path based finder`)."
537
569
msgstr ""
570
+ "Python 的預設 :data:`sys.meta_path` 有三個元路徑尋檢器,一個知道如何引入內建"
571
+ "模組,一個知道如何引入凍結模組,還有一個知道如何從 :term:`import path` 引入模"
572
+ "組(即 :term:`path based finder`)。"
538
573
539
574
#: ../../reference/import.rst:325
540
575
msgid ""
@@ -544,18 +579,23 @@ msgid ""
544
579
"if the finder does not implement :meth:`~importlib.abc.MetaPathFinder."
545
580
"find_spec`."
546
581
msgstr ""
582
+ "元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法取代了 :"
583
+ "meth:`!find_module`,後者現在已被棄用。雖然它將繼續正常工作,但引入機制僅在尋"
584
+ "檢器未實作 :meth:`~importlib.abc.MetaPathFinder.find_spec` 時才會嘗試使用它。"
547
585
548
586
#: ../../reference/import.rst:332
549
587
msgid ""
550
588
"Use of :meth:`!find_module` by the import system now raises :exc:"
551
589
"`ImportWarning`."
552
- msgstr ""
590
+ msgstr "引入系統現在使用 :meth:`!find_module` 時將引發 :exc:`ImportWarning`。 "
553
591
554
592
#: ../../reference/import.rst:336
555
593
msgid ""
556
594
":meth:`!find_module` has been removed. Use :meth:`~importlib.abc."
557
595
"MetaPathFinder.find_spec` instead."
558
596
msgstr ""
597
+ ":meth:`!find_module` 已被移除。請改用 :meth:`~importlib.abc.MetaPathFinder."
598
+ "find_spec`。"
559
599
560
600
#: ../../reference/import.rst:342
561
601
msgid "Loading"
0 commit comments