diff --git a/library/zipapp.po b/library/zipapp.po index d8c15093bb..15bbb40110 100644 --- a/library/zipapp.po +++ b/library/zipapp.po @@ -3,13 +3,14 @@ # # Translators: # Adrian Liaw , 2018 +# Dr-XYZ , 2025 msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" -"PO-Revision-Date: 2018-05-23 16:16+0000\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2025-07-13 16:00+0800\n" +"Last-Translator: Dr-XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -33,6 +34,10 @@ msgid "" "`. The module provides both a :ref:`zipapp-" "command-line-interface` and a :ref:`zipapp-python-api`." msgstr "" +"本模組提供工具來建立包含 Python 程式碼的 zip 檔案,這些檔案可以 :ref:`直接由 " +"Python 直譯器執行 `。此模組同時提供了 :ref:" +"`zipapp 命令列介面 ` 和 :ref:`zipapp Python " +"API `。" #: ../../library/zipapp.rst:23 msgid "Basic Example" @@ -45,6 +50,9 @@ msgid "" "code. When run, the archive will execute the ``main`` function from the " "module ``myapp`` in the archive." msgstr "" +"以下範例展示了如何使用 :ref:`zipapp 命令列介面 `,從一個包含 Python 程式碼的目錄中建立一個可執行的封存檔案。執行" +"時,該封存檔案將會執行封存檔案中 ``myapp`` 模組的 ``main`` 函式。" #: ../../library/zipapp.rst:30 msgid "" @@ -63,7 +71,7 @@ msgstr "命令列介面" #: ../../library/zipapp.rst:42 msgid "" "When called as a program from the command line, the following form is used:" -msgstr "" +msgstr "當從命令列作為程式呼叫時,會使用以下格式:" #: ../../library/zipapp.rst:44 msgid "$ python -m zipapp source [options]" @@ -76,10 +84,13 @@ msgid "" "copied to the target archive (or the contents of its shebang line will be " "displayed if the --info option is specified)." msgstr "" +"如果 *source* 是一個目錄,這將會從 *source* 的內容建立一個封存檔案。如果 " +"*source* 是一個檔案,它應該是一個封存檔案,並且它將被複製到目標封存檔案(或者" +"如果指定了 --info 選項,將會顯示其 shebang 行的內容)。" #: ../../library/zipapp.rst:53 msgid "The following options are understood:" -msgstr "" +msgstr "可使用以下選項:" #: ../../library/zipapp.rst:59 msgid "" @@ -88,12 +99,17 @@ msgid "" "extension ``.pyz`` added. If an explicit filename is given, it is used as " "is (so a ``.pyz`` extension should be included if required)." msgstr "" +"將輸出寫入名為 *output* 的檔案。如果未指定此選項,輸出檔名將與輸入 *source* " +"相同,並加上 ``.pyz`` 副檔名。如果給定了明確的檔名,則會直接使用它(因此如果" +"需要,應包含 ``.pyz`` 副檔名)。" #: ../../library/zipapp.rst:64 msgid "" "An output filename must be specified if the *source* is an archive (and in " "that case, *output* must not be the same as *source*)." msgstr "" +"如果 *source* 是一個封存檔案,則必須指定輸出檔名(且在這種情況下,*output* 不" +"得與 *source* 相同)。" #: ../../library/zipapp.rst:69 msgid "" @@ -101,6 +117,9 @@ msgid "" "run. Also, on POSIX, make the archive executable. The default is to write " "no ``#!`` line, and not make the file executable." msgstr "" +"在封存檔案中加入一行 ``#!``,指定 *interpreter* 作為要執行的命令。此外,在 " +"POSIX 上,使封存檔案成為可執行檔。預設是不寫入 ``#!`` 行,也不讓檔案成為可執" +"行檔。" #: ../../library/zipapp.rst:75 msgid "" @@ -109,20 +128,25 @@ msgid "" "a package/module in the archive, and \"fn\" is a callable in the given " "module. The ``__main__.py`` file will execute that callable." msgstr "" +"在封存檔案中寫入一個執行 *mainfn* 的 ``__main__.py`` 檔案。*mainfn* 引數應為" +" \"pkg.mod:fn\" 的形式,其中 \"pkg.mod\" 是封存檔案中的一個套件/模組,而 \"fn\" 是" +"給定模組中的一個可呼叫物件。``__main__.py`` 檔案將會執行該可呼叫物件。" #: ../../library/zipapp.rst:80 msgid ":option:`--main` cannot be specified when copying an archive." -msgstr "" +msgstr "複製封存檔案時,不可指定 :option:`--main`。" #: ../../library/zipapp.rst:84 msgid "" "Compress files with the deflate method, reducing the size of the output " "file. By default, files are stored uncompressed in the archive." msgstr "" +"使用 deflate 方法壓縮檔案,以減少輸出檔案的大小。預設情況下,檔案在封存檔案中" +"是不壓縮儲存的。" #: ../../library/zipapp.rst:87 msgid ":option:`--compress` has no effect when copying an archive." -msgstr "" +msgstr "複製封存檔案時,:option:`--compress` 沒有作用。" #: ../../library/zipapp.rst:93 msgid "" @@ -130,24 +154,26 @@ msgid "" "In this case, any other options are ignored and SOURCE must be an archive, " "not a directory." msgstr "" +"顯示嵌入在封存檔案中的直譯器,以供診斷之用。在這種情況下,任何其他選項都會被" +"忽略,且 SOURCE 必須是一個封存檔案,而不是一個目錄。" #: ../../library/zipapp.rst:99 msgid "Print a short usage message and exit." -msgstr "" +msgstr "印出簡短的使用訊息並退出。" #: ../../library/zipapp.rst:105 msgid "Python API" -msgstr "" +msgstr "Python API" #: ../../library/zipapp.rst:107 msgid "The module defines two convenience functions:" -msgstr "" +msgstr "此模組定義了兩個便利的函式:" #: ../../library/zipapp.rst:112 msgid "" "Create an application archive from *source*. The source can be any of the " "following:" -msgstr "" +msgstr "從 *source* 建立一個應用程式封存檔案。source 可以是以下任何一種:" #: ../../library/zipapp.rst:115 msgid "" @@ -155,6 +181,8 @@ msgid "" "directory, in which case a new application archive will be created from the " "content of that directory." msgstr "" +"一個目錄的名稱,或是一個指向目錄的 :term:`類路徑物件 `,在" +"這種情況下,將會從該目錄的內容建立一個新的應用程式封存檔案。" #: ../../library/zipapp.rst:118 msgid "" @@ -163,6 +191,9 @@ msgid "" "target (modifying it to reflect the value given for the *interpreter* " "argument). The file name should include the ``.pyz`` extension, if required." msgstr "" +"一個現有應用程式封存檔案的名稱,或是一個指向該檔案的 :term:`類路徑物件 `,在這種情況下,該檔案會被複製到目標(並修改它以反映為 " +"*interpreter* 引數所給定的值)。如果需要,檔名應包含 ``.pyz`` 副檔名。" #: ../../library/zipapp.rst:122 msgid "" @@ -170,23 +201,29 @@ msgid "" "should be an application archive, and the file object is assumed to be " "positioned at the start of the archive." msgstr "" +"一個以位元組模式開啟以供讀取的檔案物件。該檔案的內容應該是一個應用程式封存檔" +"案,並且檔案物件被假定位於封存檔案的開頭。" #: ../../library/zipapp.rst:126 msgid "" "The *target* argument determines where the resulting archive will be written:" -msgstr "" +msgstr "*target* 引數決定了產生的封存檔案將被寫入何處:" #: ../../library/zipapp.rst:129 msgid "" "If it is the name of a file, or a :term:`path-like object`, the archive will " "be written to that file." msgstr "" +"如果它是一個檔案的名稱,或是一個 :term:`類路徑物件 `,封存" +"檔案將被寫入該檔案。" #: ../../library/zipapp.rst:131 msgid "" "If it is an open file object, the archive will be written to that file " "object, which must be open for writing in bytes mode." msgstr "" +"如果它是一個開啟的檔案物件,封存檔案將被寫入該檔案物件,該物件必須以位元組模" +"式開啟以供寫入。" #: ../../library/zipapp.rst:133 msgid "" @@ -194,6 +231,8 @@ msgid "" "the target will be a file with the same name as the source, with a ``.pyz`` " "extension added." msgstr "" +"如果省略了 target(或為 ``None``),則 source 必須是一個目錄,而 target 將" +"是一個與 source 同名的檔案,並加上 ``.pyz`` 副檔名。" #: ../../library/zipapp.rst:137 msgid "" @@ -205,6 +244,11 @@ msgid "" "is specified, and the target is a filename, the executable bit of the target " "file will be set." msgstr "" +"*interpreter* 引數指定了將用來執行封存檔案的 Python 直譯器名稱。它會作為" +"「shebang」行寫入封存檔案的開頭。在 POSIX 上,這將由作業系統解讀,而在 " +"Windows 上,它將由 Python 啟動器處理。省略 *interpreter* 將導致不寫入 " +"shebang 行。如果指定了直譯器,且 target 是一個檔名,則目標檔案的可執行位元將" +"被設定。" #: ../../library/zipapp.rst:145 msgid "" @@ -217,6 +261,12 @@ msgid "" "a directory and does not contain a ``__main__.py`` file, as otherwise the " "resulting archive would not be executable." msgstr "" +"*main* 引數指定了一個可呼叫物件的名稱,它將被用作封存檔案的主程式。只有當 " +"source 是一個目錄,且該 source 尚未包含 ``__main__.py`` 檔案時,才能指定此引" +"數。*main* 引數應採用「pkg.module:callable」的形式,封存檔案將透過引入「pkg." +"module」並執行給定的無引數可呼叫物件來執行。如果 source 是一個目錄且不包含 " +"``__main__.py`` 檔案,則省略 *main* 會導致錯誤,因為這樣產生的封存檔案將無法" +"執行。" #: ../../library/zipapp.rst:155 msgid "" @@ -224,6 +274,8 @@ msgid "" "a Path object representing the path to the file being added (relative to the " "source directory). It should return ``True`` if the file is to be added." msgstr "" +"可選的 *filter* 引數指定了一個回呼函式,該函式會被傳入一個 Path 物件,代表要" +"加入的檔案路徑(相對於 source 目錄)。如果要加入該檔案,它應該回傳 ``True``。" #: ../../library/zipapp.rst:160 msgid "" @@ -232,12 +284,17 @@ msgid "" "method; otherwise, files are stored uncompressed. This argument has no " "effect when copying an existing archive." msgstr "" +"可選的 *compressed* 引數決定檔案是否被壓縮。如果設定為 ``True``,封存檔案中的" +"檔案將使用 deflate 方法進行壓縮;否則,檔案將不壓縮儲存。複製現有封存檔案時," +"此引數無效。" #: ../../library/zipapp.rst:165 msgid "" "If a file object is specified for *source* or *target*, it is the caller's " "responsibility to close it after calling create_archive." msgstr "" +"如果為 *source* 或 *target* 指定了檔案物件,呼叫者有責任在呼叫 " +"create_archive 後將其關閉。" #: ../../library/zipapp.rst:168 msgid "" @@ -246,6 +303,9 @@ msgid "" "directory, if the target is a file object it will be passed to the ``zipfile." "ZipFile`` class, and must supply the methods needed by that class." msgstr "" +"複製現有封存檔案時,提供的檔案物件只需要 ``read`` 和 ``readline``,或 " +"``write`` 方法。從目錄建立封存檔案時,如果 target 是一個檔案物件,它將被傳遞" +"給 ``zipfile.ZipFile`` 類別,並且必須提供該類別所需的方法。" #: ../../library/zipapp.rst:174 msgid "Added the *filter* and *compressed* parameters." @@ -258,6 +318,9 @@ msgid "" "argument can be a filename or a file-like object open for reading in bytes " "mode. It is assumed to be at the start of the archive." msgstr "" +"回傳封存檔案開頭 ``#!`` 行中指定的直譯器。如果沒有 ``#!`` 行,則回傳 :const:" +"`None`。*archive* 引數可以是一個檔名或一個以位元組模式開啟以供讀取的類檔案物" +"件。它被假定位於封存檔案的開頭。" #: ../../library/zipapp.rst:188 msgid "Examples" @@ -265,7 +328,7 @@ msgstr "範例" #: ../../library/zipapp.rst:190 msgid "Pack up a directory into an archive, and run it." -msgstr "" +msgstr "將一個目錄打包成一個封存檔案,並執行它。" #: ../../library/zipapp.rst:192 msgid "" @@ -279,7 +342,7 @@ msgstr "" #: ../../library/zipapp.rst:198 msgid "The same can be done using the :func:`create_archive` function::" -msgstr "" +msgstr "使用 :func:`create_archive` 函式也可以達到同樣的效果: ::" #: ../../library/zipapp.rst:200 msgid "" @@ -293,7 +356,7 @@ msgstr "" msgid "" "To make the application directly executable on POSIX, specify an interpreter " "to use." -msgstr "" +msgstr "要讓應用程式在 POSIX 上可以直接執行,請指定要使用的直譯器。" #: ../../library/zipapp.rst:206 msgid "" @@ -310,6 +373,8 @@ msgid "" "To replace the shebang line on an existing archive, create a modified " "archive using the :func:`create_archive` function::" msgstr "" +"要替換現有封存檔案上的 shebang 行,請使用 :func:`create_archive` 函式建立一個" +"修改過的封存檔案: ::" #: ../../library/zipapp.rst:215 msgid "" @@ -330,6 +395,10 @@ msgid "" "errors, but production code should do so. Also, this method will only work " "if the archive fits in memory::" msgstr "" +"要原地 (in place) 更新檔案,請使用 :class:`~io.BytesIO` 物件在記憶體中進行替換,然後再覆" +"寫來源檔案。請注意,原地覆寫檔案存在風險,錯誤可能導致原始檔案遺失。這段程式" +"碼沒有防範此類錯誤,但生產環境的程式碼應作此類防護。此外,此方法只有在封存檔" +"案能容納於記憶體中時才有效: ::" #: ../../library/zipapp.rst:225 msgid "" @@ -349,7 +418,7 @@ msgstr "" #: ../../library/zipapp.rst:236 msgid "Specifying the Interpreter" -msgstr "" +msgstr "指定直譯器" #: ../../library/zipapp.rst:238 msgid "" @@ -358,6 +427,9 @@ msgid "" "Python launcher for Windows supports most common forms of POSIX ``#!`` line, " "but there are other issues to consider:" msgstr "" +"請注意,如果你指定了一個直譯器然後分發你的應用程式封存檔案,你需要確保所使用" +"的直譯器是可攜的。Windows 的 Python 啟動器支援大多數常見形式的 POSIX ``#!`` " +"行,但還有其他問題需要考慮:" #: ../../library/zipapp.rst:243 msgid "" @@ -366,6 +438,9 @@ msgid "" "may have either Python 2 or Python 3 as their default, and write your code " "to work under both versions." msgstr "" +"如果你使用「/usr/bin/env python」(或「python」命令的其他形式,例如「/usr/" +"bin/python」),你需要考慮到你的使用者可能將 Python 2 或 Python 3 作為預設版" +"本,並編寫你的程式碼使其能在兩個版本下運作。" #: ../../library/zipapp.rst:247 msgid "" @@ -373,6 +448,9 @@ msgid "" "application will not work for users who do not have that version. (This may " "be what you want if you have not made your code Python 2 compatible)." msgstr "" +"如果你使用一個明確的版本,例如「/usr/bin/env python3」,你的應用程式將無法為" +"沒有該版本的使用者運作。(如果你尚未讓你的程式碼與 Python 2 相容,這可能正是" +"你想要的)。" #: ../../library/zipapp.rst:250 msgid "" @@ -380,16 +458,21 @@ msgid "" "exact version like \"/usr/bin/env python3.4\" as you will need to change " "your shebang line for users of Python 3.5, for example." msgstr "" +"沒有辦法說「python X.Y 或更新版本」,所以要小心使用像「/usr/bin/env " +"python3.4」這樣的確切版本,因為舉例來說,你將需要為 Python 3.5 的使用者更改你" +"的 shebang 行。" #: ../../library/zipapp.rst:254 msgid "" "Typically, you should use an \"/usr/bin/env python2\" or \"/usr/bin/env " "python3\", depending on whether your code is written for Python 2 or 3." msgstr "" +"通常,你應該使用「/usr/bin/env python2」或「/usr/bin/env python3」,這取決於" +"你的程式碼是為 Python 2 還是 Python 3 編寫的。" #: ../../library/zipapp.rst:259 msgid "Creating Standalone Applications with zipapp" -msgstr "" +msgstr "使用 zipapp 建立獨立應用程式" #: ../../library/zipapp.rst:261 msgid "" @@ -399,10 +482,13 @@ msgid "" "this is to bundle all of the application's dependencies into the archive, " "along with the application code." msgstr "" +"使用 :mod:`zipapp` 模組,可以建立獨立的 Python 程式,這些程式可以分發給終端使" +"用者,他們只需要在他們的系統上安裝合適版本的 Python。實現這一點的關鍵是將應用" +"程式的所有依賴項與應用程式程式碼一起打包到封存檔案中。" #: ../../library/zipapp.rst:267 msgid "The steps to create a standalone archive are as follows:" -msgstr "" +msgstr "建立獨立封存檔案的步驟如下:" #: ../../library/zipapp.rst:269 msgid "" @@ -410,12 +496,14 @@ msgid "" "directory containing a ``__main__.py`` file, and any supporting application " "code." msgstr "" +"像平常一樣在一個目錄中建立你的應用程式,這樣你就有一個 ``myapp`` 目錄,其中包" +"含一個 ``__main__.py`` 檔案和任何支援的應用程式程式碼。" #: ../../library/zipapp.rst:273 msgid "" "Install all of your application's dependencies into the ``myapp`` directory, " "using pip:" -msgstr "" +msgstr "使用 pip 將你應用程式的所有依賴項安裝到 ``myapp`` 目錄中:" #: ../../library/zipapp.rst:276 msgid "$ python -m pip install -r requirements.txt --target myapp" @@ -427,10 +515,12 @@ msgid "" "file - if not, you can just list the dependencies manually on the pip " "command line)." msgstr "" +"(這假設你的專案需求在一個 ``requirements.txt`` 檔案中——如果沒有,你可以在 " +"pip 命令列上手動列出依賴項)。" #: ../../library/zipapp.rst:284 msgid "Package the application using:" -msgstr "" +msgstr "使用以下命令打包應用程式:" #: ../../library/zipapp.rst:286 msgid "$ python -m zipapp -p \"interpreter\" myapp" @@ -442,6 +532,9 @@ msgid "" "with the appropriate interpreter available. See :ref:`zipapp-specifying-the-" "interpreter` for details. It can be shipped to users as a single file." msgstr "" +"這將產生一個獨立的可執行檔,可以在任何有適當直譯器的機器上執行。詳情請參閱 :" +"ref:`指定直譯器 `。它可以作為單一檔案交付" +"給使用者。" #: ../../library/zipapp.rst:294 msgid "" @@ -451,10 +544,14 @@ msgid "" "fact that the Python interpreter registers the ``.pyz`` and ``.pyzw`` file " "extensions when installed." msgstr "" +"在 Unix 上,``myapp.pyz`` 檔案本身就是可執行的。如果你偏好一個「普通」的命令" +"名稱,可以重新命名檔案以移除 ``.pyz`` 副檔名。在 Windows 上,``myapp." +"pyz[w]`` 檔案是可執行的,因為 Python 直譯器在安裝時會註冊 ``.pyz`` 和 ``." +"pyzw`` 副檔名。" #: ../../library/zipapp.rst:302 msgid "Caveats" -msgstr "" +msgstr "注意事項" #: ../../library/zipapp.rst:304 msgid "" @@ -469,10 +566,17 @@ msgid "" "(and potentially pick the correct version to add to ``sys.path`` at runtime, " "based on the user's machine)." msgstr "" +"如果你的應用程式依賴於一個包含 C 擴充的套件,該套件無法從 zip 檔案中執行(這" +"是一個作業系統的限制,因為可執行程式碼必須存在於檔案系統中,作業系統的載入器" +"才能載入它)。在這種情況下,你可以從 zipfile 中排除該依賴項,並要求你的使用者" +"安裝它,或者將它與你的 zipfile 一起發布,並在你的 ``__main__.py`` 中加入程式" +"碼,將包含解壓縮後模組的目錄加入到 ``sys.path`` 中。在這種情況下,你需要確保" +"為你的目標架構提供適當的二進位檔案(並可能在 runtime 根據使用者的機器選擇正確" +"的版本加入到 ``sys.path`` 中)。" #: ../../library/zipapp.rst:316 msgid "The Python Zip Application Archive Format" -msgstr "" +msgstr "Python Zip 應用程式封存檔案格式" #: ../../library/zipapp.rst:318 msgid "" @@ -484,6 +588,11 @@ msgid "" "be placed on :data:`sys.path` and thus further modules can be imported from " "the zip file." msgstr "" +"自 2.6 版以來,Python 就能夠執行包含 ``__main__.py`` 檔案的 zip 檔案。為了能" +"被 Python 執行,一個應用程式封存檔案只需要是一個標準的 zip 檔案,其中包含一" +"個 ``__main__.py`` 檔案,該檔案將作為應用程式的進入點執行。如同任何 Python 腳" +"本一樣,腳本的父目錄(在此情況下是 zip 檔案)將被放置在 :data:`sys.path` 上," +"因此可以從 zip 檔案中引入更多的模組。" #: ../../library/zipapp.rst:325 msgid "" @@ -491,10 +600,12 @@ msgid "" "The zip application format uses this ability to prepend a standard POSIX " "\"shebang\" line to the file (``#!/path/to/interpreter``)." msgstr "" +"zip 檔案格式允許在 zip 檔案前附加任意資料。zip 應用程式格式利用此功能在檔案前" +"附加一個標準的 POSIX「shebang」行(``#!/path/to/interpreter``)。" #: ../../library/zipapp.rst:329 msgid "Formally, the Python zip application format is therefore:" -msgstr "" +msgstr "因此,Python zip 應用程式格式的正式定義如下:" #: ../../library/zipapp.rst:331 msgid "" @@ -505,6 +616,10 @@ msgid "" "encoded in UTF-8 on Windows, and in :func:`sys.getfilesystemencoding` on " "POSIX." msgstr "" +"一個可選的 shebang 行,包含字元 ``b'#!'``,後跟一個直譯器名稱,然後是一個換行" +"符(\\ ``b'\\n'``\\ )。直譯器名稱可以是任何作業系統「shebang」處理或 " +"Windows 上的 Python 啟動器可接受的內容。在 Windows 上,直譯器應以 UTF-8 編" +"碼,在 POSIX 上應以 :func:`sys.getfilesystemencoding` 編碼。" #: ../../library/zipapp.rst:336 msgid "" @@ -513,12 +628,17 @@ msgid "" "in the \"root\" of the zipfile - i.e., it cannot be in a subdirectory). The " "zipfile data can be compressed or uncompressed." msgstr "" +"由 :mod:`zipfile` 模組產生的標準 zipfile 資料。zipfile 內容*必須*包含一個名" +"為 ``__main__.py`` 的檔案(該檔案必須位於 zipfile 的「根目錄」中——即,它不能" +"在子目錄中)。zipfile 資料可以被壓縮或不壓縮。" #: ../../library/zipapp.rst:341 msgid "" "If an application archive has a shebang line, it may have the executable bit " "set on POSIX systems, to allow it to be executed directly." msgstr "" +"如果應用程式封存檔案有 shebang 行,它在 POSIX 系統上可能會設定可執行位元,以" +"允許其直接執行。" #: ../../library/zipapp.rst:344 msgid "" @@ -526,6 +646,8 @@ msgid "" "application archives - the module is a convenience, but archives in the " "above format created by any means are acceptable to Python." msgstr "" +"沒有要求必須使用此模組中的工具來建立應用程式封存檔案——此模組是一個便利工具," +"但以任何方式建立的符合上述格式的封存檔案對 Python 都是可接受的。" #: ../../library/zipapp.rst:11 msgid "Executable Zip Files"