From 8a5a6469c0059920932f4ab60ab3406cb09baa0a Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Tue, 6 May 2025 10:44:35 +0800 Subject: [PATCH] translate `c-api/import.po` --- c-api/import.po | 140 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 126 insertions(+), 14 deletions(-) diff --git a/c-api/import.po b/c-api/import.po index 00cfc9eefe..4537a6c00f 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -3,13 +3,14 @@ # # Translators: # Ching-Lung Chuang, 2015 +# Matt Wang , 2025 msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-09-08 15:25+0800\n" -"PO-Revision-Date: 2018-05-23 14:06+0000\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2025-11-11 14:06+0000\n" +"Last-Translator: mattwang44@gmail.com\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -27,10 +28,12 @@ msgid "" "This is a wrapper around :c:func:`PyImport_Import()` which takes " "a :c:expr:`const char *` as an argument instead of a :c:expr:`PyObject *`." msgstr "" +"這是 :c:func:`PyImport_Import()` 的包裝器 (wrapper),它使用 :c:expr:`const " +"char *` 作為引數,而不是 :c:expr:`PyObject *`。" #: ../../c-api/import.rst:21 msgid "This function is a deprecated alias of :c:func:`PyImport_ImportModule`." -msgstr "" +msgstr "這個函式是 :c:func:`PyImport_ImportModule` 的已棄用別名。" #: ../../c-api/import.rst:23 msgid "" @@ -39,6 +42,8 @@ msgid "" "module locks for most purposes, so this function's special behaviour isn't " "needed anymore." msgstr "" +"當引入鎖被其他執行緒持有時,這個函式過去會立即失敗。但在 Python 3.3 中,鎖機" +"制轉換成針對每個模組的鎖 (per-module lock) 來達到大多數目的,所以這個函式的特殊行為就不再需要了。" #: ../../c-api/import.rst:29 msgid "Use :c:func:`PyImport_ImportModule` instead." @@ -48,7 +53,7 @@ msgstr "請改用 :c:func:`PyImport_ImportModule`。" msgid "" "Import a module. This is best described by referring to the built-in Python " "function :func:`__import__`." -msgstr "" +msgstr "引入一個模組。這最好透過參考 Python 內建函式 :func:`__import__` 來說明。" #: ../../c-api/import.rst:40 ../../c-api/import.rst:56 msgid "" @@ -58,12 +63,16 @@ msgid "" "requested is normally the top-level package, unless a non-empty *fromlist* " "was given." msgstr "" +"回傳值是對引入的模組或頂層套件的新參照,或者是 ``NULL``,失敗時會設定例外。" +"就像 :func:`__import__` 一樣,當要求一個套件的子模組時,回傳值通常是頂層套" +"件,除非給定一個非空的 *fromlist*。" #: ../../c-api/import.rst:46 msgid "" "Failing imports remove incomplete module objects, like " "with :c:func:`PyImport_ImportModule`." msgstr "" +"失敗的引入會移除不完整的模組物件,就像 :c:func:`PyImport_ImportModule` 一樣。" #: ../../c-api/import.rst:52 msgid "" @@ -71,16 +80,20 @@ msgid "" "function :func:`__import__`, as the standard :func:`__import__` function " "calls this function directly." msgstr "" +"引入一個模組。這最好透過參考內建的 Python 函式 :func:`__import__` 來說明,因為" +"標準的 :func:`__import__` 函式會直接呼叫這個函式。" #: ../../c-api/import.rst:66 msgid "" "Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" +"類似於 :c:func:`PyImport_ImportModuleLevelObject`,但名稱是 UTF-8 編碼字串," +"而不是 Unicode 物件。" #: ../../c-api/import.rst:69 msgid "Negative values for *level* are no longer accepted." -msgstr "" +msgstr "不再接受負的 *level* 值。" #: ../../c-api/import.rst:74 msgid "" @@ -90,20 +103,26 @@ msgid "" "current globals. This means that the import is done using whatever import " "hooks are installed in the current environment." msgstr "" +"這是一個較高階的介面,用來呼叫目前的「引入掛勾函式 (import hook function)」" +"(明確的 *level* 為 0,表示絕對引入 (absolute import))。它從目前全域變數的 " +"``__builtins__`` 中呼叫 :func:`__import__` 函式。這表示引入是使用目前環境所安" +"裝的引入掛勾來完成的。" #: ../../c-api/import.rst:80 msgid "This function always uses absolute imports." -msgstr "" +msgstr "此函式總是使用絕對引入。" #: ../../c-api/import.rst:85 msgid "" "Reload a module. Return a new reference to the reloaded module, or ``NULL`` " "with an exception set on failure (the module still exists in this case)." msgstr "" +"重新載入一個模組。回傳重新載入模組的新參照,或在失敗時回傳 ``NULL`` 並設定例" +"外(在這種情況下模組仍然存在)。" #: ../../c-api/import.rst:91 msgid "Return the module object corresponding to a module name." -msgstr "" +msgstr "回傳與模組名稱對應的模組物件。" #: ../../c-api/import.rst:93 msgid "" @@ -111,16 +130,20 @@ msgid "" "modules dictionary if there's one there, and if not, create a new one and " "insert it in the modules dictionary." msgstr "" +"*name* 引數的形式可以是 ``package.module``。首先檢查模組字典中是否有,如果沒" +"有,則建立新的模組並插入模組字典中。" #: ../../c-api/import.rst:97 msgid "" "Return a :term:`strong reference` to the module on success. Return ``NULL`` " "with an exception set on failure." msgstr "" +"成功時回傳模組的\\ :term:`強參照 `。失敗時回傳 ``NULL`` 並" +"設定例外。" #: ../../c-api/import.rst:100 msgid "The module name *name* is decoded from UTF-8." -msgstr "" +msgstr "模組名稱 *name* 是以 UTF-8 解碼。" #: ../../c-api/import.rst:102 msgid "" @@ -130,18 +153,25 @@ msgid "" "module. Package structures implied by a dotted name for *name* are not " "created if not already present." msgstr "" +"這個函式不會載入或引入模組;如果模組尚未載入,你將會得到一個空的模組物件。使" +"用 :c:func:`PyImport_ImportModule` 或其變體來引入一個模組。如果尚未存在,則不" +"會建立由 *name* 的點名稱 (dotted name) 所隱含的套件結構。" #: ../../c-api/import.rst:113 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference` and *name* is a Python :class:`str` object." msgstr "" +"類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " +"`\\ 且 *name* 為 Python 的 :class:`str` 物件。" #: ../../c-api/import.rst:121 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference`." msgstr "" +"類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " +"`。" #: ../../c-api/import.rst:129 msgid "" @@ -156,6 +186,13 @@ msgid "" "no way to know that the module object is an unknown (and probably damaged " "with respect to the module author's intents) state." msgstr "" +"給定一個模組名稱(可能為 ``package.module`` 的形式),以及一個從 Python 位元組" +"碼檔讀取或從內建函式 :func:`compile` 取得的程式碼物件,載入模組。回傳模組物件" +"的新參照,如果發生錯誤,則回傳 ``NULL`` 並設定例外。在出錯的情況下,*name* 會" +"從 :data:`sys.modules` 中移除,即使 *name* 在進" +"入 :c:func:`PyImport_ExecCodeModule` 時已經在 :data:`sys.modules` 中。" +"在 :data:`sys.modules` 中留下未完全初始化的模組是很危險的,因為這種模組的引入" +"無法知道模組物件處於未知狀態(且相對於模組作者的意圖,很可能已經損壞)。" #: ../../c-api/import.rst:139 msgid "" @@ -164,6 +201,10 @@ msgid "" "will be set to the module's :attr:`!__loader__` (if set) and to an instance " "of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" +"如果尚未設定,模組的 :attr:`~module.__spec__` 和 :attr:`~module.__loader__` " +"將會被設定為適當的值。規格的載入器將被設定為模組的 :attr:`!__loader__`\\ (如" +"果有設定),否則將被設定為 :class:`~importlib.machinery.SourceFileLoader` 的" +"實例。" #: ../../c-api/import.rst:144 msgid "" @@ -171,40 +212,53 @@ msgid "" "object's :attr:`~codeobject.co_filename`. If " "applicable, :attr:`~module.__cached__` will also be set." msgstr "" +"模組的 :attr:`~module.__file__` 屬性將會設定為程式碼物件" +"的 :attr:`~codeobject.co_filename`。如果適用,:attr:`~module.__cached__` 也會" +"被設定。" #: ../../c-api/import.rst:148 msgid "" "This function will reload the module if it was already imported. " "See :c:func:`PyImport_ReloadModule` for the intended way to reload a module." msgstr "" +"如果模組已經被引入,這個函式會重新載入模組。請參" +"閱 :c:func:`PyImport_ReloadModule` 以取得重新載入模組的預期方法。" #: ../../c-api/import.rst:151 msgid "" "If *name* points to a dotted name of the form ``package.module``, any " "package structures not already created will still not be created." msgstr "" +"如果 *name* 指向形式為 ``package.module`` 的點名稱,則任何尚未建立的套件結構" +"仍不會被建立。" #: ../../c-api/import.rst:154 msgid "" "See also :c:func:`PyImport_ExecCodeModuleEx` " "and :c:func:`PyImport_ExecCodeModuleWithPathnames`." msgstr "" +"另請參閱 :c:func:`PyImport_ExecCodeModuleEx` " +"及 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" #: ../../c-api/import.rst:157 msgid "" "The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " "deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" +":attr:`~module.__cached__` 和 :attr:`~module.__loader__` 的設定已被棄用。請參" +"閱 :class:`~importlib.machinery.ModuleSpec` 以取得替代方案。" #: ../../c-api/import.rst:165 msgid "" "Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__` " "attribute of the module object is set to *pathname* if it is non-``NULL``." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModule`,但是如果 *pathname* 不是 ``NULL``," +"模組物件的 :attr:`~module.__file__` 屬性會被設定為 *pathname*。" #: ../../c-api/import.rst:168 msgid "See also :c:func:`PyImport_ExecCodeModuleWithPathnames`." -msgstr "也請見 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" +msgstr "另請參閱 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" #: ../../c-api/import.rst:173 msgid "" @@ -212,12 +266,17 @@ msgid "" "attribute of the module object is set to *cpathname* if it is non-``NULL``. " "Of the three functions, this is the preferred one to use." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModuleEx`,但是如果 *cpathname* 不" +"是 ``NULL``,模組物件的 :attr:`~module.__cached__` 屬性會被設定" +"為 *cpathname*。在這三個函式中,這是首選的函式。" #: ../../c-api/import.rst:179 msgid "" "Setting :attr:`~module.__cached__` is deprecated. " "See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" +"設定 :attr:`~module.__cached__` 已被棄用。請參" +"閱 :class:`~importlib.machinery.ModuleSpec` 以取得替代方案。" #: ../../c-api/import.rst:186 msgid "" @@ -226,12 +285,17 @@ msgid "" "what the value for *pathname* should be from *cpathname* if the former is " "set to ``NULL``." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModuleObject`,但是 *name*、*pathname* 和 " +"*cpathname* 是 UTF-8 編碼的字串。如果 *pathname* 被設定為 ``NULL``,也會嘗試從 " +"*cpathname* 中找出 *pathname* 的值應該是什麼。" #: ../../c-api/import.rst:192 msgid "" "Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." msgstr "" +"如果只提供了位元組碼路徑,則在計算原始碼路徑時使" +"用 :func:`!imp.source_from_cache`。" #: ../../c-api/import.rst:195 msgid "No longer uses the removed :mod:`!imp` module." @@ -243,6 +307,9 @@ msgid "" "file). The magic number should be present in the first four bytes of the " "bytecode file, in little-endian byte order. Returns ``-1`` on error." msgstr "" +"回傳 Python 位元組碼檔案(也稱為 :file:`.pyc` 檔案)的魔術數字(magic " +"number)。魔術數字應該出現在位元組碼檔案的前四個位元組,以小端序(little-" +"endian)位元組順序排列。錯誤時會回傳 ``-1``。" #: ../../c-api/import.rst:205 msgid "Return value of ``-1`` upon failure." @@ -254,12 +321,16 @@ msgid "" "names. Keep in mind that the value at ``sys.implementation.cache_tag`` is " "authoritative and should be used instead of this function." msgstr "" +"回傳 :pep:`3147` 格式 Python 位元組碼檔名的魔術標籤字串。請記住," +"``sys.implementation.cache_tag`` 的值是權威的,應該使用它來取代這個函式。" #: ../../c-api/import.rst:219 msgid "" "Return the dictionary used for the module administration (a.k.a. " "``sys.modules``). Note that this is a per-interpreter variable." msgstr "" +"回傳用於模組管理的字典(也稱為 ``sys.modules``)。請注意,這是一個針對每個直" +"譯器的變數 (per-interpreter variable)。" #: ../../c-api/import.rst:224 msgid "" @@ -267,6 +338,8 @@ msgid "" "not been imported yet then returns ``NULL`` but does not set an error. " "Returns ``NULL`` and sets an error if the lookup failed." msgstr "" +"回傳已以給定名稱引入的模組。如果模組尚未引入,則會回傳 ``NULL`` 但不會設" +"定錯誤。如果查找失敗,則回傳 ``NULL`` 並設定錯誤。" #: ../../c-api/import.rst:232 msgid "" @@ -279,6 +352,12 @@ msgid "" "in :data:`sys.path_importer_cache`. Return a new reference to the finder " "object." msgstr "" +"回傳 :data:`sys.path`/:attr:`!pkg.__path__` 項 *path* 的查找器物件 (finder object)," +"可能的方式是從 :data:`sys.path_importer_cache` 字典取得。如果它還沒有被快取,就遍" +"歷 :data:`sys.path_hooks` 直到找到可以處理路徑項的掛勾。如果沒有掛勾可以處" +"理,則回傳 ``None``;這會告訴我們的呼叫者 :term:`path based finder` 找不到這" +"個路徑項的查找器。將結果快取到 :data:`sys.path_importer_cache`。回傳查找器物" +"件的新參照。" #: ../../c-api/import.rst:243 msgid "" @@ -288,16 +367,22 @@ msgid "" "use :c:func:`PyImport_ImportModule`. (Note the misnomer --- this function " "would reload the module if it was already imported.)" msgstr "" +"載入一個名為 *name* 的凍結模組。成功則回傳 ``1``,找不到模組則回傳 ``0``,初始" +"化失敗則回傳 ``-1`` 並設定例外。要在成功載入時存取引入的模組,請使" +"用 :c:func:`PyImport_ImportModule`。(請注意這個名稱並不恰當 --- 如果模組已經" +"被引入,這個函式會重新載入模組)。" #: ../../c-api/import.rst:251 msgid "The ``__file__`` attribute is no longer set on the module." -msgstr "" +msgstr "不會再於模組設定 ``__file__`` 屬性。" #: ../../c-api/import.rst:257 msgid "" "Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" +"類似於 :c:func:`PyImport_ImportFrozenModuleObject`,但名稱是 UTF-8 編碼字串," +"而不是 Unicode 物件。" #: ../../c-api/import.rst:265 msgid "" @@ -306,6 +391,9 @@ msgid "" "Python source distribution). Its definition, found in :file:`Include/" "import.h`, is::" msgstr "" +"這是由 :program:`freeze` 工具程式產生的凍結模組描述器的結構型別定義(請參閱 " +"Python 原始碼發行版中的 :file:`Tools/freeze/`)。它的定義在 :file:`Include/" +"import.h` 中,為: ::" #: ../../c-api/import.rst:270 msgid "" @@ -328,6 +416,8 @@ msgid "" "The new ``is_package`` field indicates whether the module is a package or " "not. This replaces setting the ``size`` field to a negative value." msgstr "" +"新的 ``is_package`` 欄位指出模組是否為套件。這取代了將 ``size`` 欄位設定為負" +"值的方式。" #: ../../c-api/import.rst:283 msgid "" @@ -337,6 +427,9 @@ msgid "" "could play tricks with this to provide a dynamically created collection of " "frozen modules." msgstr "" +"這個指標會被初始化為指向一個 :c:struct:`_frozen` 記錄的陣列,以一個其成員都是 " +"``NULL`` 或 0 的記錄為結尾。當一個凍結的模組被引入時,它會在這個表格中被搜" +"尋。第三方程式碼可以利用這一點來提供一個動態建立的凍結模組集合。" #: ../../c-api/import.rst:291 msgid "" @@ -347,6 +440,10 @@ msgid "" "function called on the first attempted import. This should be called " "before :c:func:`Py_Initialize`." msgstr "" +"新增單一模組到現有的內建模組表格。這是 :c:func:`PyImport_ExtendInittab` 的便" +"利包裝器,如果表格無法擴充會回傳 ``-1``。新的模組可以用 *name* 的名稱引入,並" +"使用函式 *initfunc* 作為第一次嘗試引入時呼叫的初始化函式。這應該" +"在 :c:func:`Py_Initialize` 之前呼叫。" #: ../../c-api/import.rst:301 msgid "" @@ -355,14 +452,17 @@ msgid "" "conjunction with :c:func:`PyImport_ExtendInittab` to provide additional " "built-in modules. The structure consists of two members:" msgstr "" +"描述內建模組列表中單一項目的結構。嵌入 Python 的程式可以使用這些結構的陣列" +"與 :c:func:`PyImport_ExtendInittab` 結合來提供額外的內建模組。這個結構包含兩" +"個成員:" #: ../../c-api/import.rst:309 msgid "The module name, as an ASCII encoded string." -msgstr "" +msgstr "模組名稱,為 ASCII 編碼的字串。" #: ../../c-api/import.rst:313 msgid "Initialization function for a module built into the interpreter." -msgstr "" +msgstr "內建於直譯器中的模組的初始化函式。" #: ../../c-api/import.rst:318 msgid "" @@ -374,6 +474,11 @@ msgid "" "event of failure, no modules are added to the internal table. This must be " "called before :c:func:`Py_Initialize`." msgstr "" +"新增一個模組集合到內建模組表格。*newtab* 陣列必須以包含 ``NULL`` " +"的 :c:member:`~_inittab.name` 欄位的哨兵項目(sentinel entry)結尾;如果沒有" +"提供哨兵值,可能會導致記憶體錯誤。成功時會回傳 ``0``,如果沒有足夠的記憶體可" +"以分配來擴充內部表格則回傳 ``-1``。在失敗的情況下,沒有模組會被加入內部表格。" +"這個函式必須在 :c:func:`Py_Initialize` 之前呼叫。" #: ../../c-api/import.rst:325 msgid "" @@ -381,10 +486,12 @@ msgid "" "or :c:func:`PyImport_ExtendInittab` must be called before each Python " "initialization." msgstr "" +"如果 Python 被多次初始化,:c:func:`PyImport_AppendInittab` " +"或 :c:func:`PyImport_ExtendInittab` 必須在每次 Python 初始化之前被呼叫。" #: ../../c-api/import.rst:332 msgid "Import the module *mod_name* and get its attribute *attr_name*." -msgstr "" +msgstr "引入模組 *mod_name* 並取得其屬性 *attr_name*。" #: ../../c-api/import.rst:334 msgid "Names must be Python :class:`str` objects." @@ -397,12 +504,17 @@ msgid "" "if the module is not found, and :exc:`AttributeError` if the attribute " "doesn't exist." msgstr "" +"結合 :c:func:`PyImport_Import` 和 :c:func:`PyObject_GetAttr` 的輔助函式。例" +"如,如果找不到模組,它會引發 :exc:`ImportError`,如果屬性不存在,則會引" +"發 :exc:`AttributeError`。" #: ../../c-api/import.rst:345 msgid "" "Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded " "strings instead of Python :class:`str` objects." msgstr "" +"類似於 :c:func:`PyImport_ImportModuleAttr`,但名稱是 UTF-8 編碼字串,而不是 " +"Python :class:`str` 物件。" #: ../../c-api/import.rst:11 msgid "package variable" @@ -434,4 +546,4 @@ msgstr "compile(編譯)" #: ../../c-api/import.rst:263 msgid "freeze utility" -msgstr "freeze utility(凍結工具)" +msgstr "freeze utility(凍結工具程式)"