From 489e76f9957f655a8661d32b1a6c8d60ffc02af5 Mon Sep 17 00:00:00 2001 From: mindihx Date: Sun, 7 Jan 2024 12:49:33 +0800 Subject: [PATCH 1/2] Translate library/pathlib part 2/2 --- library/pathlib.po | 217 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 171 insertions(+), 46 deletions(-) diff --git a/library/pathlib.po b/library/pathlib.po index 24a94144cc..09ebf62c42 100644 --- a/library/pathlib.po +++ b/library/pathlib.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-24 00:03+0000\n" -"PO-Revision-Date: 2023-12-30 18:12+0800\n" +"PO-Revision-Date: 2024-01-07 10:44+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -120,7 +120,7 @@ msgid "" "access a filesystem. There are three ways to access these classes, which we " "also call *flavours*:" msgstr "" -"純路徑物件提供處理路徑的操作,實際上不會存取檔案系統。有三種方法可以存取這些" +"純路徑物件提供處理路徑的操作,實際上不會存取檔案系統。有三種方式可以存取這些" "類別,我們也稱之為\\ *類型 (flavours)*:" #: ../../library/pathlib.rst:102 @@ -601,7 +601,7 @@ msgstr "" #: ../../library/pathlib.rst:734 msgid "Concrete paths" -msgstr "" +msgstr "實體路徑" #: ../../library/pathlib.rst:736 msgid "" @@ -609,6 +609,8 @@ msgid "" "operations provided by the latter, they also provide methods to do system " "calls on path objects. There are three ways to instantiate concrete paths:" msgstr "" +"實體路徑是純路徑類別的子類別。除了後者本來就有提供的操作,它們也提供方法可以" +"對路徑物件做系統呼叫。有三種方式可以實例化實體路徑:" #: ../../library/pathlib.rst:742 msgid "" @@ -616,18 +618,24 @@ msgid "" "system's path flavour (instantiating it creates either a :class:`PosixPath` " "or a :class:`WindowsPath`)::" msgstr "" +":class:`PurePath` 的子類別,此類別表示系統的路徑類型的實體路徑(實例化時會建" +"立一個 :class:`PosixPath` 或 :class:`WindowsPath`): ::" #: ../../library/pathlib.rst:753 msgid "" "A subclass of :class:`Path` and :class:`PurePosixPath`, this class " "represents concrete non-Windows filesystem paths::" msgstr "" +":class:`Path` 和 :class:`PurePosixPath` 的子類別,此類別表示實體非 Windows 檔" +"案系統路徑: ::" #: ../../library/pathlib.rst:763 msgid "" "A subclass of :class:`Path` and :class:`PureWindowsPath`, this class " "represents concrete Windows filesystem paths::" msgstr "" +":class:`Path` 和 :class:`PureWindowsPath` 的子類別,此類別表示實體 Windows 檔" +"案系統路徑: ::" #: ../../library/pathlib.rst:771 msgid "" @@ -635,10 +643,12 @@ msgid "" "(allowing system calls on non-compatible path flavours could lead to bugs or " "failures in your application)::" msgstr "" +"你只能實例化對應你的系統的類別類型(允許在不相容的路徑類型上做系統呼叫可能在" +"你的應用程式導致漏洞或故障): ::" #: ../../library/pathlib.rst:791 msgid "Methods" -msgstr "" +msgstr "方法" #: ../../library/pathlib.rst:793 msgid "" @@ -646,6 +656,8 @@ msgid "" "methods. Many of these methods can raise an :exc:`OSError` if a system call " "fails (for example because the path doesn't exist)." msgstr "" +"實體路徑除了純路徑的方法之外也提供以下方法。如果系統呼叫失敗(例如因為路徑不" +"存在),以下許多方法會引發 :exc:`OSError`。" #: ../../library/pathlib.rst:799 msgid "" @@ -656,12 +668,18 @@ msgid "" "raising an exception for paths that contain characters unrepresentable at " "the OS level." msgstr "" +":meth:`~Path.exists()`、:meth:`~Path.is_dir()`、:meth:`~Path.is_file()`、:" +"meth:`~Path.is_mount()`、:meth:`~Path.is_symlink()`、:meth:`~Path." +"is_block_device()`、:meth:`~Path.is_char_device()`、:meth:`~Path." +"is_fifo()`、:meth:`~Path.is_socket()` 遇到路徑包含 OS 層無法表示的字元時現在" +"會回傳 ``False`` 而不是引發例外。" #: ../../library/pathlib.rst:809 msgid "" "Return a new path object representing the current directory (as returned by :" "func:`os.getcwd`)::" msgstr "" +"回傳一個代表目前目錄的新的路徑物件(像 :func:`os.getcwd` 回傳的一樣): ::" #: ../../library/pathlib.rst:818 msgid "" @@ -669,6 +687,8 @@ msgid "" "by :func:`os.path.expanduser` with ``~`` construct). If the home directory " "can't be resolved, :exc:`RuntimeError` is raised." msgstr "" +"回傳一個代表使用者家目錄的新的路徑物件(像以 ``~`` 構成的 :func:`os.path." +"expanduser` 的回傳一樣)。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:832 msgid "" @@ -676,12 +696,16 @@ msgid "" "path, like :func:`os.stat`. The result is looked up at each call to this " "method." msgstr "" +"回傳一個包含該路徑資訊的 :class:`os.stat_result` 物件,像 :func:`os.stat` 一" +"樣。每次呼叫此方法都會重新查詢結果。" #: ../../library/pathlib.rst:835 msgid "" "This method normally follows symlinks; to stat a symlink add the argument " "``follow_symlinks=False``, or use :meth:`~Path.lstat`." msgstr "" +"此方法通常會跟隨 (follow) 符號連結;想要取得符號連結的資訊,可以加上引數 " +"``follow_symlinks=False`` 或使用 :meth:`~Path.lstat`。" #: ../../library/pathlib.rst:846 ../../library/pathlib.rst:866 #: ../../library/pathlib.rst:887 @@ -690,7 +714,7 @@ msgstr "新增 *follow_symlinks* 參數。" #: ../../library/pathlib.rst:851 msgid "Change the file mode and permissions, like :func:`os.chmod`." -msgstr "" +msgstr "修改檔案模式 (file mode) 與權限,像 :func:`os.chmod` 一樣。" #: ../../library/pathlib.rst:853 msgid "" @@ -698,16 +722,20 @@ msgid "" "permissions on the symlink itself; on these platforms you may add the " "argument ``follow_symlinks=False``, or use :meth:`~Path.lchmod`." msgstr "" +"此方法通常會跟隨符號連結。一些 Unix 類型支援修改符號連結本身的權限;在這些平" +"台上你可以加上引數 ``follow_symlinks=False`` 或使用 :meth:`~Path.lchmod`。" #: ../../library/pathlib.rst:871 msgid "Return ``True`` if the path points to an existing file or directory." -msgstr "" +msgstr "如果路徑指向存在的檔案或目錄則回傳 ``True``。" #: ../../library/pathlib.rst:873 msgid "" "This method normally follows symlinks; to check if a symlink exists, add the " "argument ``follow_symlinks=False``." msgstr "" +"此方法通常會跟隨符號連結;如果想檢查符號連結是否存在,可以加上引數 " +"``follow_symlinks=False``。" #: ../../library/pathlib.rst:892 msgid "" @@ -715,12 +743,16 @@ msgid "" "by :meth:`os.path.expanduser`. If a home directory can't be resolved, :exc:" "`RuntimeError` is raised." msgstr "" +"回傳一個展開 ``~`` 和 ``~user`` 構成的新路徑,像 :meth:`os.path.expanduser` " +"回傳的一樣。如果無法解析家目錄,會引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:907 msgid "" "Glob the given relative *pattern* in the directory represented by this path, " "yielding all matching files (of any kind)::" msgstr "" +"在該路徑表示的目錄裡,以 glob 方式比對所給定的相對 *pattern*,並 yield 所有比" +"對到的檔案(任意類型): ::" #: ../../library/pathlib.rst:915 msgid "" @@ -728,6 +760,8 @@ msgid "" "which means \"this directory and all subdirectories, recursively\". In " "other words, it enables recursive globbing::" msgstr "" +"模式 (pattern) 和給 :mod:`fnmatch` 的一樣,加上 “``**``” 代表「目前目錄及所有" +"遞迴的子目錄」。也就是說它能夠做遞迴的 glob 比對: ::" #: ../../library/pathlib.rst:926 msgid "" @@ -743,12 +777,16 @@ msgid "" "typically, case-sensitive on POSIX, and case-insensitive on Windows. Set " "*case_sensitive* to ``True`` or ``False`` to override this behaviour." msgstr "" +"預設情況下,或者當 *case_sensitive* 關鍵字參數被設定為 ``None`` 的時候,此方" +"法會使用平台特定的大小寫規則來比對路徑;通常在 POSIX 上會區分大小寫,而在 " +"Windows 上不區分大小寫。將 *case_sensitive* 設成 ``True`` 或 ``False`` 會覆寫" +"這個行為。" #: ../../library/pathlib.rst:936 msgid "" "Using the \"``**``\" pattern in large directory trees may consume an " "inordinate amount of time." -msgstr "" +msgstr "在很大的目錄樹裡使用 “``**``” 可能會耗費過多的時間。" #: ../../library/pathlib.rst:939 msgid "" @@ -763,18 +801,24 @@ msgid "" "Return only directories if *pattern* ends with a pathname components " "separator (:data:`~os.sep` or :data:`~os.altsep`)." msgstr "" +"如果 *pattern* 以路徑名稱組成的分隔符號(:data:`~os.sep` 或 :data:`~os." +"altsep`)作結尾則只會回傳目錄。" #: ../../library/pathlib.rst:951 msgid "" "Return the name of the group owning the file. :exc:`KeyError` is raised if " "the file's gid isn't found in the system database." msgstr "" +"回傳擁有該檔案的群組名稱。如果在系統資料庫裡找不到檔案的 gid 會引發 :exc:" +"`KeyError`。" #: ../../library/pathlib.rst:957 msgid "" "Return ``True`` if the path points to a directory (or a symbolic link " "pointing to a directory), ``False`` if it points to another kind of file." msgstr "" +"如果該路徑指向一個目錄(或者是一個指向目錄的符號連結)則回傳 ``True``,如果指" +"向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:960 ../../library/pathlib.rst:969 #: ../../library/pathlib.rst:1011 ../../library/pathlib.rst:1020 @@ -783,18 +827,24 @@ msgid "" "``False`` is also returned if the path doesn't exist or is a broken symlink; " "other errors (such as permission errors) are propagated." msgstr "" +"如果路徑不存在或者是一個斷掉的符號連結則也會回傳 ``False``;其他錯誤(例如權" +"限錯誤)則會傳遞出來。" #: ../../library/pathlib.rst:966 msgid "" "Return ``True`` if the path points to a regular file (or a symbolic link " "pointing to a regular file), ``False`` if it points to another kind of file." msgstr "" +"如果該路徑指向一個普通檔案(或者是一個指向普通檔案的符號連結)則回傳 " +"``True``,如果指向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:975 msgid "" "Return ``True`` if the path points to a junction, and ``False`` for any " "other type of file. Currently only Windows supports junctions." msgstr "" +"如果該路徑指向一個 junction 則回傳 ``True``,對其他類型的檔案則回傳 " +"``False``。目前只有 Windows 支援 junction。" #: ../../library/pathlib.rst:983 msgid "" @@ -807,39 +857,52 @@ msgid "" "letter root (e.g. ``c:\\``), a UNC share (e.g. ``\\\\server\\share``), or a " "mounted filesystem directory." msgstr "" +"如果路徑是一個 :dfn:`mount point`\\ (一個檔案系統裡掛載不同檔案系統的存取" +"點)則回傳 ``True``。在 POSIX 上,此函式檢查 *path* 的父路徑 :file:`path/..` " +"是否和 *path* 在不同的裝置上,或者 :file:`path/..` 和 *path* 是否指向相同裝置" +"的相同 i-node ── 這對於所有 Unix 和 POSIX 變體來說應該會偵測出掛載點。在 " +"Windows 上,一個掛載點被視為一個根磁碟機字母(例如 ``c:\\``)、一個 UNC share" +"(例如 ``\\\\server\\share``)或是掛載的檔案系統目錄。" #: ../../library/pathlib.rst:994 msgid "Windows support was added." -msgstr "" +msgstr "加入對 Windows 的支援。" #: ../../library/pathlib.rst:1000 msgid "" "Return ``True`` if the path points to a symbolic link, ``False`` otherwise." -msgstr "" +msgstr "如果該路徑指向一個符號連結則回傳 ``True``,否則回傳 ``False``。" #: ../../library/pathlib.rst:1002 msgid "" "``False`` is also returned if the path doesn't exist; other errors (such as " "permission errors) are propagated." msgstr "" +"如果該路徑不存在也會回傳 ``False``;其他錯誤(例如權限錯誤)則會傳遞出來。" #: ../../library/pathlib.rst:1008 msgid "" "Return ``True`` if the path points to a Unix socket (or a symbolic link " "pointing to a Unix socket), ``False`` if it points to another kind of file." msgstr "" +"如果該路徑指向一個 Unix socket(或者是一個指向 Unix socket 的符號連結)則會回" +"傳 ``True``,如果指向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:1017 msgid "" "Return ``True`` if the path points to a FIFO (or a symbolic link pointing to " "a FIFO), ``False`` if it points to another kind of file." msgstr "" +"如果該路徑指向一個 FIFO(或者是一個指向 FIFO 的符號連結)則會回傳 ``True``," +"如果指向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:1026 msgid "" "Return ``True`` if the path points to a block device (or a symbolic link " "pointing to a block device), ``False`` if it points to another kind of file." msgstr "" +"如果該路徑指向一個區塊裝置 (block device)(或者是一個指向區塊裝置的符號連結)" +"則會回傳 ``True``,如果指向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:1035 msgid "" @@ -847,12 +910,14 @@ msgid "" "pointing to a character device), ``False`` if it points to another kind of " "file." msgstr "" +"如果該路徑指向一個字元裝置 (character device)(或者是一個指向字元裝置的符號連" +"結)則會回傳 ``True``,如果指向其他類型的檔案則回傳 ``False``。" #: ../../library/pathlib.rst:1044 msgid "" "When the path points to a directory, yield path objects of the directory " "contents::" -msgstr "" +msgstr "當該路徑指向一個目錄,會 yield 目錄裡面的路徑物件: ::" #: ../../library/pathlib.rst:1058 msgid "" @@ -861,12 +926,15 @@ msgid "" "directory after creating the iterator, whether a path object for that file " "be included is unspecified." msgstr "" +"子路徑會以任意順序被 yield,且不會包含特殊項目 ``’.’`` 和 ``’..’``。如果一個" +"檔案在建立這個迭代器之後加到該目錄或從目錄刪除,是否會包含這個檔案的路徑物件" +"是不確定的。" #: ../../library/pathlib.rst:1065 msgid "" "Generate the file names in a directory tree by walking the tree either top-" "down or bottom-up." -msgstr "" +msgstr "透過由上而下或由下而上地走訪目錄樹產生目錄樹裡的檔案名稱。" #: ../../library/pathlib.rst:1068 msgid "" @@ -874,6 +942,8 @@ msgid "" "but excluding '.' and '..'), the method yields a 3-tuple of ``(dirpath, " "dirnames, filenames)``." msgstr "" +"對每個以 *self* 為根且在目錄樹裡的目錄(包含 *self* 但不包含 ‘.’ 和 ‘..’ )," +"此方法會 yield 一個 ``(dirpath, dirnames, filenames)`` 的三元素元組。" #: ../../library/pathlib.rst:1072 msgid "" @@ -884,6 +954,11 @@ msgid "" "begins with *self*) to a file or directory in *dirpath*, do ``dirpath / " "name``. Whether or not the lists are sorted is file system-dependent." msgstr "" +"*dirpath* 是一個目前走訪到的目錄的 :class:`Path`,*dirnames* 是一個 " +"*dirpath* 裡的子目錄名稱的字串串列(不包含 ``’.’`` 和 ``’..’`` ),而 " +"*filenames* 是一個 *dirpath* 裡非目錄檔案名稱的字串串列。要取得在 *dirpath* " +"裡檔案或目錄的完整路徑(以 *self* 開頭),可以使用 ``dirpath / name``。會根據" +"檔案系統來決定串列是否有排序。" #: ../../library/pathlib.rst:1080 msgid "" @@ -895,6 +970,11 @@ msgid "" "*top_down*, the list of subdirectories is retrieved before the triples for " "the directory and its subdirectories are walked." msgstr "" +"如果可選引數 *top_down* 是 true(預設值),一個目錄的三元素元組會在其任何子目" +"錄的三元素元組之前產生(目錄是由上而下走訪)。如果 *top_down* 是 false,一個" +"目錄的三元素元組會在其所有子目錄的三元素元組之後產生(目錄是由下而上走訪)。" +"不論 *top_down* 的值是什麼,子目錄的串列會在走訪該目錄及其子目錄的三元素元組" +"之前取得。" #: ../../library/pathlib.rst:1088 msgid "" @@ -908,6 +988,13 @@ msgid "" "of :meth:`Path.walk()` since the directories in *dirnames* have already been " "generated by the time *dirnames* is yielded to the caller." msgstr "" +"當 *top_down* 是 true,呼叫者可以原地 (in-place) 修改 *dirnames* 串列(例如使" +"用 :keyword:`del` 或切片賦值 (slice assignment)),且 :meth:`Path.walk` 只會" +"遞迴進名稱依然留在 *dirnames* 裡的子目錄。這可以用來修剪搜尋,或者強加特定順" +"序的訪問,或者甚至在繼續 :meth:`Path.walk` 之前,用來告訴 :meth:`Path.walk` " +"關於呼叫者建立或重新命名的目錄。當 *top_down* 是 false 的時候,修改 " +"*dirnames* 對 :meth:`Path.walk()` 的行為沒有影響,因為 *dirnames* 裡的目錄已" +"經在 *dirnames* yield 給呼叫者之前被產生。" #: ../../library/pathlib.rst:1098 msgid "" @@ -917,6 +1004,10 @@ msgid "" "error to continue the walk or re-raise it to stop the walk. Note that the " "filename is available as the ``filename`` attribute of the exception object." msgstr "" +"預設來自 :func:`os.scandir` 的錯誤會被忽略。如果指定了可選引數 *on_error*\\ " +"(它應該要是一個可呼叫物件),它會被以一個 :exc:`OSError` 實例為引數來呼叫。" +"這個可呼叫物件可以處理錯誤以繼續走訪,或者再次引發錯誤來停止走訪。注意,檔案" +"名稱可以從例外物件的 ``filename`` 屬性來取得。" #: ../../library/pathlib.rst:1104 msgid "" @@ -926,6 +1017,10 @@ msgid "" "their targets, and consequently visit directories pointed to by symlinks " "(where supported)." msgstr "" +"預設 :meth:`Path.walk` 不會跟隨符號連結,而是會把它們加到 *filenames* 串列。" +"將 *follow_symlinks* 設定為 true 會解析符號連結,並將它們根據其指向的目標放在" +"適當的 *dirnames* 和 *filenames*,而因此訪問到符號連結指向的目錄(在有支援符" +"號連結的地方)。" #: ../../library/pathlib.rst:1111 msgid "" @@ -933,6 +1028,8 @@ msgid "" "recursion if a link points to a parent directory of itself. :meth:`Path." "walk` does not keep track of the directories it has already visited." msgstr "" +"需要注意的是如果符號連結指向一個其本身的父目錄,則將 *follow_symlinks* 設定" +"為 true 會導致無窮的遞迴。:meth:`Path.walk` 不會紀錄其已經訪問過的目錄。" #: ../../library/pathlib.rst:1116 msgid "" @@ -942,18 +1039,26 @@ msgid "" "try to descend into it. To prevent such behavior, remove directories from " "*dirnames* as appropriate." msgstr "" +":meth:`Path.walk` 假設其走訪的目錄在執行過程中不會被修改。舉例來說,如果在 " +"*dirnames* 裡的目錄已經被一個符號連結取代,且 *follow_symlinks* 是 false,:" +"meth:`Path.walk` 依然會試著往下進入它。為了防止這樣的行為,可以從 *dirnames* " +"適當地移除目錄。" #: ../../library/pathlib.rst:1124 msgid "" "Unlike :func:`os.walk`, :meth:`Path.walk` lists symlinks to directories in " "*filenames* if *follow_symlinks* is false." msgstr "" +"如果 *follow_symlinks* 是 false,和 :func:`os.walk` 行為不同的是 :meth:`Path." +"walk` 會將指向目錄的符號連結放在 *filenames* 串列。" #: ../../library/pathlib.rst:1127 msgid "" "This example displays the number of bytes used by all files in each " "directory, while ignoring ``__pycache__`` directories::" msgstr "" +"這個範例會顯示在每個目錄裡所有檔案使用的位元組數量,同時間忽略 " +"``__pycache__`` 目錄: ::" #: ../../library/pathlib.rst:1143 msgid "" @@ -961,18 +1066,24 @@ msgid "" "Walking the tree bottom-up is essential as :func:`rmdir` doesn't allow " "deleting a directory before it is empty::" msgstr "" +"下一個範例是 :func:`shutil.rmtree` 的一個簡單的實作方式。由下而上走訪目錄樹是" +"必要的,因為 :func:`rmdir` 不允許在目錄為空之前刪除它: ::" #: ../../library/pathlib.rst:1160 msgid "" "Like :meth:`Path.chmod` but, if the path points to a symbolic link, the " "symbolic link's mode is changed rather than its target's." msgstr "" +"類似 :meth:`Path.chmod`,但如果該路徑指向一個符號連結,則符號連結的模式 " +"(mode) 會被改變而不是其指向的目標。" #: ../../library/pathlib.rst:1166 msgid "" "Like :meth:`Path.stat` but, if the path points to a symbolic link, return " "the symbolic link's information rather than its target's." msgstr "" +"類似 :meth:`Path.stat`,但如果該路徑指向一個符號連結,則回傳符號連結的資訊而" +"不是其指向的目標。" #: ../../library/pathlib.rst:1172 msgid "" @@ -980,6 +1091,9 @@ msgid "" "combined with the process' ``umask`` value to determine the file mode and " "access flags. If the path already exists, :exc:`FileExistsError` is raised." msgstr "" +"在給定路徑下建立一個新的目錄。如果有給 *mode* 則會結合行程 (process) 的 " +"``umask`` 值來決定檔案模式與存取旗標 (access flag)。如果路徑已經存在,會引" +"發 :exc:`FileExistsError`。" #: ../../library/pathlib.rst:1177 msgid "" @@ -987,18 +1101,24 @@ msgid "" "needed; they are created with the default permissions without taking *mode* " "into account (mimicking the POSIX ``mkdir -p`` command)." msgstr "" +"如果 *parents* 是 true,則任何缺少的父路徑都會依需要被建立;它們不考慮 " +"*mode* 而會以預設的權限來建立(模仿 POSIX 的 ``mkdir -p`` 指令)。" #: ../../library/pathlib.rst:1181 msgid "" "If *parents* is false (the default), a missing parent raises :exc:" "`FileNotFoundError`." msgstr "" +"如果 *parents* 是 false(預設值),缺少的父路徑會引發 :exc:" +"`FileNotFoundError`。" #: ../../library/pathlib.rst:1184 msgid "" "If *exist_ok* is false (the default), :exc:`FileExistsError` is raised if " "the target directory already exists." msgstr "" +"如果 *exist_ok* 是 false(預設值),則當目標目錄已經存在的話會引發 :exc:" +"`FileExistsError`。" #: ../../library/pathlib.rst:1187 msgid "" @@ -1006,8 +1126,8 @@ msgid "" "given path already exists in the file system and is not a directory (same " "behavior as the POSIX ``mkdir -p`` command)." msgstr "" -"如果 *exist_ok* 為 true,:exc:`FileExistsError` 例外不會被引發,除非給定路徑" -"已在檔案系統中存在且並不是個目錄(行為與 POSIX ``mkdir -p`` 指令相同)。" +"如果 *exist_ok* 是 true,只有當最後的路徑組成不是一個已存在的非目錄檔案,:" +"exc:`FileExistsError` 例外會被忽略(與 POSIX 的 ``mkdir -p`` 指令行為相同)。" #: ../../library/pathlib.rst:1191 msgid "The *exist_ok* parameter was added." @@ -1017,29 +1137,29 @@ msgstr "新增 *exist_ok* 參數。" msgid "" "Open the file pointed to by the path, like the built-in :func:`open` " "function does::" -msgstr "" +msgstr "開啟該路徑指向的檔案,像內建的 :func:`open` 函式做的一樣: ::" #: ../../library/pathlib.rst:1209 msgid "" "Return the name of the user owning the file. :exc:`KeyError` is raised if " "the file's uid isn't found in the system database." msgstr "" -"回傳擁有該檔案的用戶的名稱。如果在系統資料庫中找不到該檔案的 uid ,則會引發 :" +"回傳擁有該檔案的用戶名稱。如果在系統資料庫中找不到該檔案的 uid,則會引發 :" "exc:`KeyError`。" #: ../../library/pathlib.rst:1215 msgid "Return the binary contents of the pointed-to file as a bytes object::" -msgstr "將指向檔案的二進為內容以一個位元組 (bytes) 物件回傳: ::" +msgstr "將路徑指向的檔案的二進位內容以一個位元組物件回傳: ::" #: ../../library/pathlib.rst:1228 msgid "Return the decoded contents of the pointed-to file as a string::" -msgstr "將指向檔案的解碼內容以字串形式回傳: ::" +msgstr "將路徑指向的檔案的解碼內容以字串形式回傳: ::" #: ../../library/pathlib.rst:1236 msgid "" "The file is opened and then closed. The optional parameters have the same " "meaning as in :func:`open`." -msgstr "該檔案被打開並且隨後關閉。選填參數的含義與 :func:`open` 函數中的相同。" +msgstr "該檔案被打開並且隨後關閉。可選參數的含義與 :func:`open` 中的相同。" #: ../../library/pathlib.rst:1244 msgid "" @@ -1055,10 +1175,10 @@ msgid "" "*target* exists, :exc:`FileExistsError` will be raised. *target* can be " "either a string or another path object::" msgstr "" -"將此檔案或目錄重新命名為所提供的 *target* ,並回傳一個新的路徑 (Path) 物件指" -"向該 *target* 。在 Unix 系統上,若 *target* 存在且為一個檔案,若使用者有權" -"限,則會在不顯示訊息的情況下進行取代。在 Windows 系統上,若 *target* 存在,則" -"會引發 :exc:`FileExistsError` 錯誤。*target* 可以是字串或另一個路徑物件: ::" +"將此檔案或目錄重新命名為給定的 *target* ,並回傳一個新的路徑 (Path) 物件指向" +"該 *target* 。在 Unix 系統上,若 *target* 存在且為一個檔案,若使用者有權限," +"則會在不顯示訊息的情況下進行取代。在 Windows 系統上,若 *target* 存在,則會引" +"發 :exc:`FileExistsError` 錯誤。*target* 可以是字串或另一個路徑物件: ::" #: ../../library/pathlib.rst:1272 ../../library/pathlib.rst:1288 msgid "" @@ -1066,8 +1186,8 @@ msgid "" "relative to the current working directory, *not* the directory of the Path " "object." msgstr "" -"目標路徑可以是絕對路徑或相對路徑。相對路徑會相對於當前的工作目錄進行解釋," -"*not* 相對於路徑物件所在的目錄。" +"目標路徑可以是絕對路徑或相對路徑。相對路徑會相對於當前的工作目錄進行解釋,*而" +"不是*\\ 相對於路徑物件所在的目錄。" #: ../../library/pathlib.rst:1276 msgid "" @@ -1085,7 +1205,7 @@ msgid "" "instance pointing to *target*. If *target* points to an existing file or " "empty directory, it will be unconditionally replaced." msgstr "" -"將此檔案或目錄重新命名為給定的 *target* ,並回傳一個指向 *target* 的新路徑物" +"將此檔案或目錄重新命名為給定的 *target*,並回傳一個指向 *target* 的新路徑物" "件。如果 *target* 指向一個現有的檔案或空目錄,它將被無條件地取代。" #: ../../library/pathlib.rst:1298 @@ -1093,7 +1213,7 @@ msgid "" "Make the path absolute, without normalization or resolving symlinks. Returns " "a new path object::" msgstr "" -"使路徑成為絕對路徑,不進行標準化或解析符號連結。 回傳一個新的路徑物件: ::" +"將路徑轉換為絕對路徑,不進行標準化或解析符號連結。回傳一個新的路徑物件: ::" #: ../../library/pathlib.rst:1310 msgid "" @@ -1105,7 +1225,7 @@ msgstr "將路徑轉換為絕對路徑,解析所有符號連結。回傳一個 msgid "" "\"``..``\" components are also eliminated (this is the only method to do " "so)::" -msgstr "同時也會消除 \"``..``\" 的路徑組件(這是唯一的方法): ::" +msgstr "同時也會消除 \"``..``\" 的路徑組成(只有此方法這樣做): ::" #: ../../library/pathlib.rst:1325 msgid "" @@ -1115,10 +1235,9 @@ msgid "" "If an infinite loop is encountered along the resolution path, :exc:" "`RuntimeError` is raised." msgstr "" -"如果路徑不存在且 *strict* 為 ``True``, 則引發 :exc:`FileNotFoundError`。如" -"果 *strict* 為 ``False``, 則將盡可能解析該路徑,並將任何剩餘部分追加到路徑" -"中,而不檢查其是否存在。 如果在解析過程中遇到無窮迴圈,則引發 :exc:" -"`RuntimeError`。" +"如果路徑不存在且 *strict* 為 ``True``,則引發 :exc:`FileNotFoundError`。如果 " +"*strict* 為 ``False``,則將盡可能解析該路徑,並將任何剩餘部分追加到路徑中,而" +"不檢查其是否存在。如果在解析過程中遇到無窮迴圈,則引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:1331 msgid "The *strict* parameter was added (pre-3.6 behavior is strict)." @@ -1131,8 +1250,8 @@ msgid "" "*patterns* are the same as for :mod:`fnmatch`::" msgstr "" "遞迴地 glob 給定的相對 *pattern*。這相當於在給定的相對 *pattern* 前面加上 " -"\"``**/``\" 並呼叫 :func:`Path.glob`,其中 *patterns* 和 :mod:`fnmatch` 相" -"同: ::" +"\"``**/``\" 並呼叫 :func:`Path.glob`,其中 *patterns* 和給 :mod:`fnmatch` 的" +"相同: ::" #: ../../library/pathlib.rst:1352 msgid "" @@ -1183,7 +1302,7 @@ msgstr "引數的順序 (link, target) 和 :func:`os.symlink` 相反。" #: ../../library/pathlib.rst:1415 msgid "Make this path a hard link to the same file as *target*." -msgstr "使這個路徑為與 *target* 相同檔案的一個硬連結 (hard link)。" +msgstr "使這個路徑成為與 *target* 相同檔案的一個硬連結 (hard link)。" #: ../../library/pathlib.rst:1418 msgid "" @@ -1200,30 +1319,28 @@ msgid "" msgstr "" "根據給定路徑來建立一個檔案。如果 *mode* 有給定,它會與行程的 ``umask`` 值結" "合,以確定檔案模式和存取旗標。當檔案已經存在時,若 *exist_ok* 為 true 則函式" -"不會失敗(其變更時間會被更新為當下時間),否則 :exc:`FileExistsError` 會被引" -"發。" +"不會失敗(其變更時間會被更新為當下時間),否則會引發 :exc:`FileExistsError`。" #: ../../library/pathlib.rst:1435 msgid "" "Remove this file or symbolic link. If the path points to a directory, use :" "func:`Path.rmdir` instead." -msgstr "" -"移除這個檔案或符號連結。如果路徑指到資料夾,請改用 :func:`Path.rmdir`。" +msgstr "移除這個檔案或符號連結。如果路徑指向目錄,請改用 :func:`Path.rmdir`。" #: ../../library/pathlib.rst:1438 msgid "" "If *missing_ok* is false (the default), :exc:`FileNotFoundError` is raised " "if the path does not exist." msgstr "" -"如果 *missing_ok* 是 false(預設值), :exc:`FileNotFoundError` 會在路徑不存" -"在時被引發。" +"如果 *missing_ok* 是 false(預設值),:exc:`FileNotFoundError` 會在路徑不存在" +"時被引發。" #: ../../library/pathlib.rst:1441 msgid "" "If *missing_ok* is true, :exc:`FileNotFoundError` exceptions will be ignored " "(same behavior as the POSIX ``rm -f`` command)." msgstr "" -"如果 *missing_ok* 為 true,:exc:`FileNotFoundError` 例外會被忽略(行為與 " +"如果 *missing_ok* 是 true,:exc:`FileNotFoundError` 例外會被忽略(行為與 " "POSIX ``rm -f`` 指令相同)。" #: ../../library/pathlib.rst:1444 @@ -1234,7 +1351,7 @@ msgstr "新增 *missing_ok* 參數。" msgid "" "Open the file pointed to in bytes mode, write *data* to it, and close the " "file::" -msgstr "以位元組模式開啟指到的檔案,將 *data* 寫到檔案,並關閉檔案:: :" +msgstr "以位元組模式開啟指向的檔案,將 *data* 寫到檔案,並關閉檔案:: :" #: ../../library/pathlib.rst:1459 msgid "An existing file of the same name is overwritten." @@ -1244,15 +1361,14 @@ msgstr "一個名稱相同的已存在檔案會被覆寫。" msgid "" "Open the file pointed to in text mode, write *data* to it, and close the " "file::" -msgstr "以文字模式開啟指到的檔案,將 *data* 寫到檔案,並關閉檔案:: :" +msgstr "以文字模式開啟指向的檔案,將 *data* 寫到檔案,並關閉檔案:: :" #: ../../library/pathlib.rst:1475 msgid "" "An existing file of the same name is overwritten. The optional parameters " "have the same meaning as in :func:`open`." msgstr "" -"一個已經存在、名稱相同的檔案會被覆寫。可選參數和 :func:`open` 的參數有相同意" -"義。" +"一個名稱相同的已存在檔案會被覆寫。可選參數和 :func:`open` 的參數有相同意義。" #: ../../library/pathlib.rst:1480 msgid "The *newline* parameter was added." @@ -1260,13 +1376,15 @@ msgstr "新增 *newline* 參數。" #: ../../library/pathlib.rst:1484 msgid "Correspondence to tools in the :mod:`os` module" -msgstr "" +msgstr "與 :mod:`os` 模組裡的工具的對應關係" #: ../../library/pathlib.rst:1486 msgid "" "Below is a table mapping various :mod:`os` functions to their corresponding :" "class:`PurePath`/:class:`Path` equivalent." msgstr "" +"以下是一張表格,對應許多 :mod:`os` 函式及其相符於 :class:`PurePath`/:class:" +"`Path` 的項目。" #: ../../library/pathlib.rst:1491 msgid "" @@ -1275,6 +1393,9 @@ msgid "" "include :func:`os.path.abspath` and :meth:`Path.absolute`, :func:`os.path." "relpath` and :meth:`PurePath.relative_to`." msgstr "" +"不是以下所有一對的函式/方法都相等。其中有一些儘管有重疊的使用情境但有不同的語" +"意。它們包含 :func:`os.path.abspath` 和 :meth:`Path.absolute`、:func:`os." +"path.relpath` 和 :meth:`PurePath.relative_to`。" #: ../../library/pathlib.rst:1497 msgid ":mod:`os` and :mod:`os.path`" @@ -1513,12 +1634,16 @@ msgid "" ":func:`os.path.abspath` normalizes the resulting path, which may change its " "meaning in the presence of symlinks, while :meth:`Path.absolute` does not." msgstr "" +":func:`os.path.abspath` 會標準化產生的路徑,因而當有符號連結的時候會改變其意" +"義,但 :meth:`Path.absolute` 不會。" #: ../../library/pathlib.rst:1536 msgid "" ":meth:`PurePath.relative_to` requires ``self`` to be the subpath of the " "argument, but :func:`os.path.relpath` does not." msgstr "" +":meth:`PurePath.relative_to` 要求 ``self`` 是其引數的子路徑 (subpath),但 :" +"func:`os.path.relpath` 不用。" #: ../../library/pathlib.rst:12 msgid "path" From 36366fa2c3c4de68c093df6f95fc86c5143f7954 Mon Sep 17 00:00:00 2001 From: mindihx Date: Thu, 29 Feb 2024 20:52:06 +0800 Subject: [PATCH 2/2] Refine translation of library/pathlib --- library/pathlib.po | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/library/pathlib.po b/library/pathlib.po index 09ebf62c42..e828e8e4e4 100644 --- a/library/pathlib.po +++ b/library/pathlib.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-24 00:03+0000\n" -"PO-Revision-Date: 2024-01-07 10:44+0800\n" +"PO-Revision-Date: 2024-02-29 20:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -252,7 +252,7 @@ msgid "" msgstr "" "斜線運算子 (slash operator) 用於建立子路徑,就像是 :func:`os.path.join` 函式" "一樣。如果引數是絕對路徑,則忽略前一個路徑。在 Windows 系統上,當引數是具有根" -"目錄的相對路徑(例如,``r’\\foo’``),磁碟機部分不會被重置: ::" +"目錄的相對路徑(例如,``r'\\foo'``),磁碟機部分不會被重置: ::" #: ../../library/pathlib.rst:235 msgid "" @@ -760,8 +760,8 @@ msgid "" "which means \"this directory and all subdirectories, recursively\". In " "other words, it enables recursive globbing::" msgstr "" -"模式 (pattern) 和給 :mod:`fnmatch` 的一樣,加上 “``**``” 代表「目前目錄及所有" -"遞迴的子目錄」。也就是說它能夠做遞迴的 glob 比對: ::" +"模式 (pattern) 和給 :mod:`fnmatch` 的一樣,加上 \"``**``\" 代表「目前目錄及所" +"有遞迴的子目錄」。也就是說它能夠做遞迴的 glob 比對: ::" #: ../../library/pathlib.rst:926 msgid "" @@ -777,16 +777,16 @@ msgid "" "typically, case-sensitive on POSIX, and case-insensitive on Windows. Set " "*case_sensitive* to ``True`` or ``False`` to override this behaviour." msgstr "" -"預設情況下,或者當 *case_sensitive* 關鍵字參數被設定為 ``None`` 的時候,此方" -"法會使用平台特定的大小寫規則來比對路徑;通常在 POSIX 上會區分大小寫,而在 " -"Windows 上不區分大小寫。將 *case_sensitive* 設成 ``True`` 或 ``False`` 會覆寫" -"這個行為。" +"預設情況下,或者當 *case_sensitive* 僅限關鍵字引數被設定為 ``None`` 的時候," +"此方法會使用平台特定的大小寫規則來比對路徑;通常在 POSIX 上會區分大小寫,而" +"在 Windows 上不區分大小寫。將 *case_sensitive* 設成 ``True`` 或 ``False`` 會" +"覆寫這個行為。" #: ../../library/pathlib.rst:936 msgid "" "Using the \"``**``\" pattern in large directory trees may consume an " "inordinate amount of time." -msgstr "在很大的目錄樹裡使用 “``**``” 可能會耗費過多的時間。" +msgstr "在很大的目錄樹裡使用 \"``**``\" 可能會耗費過多的時間。" #: ../../library/pathlib.rst:939 msgid "" @@ -843,8 +843,8 @@ msgid "" "Return ``True`` if the path points to a junction, and ``False`` for any " "other type of file. Currently only Windows supports junctions." msgstr "" -"如果該路徑指向一個 junction 則回傳 ``True``,對其他類型的檔案則回傳 " -"``False``。目前只有 Windows 支援 junction。" +"如果該路徑指向一個連接點 (junction) 則回傳 ``True``,對其他類型的檔案則回傳 " +"``False``。目前只有 Windows 支援連接點。" #: ../../library/pathlib.rst:983 msgid "" @@ -926,8 +926,8 @@ msgid "" "directory after creating the iterator, whether a path object for that file " "be included is unspecified." msgstr "" -"子路徑會以任意順序被 yield,且不會包含特殊項目 ``’.’`` 和 ``’..’``。如果一個" -"檔案在建立這個迭代器之後加到該目錄或從目錄刪除,是否會包含這個檔案的路徑物件" +"子路徑會以任意順序被 yield,且不會包含特殊項目 ``'.'`` 和 ``'..'``。如果一個" +"檔案在建立這個疊代器之後加到該目錄或從目錄刪除,是否會包含這個檔案的路徑物件" "是不確定的。" #: ../../library/pathlib.rst:1065 @@ -942,7 +942,7 @@ msgid "" "but excluding '.' and '..'), the method yields a 3-tuple of ``(dirpath, " "dirnames, filenames)``." msgstr "" -"對每個以 *self* 為根且在目錄樹裡的目錄(包含 *self* 但不包含 ‘.’ 和 ‘..’ )," +"對每個以 *self* 為根且在目錄樹裡的目錄(包含 *self* 但不包含 '.' 和 '..' )," "此方法會 yield 一個 ``(dirpath, dirnames, filenames)`` 的三元素元組。" #: ../../library/pathlib.rst:1072 @@ -955,7 +955,7 @@ msgid "" "name``. Whether or not the lists are sorted is file system-dependent." msgstr "" "*dirpath* 是一個目前走訪到的目錄的 :class:`Path`,*dirnames* 是一個 " -"*dirpath* 裡的子目錄名稱的字串串列(不包含 ``’.’`` 和 ``’..’`` ),而 " +"*dirpath* 裡的子目錄名稱的字串串列(不包含 ``'.'`` 和 ``'..'`` ),而 " "*filenames* 是一個 *dirpath* 裡非目錄檔案名稱的字串串列。要取得在 *dirpath* " "裡檔案或目錄的完整路徑(以 *self* 開頭),可以使用 ``dirpath / name``。會根據" "檔案系統來決定串列是否有排序。" @@ -1294,6 +1294,10 @@ msgid "" "default) otherwise. On non-Windows platforms, *target_is_directory* is " "ignored." msgstr "" +"在 Windows 上,符號連結代表一個檔案或目錄,且不會隨著目標 (target) 動態改變。" +"如果目標存在,則符號連結的類型會被建立來符合其目標。否則如果 " +"*target_is_directory* 是 ``True``,該符號連結會被建立成目錄,如果不是則建立成" +"檔案(預設值)。在非 Windows 平台上,*target_is_directory* 會被忽略。" #: ../../library/pathlib.rst:1410 msgid ""