Skip to content

Commit b0869f5

Browse files
committed
fix: to rst: 336
1 parent ec31a40 commit b0869f5

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

reference/import.po

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: Python 3.13\n"
88
"Report-Msgid-Bugs-To: \n"
99
"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"
1111
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
@@ -444,14 +444,16 @@ msgstr ""
444444

445445
#: ../../reference/import.rst:247
446446
msgid "Import hooks"
447-
msgstr ""
447+
msgstr "引入掛勾 (Import hooks)"
448448

449449
#: ../../reference/import.rst:257
450450
msgid ""
451451
"The import machinery is designed to be extensible; the primary mechanism for "
452452
"this are the *import hooks*. There are two types of import hooks: *meta "
453453
"hooks* and *import path hooks*."
454454
msgstr ""
455+
"引入機制的設計是可擴展的;其主要機制是\\ *引入掛鉤*。引入掛鉤有兩種類型:*元"
456+
"掛鉤 (meta hooks)* 和\\ *引入路徑掛鉤*。"
455457

456458
#: ../../reference/import.rst:261
457459
msgid ""
@@ -461,6 +463,10 @@ msgid ""
461463
"modules, or even built-in modules. Meta hooks are registered by adding new "
462464
"finder objects to :data:`sys.meta_path`, as described below."
463465
msgstr ""
466+
"元掛鉤會在引入處理的開始階段被呼叫,除了查找 :data:`sys.modules` 快取外,其他"
467+
"引入處理還未發生時就會呼叫。這允許元掛鉤覆蓋 :data:`sys.path` 的處理、凍結模"
468+
"組,甚至是內建模組。元掛鉤透過將新的尋檢器物件添加到 :data:`sys.meta_path` 中"
469+
"來註冊,具體描述請參閱下列章節。"
464470

465471
#: ../../reference/import.rst:267
466472
msgid ""
@@ -469,10 +475,13 @@ msgid ""
469475
"encountered. Import path hooks are registered by adding new callables to :"
470476
"data:`sys.path_hooks` as described below."
471477
msgstr ""
478+
"引入路徑掛鉤被視為 :data:`sys.path`\\ (或 ``package.__path__``)處理過程的一"
479+
"部分來呼叫,當遇到與其相關聯的路徑項目時就會被觸發。引入路徑掛鉤透過將新的可"
480+
"呼叫對象增加到 :data:`sys.path_hooks` 中來註冊,具體描述請參閱下列章節。"
472481

473482
#: ../../reference/import.rst:274
474483
msgid "The meta path"
475-
msgstr ""
484+
msgstr "元路徑"
476485

477486
#: ../../reference/import.rst:280
478487
msgid ""
@@ -485,6 +494,11 @@ msgid ""
485494
"finder can use any strategy it wants to determine whether it can handle the "
486495
"named module or not."
487496
msgstr ""
497+
"當在 :data:`sys.modules` 中找不到命名模組時,Python 接下來會搜尋 :data:`sys."
498+
"meta_path`,其中包含一個元路徑尋檢器物件串列。這些尋檢器會依次被查詢,看它們"
499+
"是否知道如何處理命名模組。元路徑尋檢器必須實作一個名為 :meth:`~importlib.abc."
500+
"MetaPathFinder.find_spec` 的方法,該方法接收三個引數:名稱、引入路徑和(可選"
501+
"的)目標模組。元路徑尋檢器可以使用任何策略來確定它是否能處理命名模組。"
488502

489503
#: ../../reference/import.rst:289
490504
msgid ""
@@ -494,6 +508,10 @@ msgid ""
494508
"returning a spec, then a :exc:`ModuleNotFoundError` is raised. Any other "
495509
"exceptions raised are simply propagated up, aborting the import process."
496510
msgstr ""
511+
"如果元路徑尋檢器知道如何處理命名模組,它會回傳一個規格物件。如果它無法處理命"
512+
"名模組,則回傳 ``None``。如果 :data:`sys.meta_path` 的處理到達串列的末尾仍未"
513+
"回傳規格,則會引發 :exc:`ModuleNotFoundError`。任何其他引發的例外將直接向上傳"
514+
"播,並中止引入過程。"
497515

498516
#: ../../reference/import.rst:295
499517
msgid ""
@@ -508,6 +526,12 @@ msgid ""
508526
"existing module object that will be the target of loading later. The import "
509527
"system passes in a target module only during reload."
510528
msgstr ""
529+
"元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法會以兩個或"
530+
"三個引數來呼叫。第一個是被引入模組的完全限定名稱,例如 ``foo.bar.baz``。第二"
531+
"個引數是用於模組搜尋的路徑條目。對於頂層模組,第二個引數是 ``None``,但對於子"
532+
"模組或子套件,第二個引數是父套件的 ``__path__`` 屬性的值。如果無法存取相應的 "
533+
"``__path__`` 屬性,將引發 :exc:`ModuleNotFoundError`。第三個引數是一個現有的"
534+
"模組物件,該物件將成為後續載入的目標。引入系統只會在重新載入時傳入目標模組。"
511535

512536
#: ../../reference/import.rst:306
513537
msgid ""
@@ -520,13 +544,21 @@ msgid ""
520544
"__path__, None)``. Once ``foo.bar`` has been imported, the final traversal "
521545
"will call ``mpf.find_spec(\"foo.bar.baz\", foo.bar.__path__, None)``."
522546
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)``。"
523553

524554
#: ../../reference/import.rst:316
525555
msgid ""
526556
"Some meta path finders only support top level imports. These importers will "
527557
"always return ``None`` when anything other than ``None`` is passed as the "
528558
"second argument."
529559
msgstr ""
560+
"一些元路徑尋檢器僅支援頂層引入。當第二個引數傳入 ``None`` 以外的值時,這些引"
561+
"入器將始終回傳 ``None``。"
530562

531563
#: ../../reference/import.rst:320
532564
msgid ""
@@ -535,6 +567,9 @@ msgid ""
535567
"modules, and one that knows how to import modules from an :term:`import "
536568
"path` (i.e. the :term:`path based finder`)."
537569
msgstr ""
570+
"Python 的預設 :data:`sys.meta_path` 有三個元路徑尋檢器,一個知道如何引入內建"
571+
"模組,一個知道如何引入凍結模組,還有一個知道如何從 :term:`import path` 引入模"
572+
"組(即 :term:`path based finder`)。"
538573

539574
#: ../../reference/import.rst:325
540575
msgid ""
@@ -544,18 +579,23 @@ msgid ""
544579
"if the finder does not implement :meth:`~importlib.abc.MetaPathFinder."
545580
"find_spec`."
546581
msgstr ""
582+
"元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法取代了 :"
583+
"meth:`!find_module`,後者現在已被棄用。雖然它將繼續正常工作,但引入機制僅在尋"
584+
"檢器未實作 :meth:`~importlib.abc.MetaPathFinder.find_spec` 時才會嘗試使用它。"
547585

548586
#: ../../reference/import.rst:332
549587
msgid ""
550588
"Use of :meth:`!find_module` by the import system now raises :exc:"
551589
"`ImportWarning`."
552-
msgstr ""
590+
msgstr "引入系統現在使用 :meth:`!find_module` 時將引發 :exc:`ImportWarning`。"
553591

554592
#: ../../reference/import.rst:336
555593
msgid ""
556594
":meth:`!find_module` has been removed. Use :meth:`~importlib.abc."
557595
"MetaPathFinder.find_spec` instead."
558596
msgstr ""
597+
":meth:`!find_module` 已被移除。請改用 :meth:`~importlib.abc.MetaPathFinder."
598+
"find_spec`。"
559599

560600
#: ../../reference/import.rst:342
561601
msgid "Loading"

0 commit comments

Comments
 (0)