From 0c1d5d0202ee3808758edd9684b2ddd200006858 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 07:45:53 +0000 Subject: [PATCH 01/12] Initial plan From ff086acdf75859dd97a1b511b3701cb3824d7b39 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 07:53:53 +0000 Subject: [PATCH 02/12] Translate core struct module descriptions and functions Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/library/struct.po b/library/struct.po index 5cc4070b77..b352b980df 100644 --- a/library/struct.po +++ b/library/struct.po @@ -36,6 +36,10 @@ msgid "" "connections), or data transfer between the Python application and the C " "layer." msgstr "" +"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。\\" +"簡潔的\\ :ref:`格式字串 ` 描述了與 Python 數值之間預期的轉換。\\" +"此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換,\\" +"或是 Python 應用程式與 C 層之間的資料傳輸。" #: ../../library/struct.rst:29 msgid "" @@ -48,6 +52,10 @@ msgid "" "for defining byte ordering and padding between elements. See :ref:`struct-" "alignment` for details." msgstr "" +"當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來\\" +"打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;\\" +"同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義\\" +"位元組順序和元素之間的填充。詳情請參見\\ :ref:`struct-alignment`。" #: ../../library/struct.rst:39 msgid "" @@ -59,6 +67,11 @@ msgid "" "of bytes implement the buffer protocol, so that they can be read/filled " "without additional copying from a :class:`bytes` object." msgstr "" +"一些\\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。\\" +"這是指實作\\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的\\" +"型別是\\ :class:`bytes` 和\\ :class:`bytearray`,但許多其他可以視為位元組陣列的\\" +"型別都實作了緩衝區協議,因此它們可以從\\ :class:`bytes` 物件讀取或填入資料而無需\\" +"額外的複製。" #: ../../library/struct.rst:48 msgid "Functions and Exceptions" @@ -73,6 +86,7 @@ msgid "" "Exception raised on various occasions; argument is a string describing what " "is wrong." msgstr "" +"在各種情況下觸發的例外;引數是一個描述錯誤內容的字串。" #: ../../library/struct.rst:61 msgid "" @@ -80,6 +94,8 @@ msgid "" "to the format string *format*. The arguments must match the values required " "by the format exactly." msgstr "" +"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。\\" +"引數必須完全符合格式所需的數值。" #: ../../library/struct.rst:68 msgid "" @@ -87,6 +103,8 @@ msgid "" "write the packed bytes into the writable buffer *buffer* starting at " "position *offset*. Note that *offset* is a required argument." msgstr "" +"依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩衝區 " +"*buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。" #: ../../library/struct.rst:75 msgid "" @@ -95,6 +113,9 @@ msgid "" "contains exactly one item. The buffer's size in bytes must match the size " "required by the format, as reflected by :func:`calcsize`." msgstr "" +"根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)\\" +"解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的\\" +"大小,如\\ :func:`calcsize` 所示。" #: ../../library/struct.rst:83 msgid "" @@ -103,6 +124,9 @@ msgid "" "item. The buffer's size in bytes, starting at position *offset*, must be at " "least the size required by the format, as reflected by :func:`calcsize`." msgstr "" +"根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組,\\" +"即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到\\" +"格式所需的大小,如\\ :func:`calcsize` 所示。" #: ../../library/struct.rst:91 msgid "" @@ -112,20 +136,25 @@ msgid "" "buffer's size in bytes must be a multiple of the size required by the " "format, as reflected by :func:`calcsize`." msgstr "" +"根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器,\\" +"它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是\\" +"格式所需大小的倍數,如\\ :func:`calcsize` 所示。" #: ../../library/struct.rst:97 msgid "Each iteration yields a tuple as specified by the format string." -msgstr "" +msgstr "每次迭代都會產出由格式字串指定的元組。" #: ../../library/struct.rst:104 msgid "" "Return the size of the struct (and hence of the bytes object produced by " "``pack(format, ...)``) corresponding to the format string *format*." msgstr "" +"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)`` \\" +"所產生的 bytes 物件的大小)。" #: ../../library/struct.rst:111 msgid "Format Strings" -msgstr "" +msgstr "格式字串" #: ../../library/struct.rst:113 msgid "" @@ -137,10 +166,14 @@ msgid "" "which describes the overall properties of the data and one or more format " "characters which describe the actual data values and padding." msgstr "" +"格式字串描述了打包和解包資料時的資料配置。它們由\\ :ref:`格式字元` \\" +"組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\\ :ref:`位元組順序、\\" +"大小和對齊`。每個格式字串由一個可選的前綴字元組成,描述資料的\\" +"整體屬性,以及一個或多個描述實際資料值和填充的格式字元。" #: ../../library/struct.rst:125 msgid "Byte Order, Size, and Alignment" -msgstr "" +msgstr "位元組順序、大小和對齊" #: ../../library/struct.rst:127 msgid "" @@ -151,6 +184,9 @@ msgid "" "corresponding C struct. Whether to use native byte ordering and padding or " "standard formats depends on the application." msgstr "" +"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組\\" +"來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於\\" +"相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決於應用程式。" #: ../../library/struct.rst:143 msgid "" From bcbf796fb30eeddf867fe0e720eb323da90a417e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 07:58:55 +0000 Subject: [PATCH 03/12] Translate byte order, format characters tables and explanations Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 59 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/library/struct.po b/library/struct.po index b352b980df..a46be771c5 100644 --- a/library/struct.po +++ b/library/struct.po @@ -194,22 +194,24 @@ msgid "" "indicate the byte order, size and alignment of the packed data, according to " "the following table:" msgstr "" +"或者,格式字串的第一個字元可以用來指示打包資料的位元組順序、大小和對齊,\\" +"如下表所示:" #: ../../library/struct.rst:148 msgid "Character" -msgstr "" +msgstr "字元" #: ../../library/struct.rst:148 msgid "Byte order" -msgstr "" +msgstr "位元組順序" #: ../../library/struct.rst:148 msgid "Size" -msgstr "" +msgstr "大小" #: ../../library/struct.rst:148 msgid "Alignment" -msgstr "" +msgstr "對齊" #: ../../library/struct.rst:150 msgid "``@``" @@ -217,7 +219,7 @@ msgstr "``@``" #: ../../library/struct.rst:150 ../../library/struct.rst:152 msgid "native" -msgstr "" +msgstr "原生" #: ../../library/struct.rst:152 msgid "``=``" @@ -226,12 +228,12 @@ msgstr "``=``" #: ../../library/struct.rst:152 ../../library/struct.rst:154 #: ../../library/struct.rst:156 ../../library/struct.rst:158 msgid "standard" -msgstr "" +msgstr "標準" #: ../../library/struct.rst:152 ../../library/struct.rst:154 #: ../../library/struct.rst:156 ../../library/struct.rst:158 msgid "none" -msgstr "" +msgstr "無" #: ../../library/struct.rst:154 msgid "``<``" @@ -239,7 +241,7 @@ msgstr "``<``" #: ../../library/struct.rst:154 msgid "little-endian" -msgstr "" +msgstr "小端序" #: ../../library/struct.rst:156 msgid "``>``" @@ -247,7 +249,7 @@ msgstr "``>``" #: ../../library/struct.rst:156 msgid "big-endian" -msgstr "" +msgstr "大端序" #: ../../library/struct.rst:158 msgid "``!``" @@ -255,29 +257,30 @@ msgstr "``!``" #: ../../library/struct.rst:158 msgid "network (= big-endian)" -msgstr "" +msgstr "網路(= 大端序)" #: ../../library/struct.rst:161 msgid "If the first character is not one of these, ``'@'`` is assumed." -msgstr "" +msgstr "如果第一個字元不是這些字元之一,則假設為 ``'@'``。" #: ../../library/struct.rst:165 msgid "" "The number 1023 (``0x3ff`` in hexadecimal) has the following byte " "representations:" msgstr "" +"數字 1023(十六進位為 ``0x3ff``)具有以下位元組表示法:" #: ../../library/struct.rst:167 msgid "``03 ff`` in big-endian (``>``)" -msgstr "" +msgstr "大端序(``>``)為 ``03 ff``" #: ../../library/struct.rst:168 msgid "``ff 03`` in little-endian (``<``)" -msgstr "" +msgstr "小端序(``<``)為 ``ff 03``" #: ../../library/struct.rst:170 msgid "Python example:" -msgstr "" +msgstr "Python 範例:" #: ../../library/struct.rst:178 msgid "" @@ -286,36 +289,48 @@ msgid "" "endian; IBM z and many legacy architectures are big-endian. " "Use :data:`sys.byteorder` to check the endianness of your system." msgstr "" +"原生位元組順序是大端序或小端序,取決於主機系統。例如,Intel x86、AMD64 (x86-64) \\" +"和 Apple M1 是小端序;IBM z 和許多舊架構是大端序。使用\\ :data:`sys.byteorder` \\" +"來檢查您系統的位元組順序。" #: ../../library/struct.rst:183 msgid "" "Native size and alignment are determined using the C compiler's ``sizeof`` " "expression. This is always combined with native byte order." msgstr "" +"原生大小和對齊是使用 C 編譯器的 ``sizeof`` 表達式來決定的。這總是與原生位元組順序\\" +"結合使用。" #: ../../library/struct.rst:186 msgid "" "Standard size depends only on the format character; see the table in " "the :ref:`format-characters` section." msgstr "" +"標準大小僅取決於格式字元;請參見\\ :ref:`format-characters` 區段中的表格。" #: ../../library/struct.rst:189 msgid "" "Note the difference between ``'@'`` and ``'='``: both use native byte order, " "but the size and alignment of the latter is standardized." msgstr "" +"請注意 ``'@'`` 和 ``'='`` 之間的差異:兩者都使用原生位元組順序,但後者的大小和\\" +"對齊是標準化的。" #: ../../library/struct.rst:192 msgid "" "The form ``'!'`` represents the network byte order which is always big-" "endian as defined in `IETF RFC 1700 `_." msgstr "" +"``'!'`` 形式表示網路位元組順序,根據 `IETF RFC 1700 `_ 的定義,\\" +"它總是大端序。" #: ../../library/struct.rst:195 msgid "" "There is no way to indicate non-native byte order (force byte-swapping); use " "the appropriate choice of ``'<'`` or ``'>'``." msgstr "" +"沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 ``'>'`` \\" +"選擇。" #: ../../library/struct.rst:198 ../../library/struct.rst:277 msgid "Notes:" @@ -326,12 +341,14 @@ msgid "" "Padding is only automatically added between successive structure members. No " "padding is added at the beginning or the end of the encoded struct." msgstr "" +"填充只會在連續的結構成員之間自動加入。編碼結構的開頭或結尾不會加入填充。" #: ../../library/struct.rst:203 msgid "" "No padding is added when using non-native size and alignment, e.g. with '<', " "'>', '=', and '!'." msgstr "" +"使用非原生大小和對齊時,例如使用 '<'、'>'、'=' 和 '!' 時,不會加入填充。" #: ../../library/struct.rst:206 msgid "" @@ -339,10 +356,12 @@ msgid "" "type, end the format with the code for that type with a repeat count of " "zero. See :ref:`struct-examples`." msgstr "" +"要將結構的結尾對齊到特定型別的對齊需求,請以該型別的代碼結束格式,重複次數為零。\\" +"請參見\\ :ref:`struct-examples`。" #: ../../library/struct.rst:214 msgid "Format Characters" -msgstr "" +msgstr "格式字元" #: ../../library/struct.rst:216 msgid "" @@ -353,10 +372,14 @@ msgid "" "``'!'`` or ``'='``. When using native size, the size of the packed value is " "platform-dependent." msgstr "" +"格式字元具有以下意義;在給定型別的情況下,C 和 Python 數值之間的轉換應該是顯而\\" +"易見的。「標準大小」欄位指的是使用標準大小時打包數值的位元組大小;也就是說,\\" +"當格式字串以 ``'<'``、``'>'``、``'!'`` 或 ``'='`` 其中之一開始時。使用原生大小時,\\" +"打包數值的大小取決於平台。" #: ../../library/struct.rst:224 msgid "Format" -msgstr "" +msgstr "格式" #: ../../library/struct.rst:224 msgid "C Type" @@ -364,11 +387,11 @@ msgstr "C Type" #: ../../library/struct.rst:224 msgid "Python type" -msgstr "" +msgstr "Python 型別" #: ../../library/struct.rst:224 msgid "Standard size" -msgstr "" +msgstr "標準大小" #: ../../library/struct.rst:224 msgid "Notes" From bfd96c3334b04234e86155df3499b8e5502d54a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 08:02:32 +0000 Subject: [PATCH 04/12] Translate format character details and technical notes Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/library/struct.po b/library/struct.po index a46be771c5..ad49d87a47 100644 --- a/library/struct.po +++ b/library/struct.po @@ -403,11 +403,11 @@ msgstr "``x``" #: ../../library/struct.rst:226 msgid "pad byte" -msgstr "" +msgstr "填充位元組" #: ../../library/struct.rst:226 msgid "no value" -msgstr "" +msgstr "無值" #: ../../library/struct.rst:226 msgid "\\(7)" @@ -423,7 +423,7 @@ msgstr ":c:expr:`char`" #: ../../library/struct.rst:228 msgid "bytes of length 1" -msgstr "" +msgstr "長度為 1 的位元組" #: ../../library/struct.rst:228 ../../library/struct.rst:230 #: ../../library/struct.rst:232 ../../library/struct.rst:234 @@ -446,7 +446,7 @@ msgstr ":c:expr:`signed char`" #: ../../library/struct.rst:253 ../../library/struct.rst:255 #: ../../library/struct.rst:267 msgid "integer" -msgstr "" +msgstr "整數" #: ../../library/struct.rst:230 msgid "\\(1), \\(2)" @@ -628,7 +628,7 @@ msgstr ":c:expr:`char[]`" #: ../../library/struct.rst:263 ../../library/struct.rst:265 msgid "bytes" -msgstr "" +msgstr "位元組" #: ../../library/struct.rst:263 msgid "\\(9)" @@ -667,6 +667,8 @@ msgid "" "The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type defined " "by C standards since C99. In standard mode, it is represented by one byte." msgstr "" +"``'?'`` 轉換代碼對應於自 C99 以來 C 標準定義的\\ :c:expr:`_Bool` 型別。\\" +"在標準模式下,它由一個位元組表示。" #: ../../library/struct.rst:287 msgid "" @@ -674,6 +676,8 @@ msgid "" "codes, if the non-integer has a :meth:`~object.__index__` method then that " "method is called to convert the argument to an integer before packing." msgstr "" +"當嘗試使用任何整數轉換代碼打包非整數時,如果非整數具有\\ :meth:`~object.__index__` \\" +"方法,則會呼叫該方法在打包之前將引數轉換為整數。" #: ../../library/struct.rst:291 msgid "Added use of the :meth:`~object.__index__` method for non-integers." @@ -686,6 +690,8 @@ msgid "" "the standard size, you can use whichever of the other integer formats fits " "your application." msgstr "" +"``'n'`` 和 ``'N'`` 轉換代碼僅適用於原生大小(作為預設選擇或使用 ``'@'`` \\" +"位元組順序字元)。對於標準大小,您可以使用適合您應用程式的其他整數格式。" #: ../../library/struct.rst:301 msgid "" @@ -694,6 +700,9 @@ msgid "" "``'f'``, ``'d'`` or ``'e'`` respectively), regardless of the floating-point " "format used by the platform." msgstr "" +"對於 ``'f'``、``'d'`` 和 ``'e'`` 轉換代碼,打包表示法使用 IEEE 754 binary32、\\" +"binary64 或 binary16 格式(分別對應於 ``'f'``、``'d'`` 或 ``'e'``),無論平台\\" +"使用何種浮點數格式。" #: ../../library/struct.rst:307 msgid "" @@ -703,6 +712,9 @@ msgid "" "on the host system. The struct module does not interpret this as native " "ordering, so the ``'P'`` format is not available." msgstr "" +"``'P'`` 格式字元僅適用於原生位元組順序(作為預設選擇或使用 ``'@'`` 位元組順序字元)。\\" +"位元組順序字元 ``'='`` 根據主機系統選擇使用小端序或大端序。struct 模組不將其解釋為\\" +"原生順序,因此 ``'P'`` 格式不可用。" #: ../../library/struct.rst:314 msgid "" @@ -715,10 +727,16 @@ msgid "" "operations. See the Wikipedia page on the `half-precision floating-point " "format `_ for more information." msgstr "" +"IEEE 754 binary16「半精度」型別是在 2008 年的 `IEEE 754 標準 `_ \\" +"修訂版中引入的。它有一個符號位元、5 位元指數和 11 位元精度(明確儲存 10 位元),\\" +"可以全精度表示大約 ``6.1e-05`` 到 ``6.5e+04`` 之間的數字。此型別未被 C 編譯器\\" +"廣泛支援:在典型機器上,unsigned short 可以用於儲存,但不能用於數學運算。\\" +"請參見 Wikipedia 上的\\ `半精度浮點數格式 `_ 頁面以取得\\" +"更多資訊。" #: ../../library/struct.rst:324 msgid "When packing, ``'x'`` inserts one NUL byte." -msgstr "" +msgstr "打包時,``'x'`` 插入一個 NUL 位元組。" #: ../../library/struct.rst:327 msgid "" @@ -733,6 +751,12 @@ msgid "" "character consumes ``count`` bytes, but that the string returned can never " "contain more than 255 bytes." msgstr "" +"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長\\" +"字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組\\" +"在其後。如果傳遞給\\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前 \\" +"``count-1`` 個位元組。如果字串短於 ``count-1``,則用空位元組填充,使得總共使用\\" +"恰好 count 個位元組。請注意,對於\\ :func:`unpack`,``'p'`` 格式字元消耗 ``count`` \\" +"個位元組,但回傳的字串永遠不能包含超過 255 個位元組。" #: ../../library/struct.rst:339 msgid "" From 18f2cbc723ddc5a53279712bfeddf33b18a68ee5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 08:13:19 +0000 Subject: [PATCH 05/12] Complete struct.po translation - 100% translated! Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 96 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 17 deletions(-) diff --git a/library/struct.po b/library/struct.po index ad49d87a47..840777338f 100644 --- a/library/struct.po +++ b/library/struct.po @@ -754,9 +754,9 @@ msgstr "" "``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長\\" "字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組\\" "在其後。如果傳遞給\\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前 \\" -"``count-1`` 個位元組。如果字串短於 ``count-1``,則用空位元組填充,使得總共使用\\" -"恰好 count 個位元組。請注意,對於\\ :func:`unpack`,``'p'`` 格式字元消耗 ``count`` \\" -"個位元組,但回傳的字串永遠不能包含超過 255 個位元組。" +"``count-1`` 個位元組。如果字串短於 ``count-1``\ ,則用空位元組填充,使得總共使用\\" +"恰好 count 個位元組。請注意,對於\\ :func:`unpack`,\\ ``'p'`` 格式字元消耗 \\" +"``count`` 個位元組,但回傳的字串永遠不能包含超過 255 個位元組。" #: ../../library/struct.rst:339 msgid "" @@ -772,18 +772,28 @@ msgid "" "number of bytes. As a special case, ``'0s'`` means a single, empty string " "(while ``'0c'`` means 0 characters)." msgstr "" +"對於 ``'s'`` 格式字元,計數被解釋為位元組的長度,而不是像其他格式字元那樣的重複\\" +"次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字串,\\" +"而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如,\\ ``cccccccccc``\ ),對應於\\" +"十個不同的 Python 位元組物件。(請參見\\ :ref:`struct-examples` 以了解具體差異\\" +"的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填充字串\\" +"以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊情況,\\" +"``'0s'`` 表示單一空字串(而 ``'0c'`` 表示 0 個字元)。" #: ../../library/struct.rst:352 msgid "" "A format character may be preceded by an integral repeat count. For " "example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." msgstr "" +"格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'`` \\" +"意思完全相同。" #: ../../library/struct.rst:355 msgid "" "Whitespace characters between formats are ignored; a count and its format " "must not contain whitespace though." msgstr "" +"格式之間的空白字元會被忽略;但是計數和其格式不能包含空白字元。" #: ../../library/struct.rst:358 msgid "" @@ -792,12 +802,17 @@ msgid "" "``'Q'``), if ``x`` is outside the valid range for that format " "then :exc:`struct.error` is raised." msgstr "" +"當使用整數格式之一(``'b'``、``'B'``、``'h'``、``'H'``、``'i'``、``'I'``、\\" +"``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該\\" +"格式的有效範圍,則會觸發\\ :exc:`struct.error`。" #: ../../library/struct.rst:363 msgid "" "Previously, some of the integer formats wrapped out-of-range values and " "raised :exc:`DeprecationWarning` instead of :exc:`struct.error`." msgstr "" +"以前,一些整數格式會環繞超出範圍的數值並觸發\\ :exc:`DeprecationWarning` \\" +"而不是\\ :exc:`struct.error`。" #: ../../library/struct.rst:369 msgid "" @@ -806,6 +821,9 @@ msgid "" "used. Either 0 or 1 in the native or standard bool representation will be " "packed, and any non-zero value will be ``True`` when unpacking." msgstr "" +"對於 ``'?'`` 格式字元,回傳值是\\ :const:`True` 或\\ :const:`False`。打包時,\\" +"使用引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何\\" +"非零值都將為 ``True``。" #: ../../library/struct.rst:379 msgid "Examples" @@ -817,12 +835,15 @@ msgid "" "of any prefix character) may not match what the reader's machine produces as " "that depends on the platform and compiler." msgstr "" +"原生位元組順序範例(由 ``'@'`` 格式前綴或缺少任何前綴字元指定)可能與讀者機器\\" +"產生的結果不符,因為這取決於平台和編譯器。" #: ../../library/struct.rst:387 msgid "" "Pack and unpack integers of three different sizes, using big endian " "ordering::" msgstr "" +"使用大端序打包和解包三種不同大小的整數: ::" #: ../../library/struct.rst:390 msgid "" @@ -844,7 +865,7 @@ msgstr "" #: ../../library/struct.rst:398 msgid "Attempt to pack an integer which is too large for the defined field::" -msgstr "" +msgstr "嘗試打包對於定義欄位來說太大的整數: ::" #: ../../library/struct.rst:400 msgid "" @@ -861,7 +882,7 @@ msgstr "" #: ../../library/struct.rst:405 msgid "" "Demonstrate the difference between ``'s'`` and ``'c'`` format characters::" -msgstr "" +msgstr "示範 ``'s'`` 和 ``'c'`` 格式字元之間的差異: ::" #: ../../library/struct.rst:408 msgid "" @@ -880,6 +901,7 @@ msgid "" "Unpacked fields can be named by assigning them to variables or by wrapping " "the result in a named tuple::" msgstr "" +"解包的欄位可以透過將其指派給變數或將結果包裝在具名元組中來命名: ::" #: ../../library/struct.rst:416 msgid "" @@ -908,6 +930,10 @@ msgid "" "integer on a four-byte boundary. In this example, the output was produced on " "a little endian machine::" msgstr "" +"在原生模式下,格式字元的順序可能會影響大小,因為填充是隱式的。在標準模式下,\\" +"使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 ``'#'`` \\" +"之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例中,輸出是在\\" +"小端序機器上產生的: ::" #: ../../library/struct.rst:432 msgid "" @@ -934,6 +960,8 @@ msgid "" "The following format ``'llh0l'`` results in two pad bytes being added at the " "end, assuming the platform's longs are aligned on 4-byte boundaries::" msgstr "" +"假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個\\" +"填充位元組: ::" #: ../../library/struct.rst:444 msgid "" @@ -949,7 +977,7 @@ msgstr ":mod:`array` 模組" #: ../../library/struct.rst:451 msgid "Packed binary storage of homogeneous data." -msgstr "" +msgstr "同質資料的打包二進位儲存。" #: ../../library/struct.rst:453 msgid "Module :mod:`json`" @@ -957,7 +985,7 @@ msgstr ":mod:`json` 模組" #: ../../library/struct.rst:454 msgid "JSON encoder and decoder." -msgstr "" +msgstr "JSON 編碼器和解碼器。" #: ../../library/struct.rst:456 msgid "Module :mod:`pickle`" @@ -965,11 +993,11 @@ msgstr ":mod:`pickle` 模組" #: ../../library/struct.rst:457 msgid "Python object serialization." -msgstr "" +msgstr "Python 物件序列化。" #: ../../library/struct.rst:463 msgid "Applications" -msgstr "" +msgstr "應用" #: ../../library/struct.rst:465 msgid "" @@ -980,10 +1008,14 @@ msgid "" "layout (:ref:`standard formats`). Generally " "speaking, the format strings constructed for these two domains are distinct." msgstr "" +":mod:`struct` 模組有兩個主要應用:在應用程式內或使用相同編譯器編譯的另一個應用\\" +"程式之間進行 Python 和 C 程式碼的資料交換(\\ :ref:`原生格式`),\\" +"以及使用約定資料配置的應用程式之間的資料交換(\\ :ref:`標準格式`)。\\" +"一般來說,為這兩個領域構造的格式字串是不同的。" #: ../../library/struct.rst:476 msgid "Native Formats" -msgstr "" +msgstr "原生格式" #: ../../library/struct.rst:478 msgid "" @@ -995,11 +1027,15 @@ msgid "" "format string to round up to the correct byte boundary for proper alignment " "of consecutive chunks of data." msgstr "" +"當構造模擬原生配置的格式字串時,編譯器和機器架構決定位元組順序和填充。在這種\\" +"情況下,應該使用 ``@`` 格式字元來指定原生位元組順序和資料大小。內部填充位元組\\" +"通常會自動插入。可能需要在格式字串的結尾使用零重複格式代碼來向上舍入到正確的\\" +"位元組邊界,以便正確對齊連續的資料區塊。" #: ../../library/struct.rst:486 msgid "" "Consider these two simple examples (on a 64-bit, little-endian machine)::" -msgstr "" +msgstr "考慮這兩個簡單範例(在 64 位元小端序機器上): ::" #: ../../library/struct.rst:489 msgid "" @@ -1019,6 +1055,8 @@ msgid "" "string without the use of extra padding. A zero-repeat format code solves " "that problem::" msgstr "" +"在第二個格式字串的結尾,如果不使用額外填充,資料不會填充到 8 位元組邊界。\\" +"零重複格式代碼解決了這個問題: ::" #: ../../library/struct.rst:498 msgid "" @@ -1033,16 +1071,19 @@ msgid "" "The ``'x'`` format code can be used to specify the repeat, but for native " "formats it is better to use a zero-repeat format like ``'0l'``." msgstr "" +"``'x'`` 格式代碼可以用來指定重複,但對於原生格式,最好使用像 ``'0l'`` 這樣的\\" +"零重複格式。" #: ../../library/struct.rst:504 msgid "" "By default, native byte ordering and alignment is used, but it is better to " "be explicit and use the ``'@'`` prefix character." msgstr "" +"預設使用原生位元組順序和對齊,但最好明確使用 ``'@'`` 前綴字元。" #: ../../library/struct.rst:511 msgid "Standard Formats" -msgstr "" +msgstr "標準格式" #: ../../library/struct.rst:513 msgid "" @@ -1057,6 +1098,12 @@ msgid "" "must explicitly add ``'x'`` pad bytes where needed. Revisiting the examples " "from the previous section, we have::" msgstr "" +"當與您的程序之外的網路或儲存等交換資料時,要精確。指定確切的位元組順序、大小\\" +"和對齊。不要假設它們與特定機器的原生順序匹配。例如,網路位元組順序是大端序,\\" +"而許多流行的 CPU 是小端序。透過明確定義這一點,使用者無需關心其程式碼運行的\\" +"平台細節。第一個字元通常應該是 ``<`` 或 ``>``\ (或 ``!``\ )。填充是程式設計師\\" +"的責任。零重複格式字元不會起作用。相反,使用者必須在需要的地方明確加入 ``'x'`` \\" +"填充位元組。重新檢視上一節的範例,我們有: ::" #: ../../library/struct.rst:525 msgid "" @@ -1096,6 +1143,8 @@ msgid "" "when executed on different machines. For example, the examples below were " "executed on a 32-bit machine::" msgstr "" +"上述結果(在 64 位元機器上執行)在不同機器上執行時不保證匹配。例如,下面的\\" +"範例是在 32 位元機器上執行的: ::" #: ../../library/struct.rst:544 msgid "" @@ -1128,6 +1177,9 @@ msgid "" "its methods is more efficient than calling module-level functions with the " "same format since the format string is only compiled once." msgstr "" +"回傳一個新的 Struct 物件,它根據格式字串 *format* 寫入和讀取二進位資料。\\" +"建立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率,\\" +"因為格式字串只編譯一次。" #: ../../library/struct.rst:569 msgid "" @@ -1135,26 +1187,30 @@ msgid "" "level functions are cached, so programs that use only a few format strings " "needn't worry about reusing a single :class:`Struct` instance." msgstr "" +"傳遞給模組層級函式的最近格式字串的編譯版本會被快取,因此僅使用少數格式字串的\\" +"程式無需擔心重複使用單一\\ :class:`Struct` 實例。" #: ../../library/struct.rst:574 msgid "Compiled Struct objects support the following methods and attributes:" -msgstr "" +msgstr "編譯的 Struct 物件支援以下方法和屬性:" #: ../../library/struct.rst:578 msgid "" "Identical to the :func:`pack` function, using the compiled format. " "(``len(result)`` will equal :attr:`size`.)" msgstr "" +"與\\ :func:`pack` 函式相同,使用編譯的格式。(``len(result)`` 將等於\\ :attr:`size`。)" #: ../../library/struct.rst:584 msgid "Identical to the :func:`pack_into` function, using the compiled format." -msgstr "" +msgstr "與\\ :func:`pack_into` 函式相同,使用編譯的格式。" #: ../../library/struct.rst:589 msgid "" "Identical to the :func:`unpack` function, using the compiled format. The " "buffer's size in bytes must equal :attr:`size`." msgstr "" +"與\\ :func:`unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須等於\\ :attr:`size`。" #: ../../library/struct.rst:595 msgid "" @@ -1162,30 +1218,36 @@ msgid "" "The buffer's size in bytes, starting at position *offset*, must be at " "least :attr:`size`." msgstr "" +"與\\ :func:`unpack_from` 函式相同,使用編譯的格式。緩衝區從位置 *offset* \\" +"開始的位元組大小必須至少為\\ :attr:`size`。" #: ../../library/struct.rst:602 msgid "" "Identical to the :func:`iter_unpack` function, using the compiled format. " "The buffer's size in bytes must be a multiple of :attr:`size`." msgstr "" +"與\\ :func:`iter_unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須是\\ :attr:`size` \\" +"的倍數。" #: ../../library/struct.rst:609 msgid "The format string used to construct this Struct object." -msgstr "" +msgstr "用於構造此 Struct 物件的格式字串。" #: ../../library/struct.rst:611 msgid "The format string type is now :class:`str` instead of :class:`bytes`." -msgstr "" +msgstr "格式字串型別現在是\\ :class:`str` 而不是\\ :class:`bytes`。" #: ../../library/struct.rst:616 msgid "" "The calculated size of the struct (and hence of the bytes object produced by " "the :meth:`pack` method) corresponding to :attr:`format`." msgstr "" +"對應於\\ :attr:`format` 的結構的計算大小(因此也是\\ :meth:`pack` 方法所產生的\\" +"bytes 物件的大小)。" #: ../../library/struct.rst:619 msgid "The *repr()* of structs has changed. It is now:" -msgstr "" +msgstr "結構的 *repr()* 已經改變。現在是:" #: ../../library/struct.rst:13 msgid "C" From d848e1c14905e3ec95e92e6866ca51f2bd75b6bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 08:18:15 +0000 Subject: [PATCH 06/12] Remove unnecessary trailing backslashes from multi-line translation Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/struct.po b/library/struct.po index 840777338f..7bedba481b 100644 --- a/library/struct.po +++ b/library/struct.po @@ -36,9 +36,9 @@ msgid "" "connections), or data transfer between the Python application and the C " "layer." msgstr "" -"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。\\" -"簡潔的\\ :ref:`格式字串 ` 描述了與 Python 數值之間預期的轉換。\\" -"此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換,\\" +"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。" +"簡潔的\\ :ref:`格式字串 `\\ 描述了與 Python 數值之間預期的轉換。" +"此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換," "或是 Python 應用程式與 C 層之間的資料傳輸。" #: ../../library/struct.rst:29 From 168007aafcc60b81386c1e3b1375e457665e2276 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:47:39 +0000 Subject: [PATCH 07/12] Fix trailing backslashes in struct.po translations - Part 1 Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/library/struct.po b/library/struct.po index 7bedba481b..1f81497842 100644 --- a/library/struct.po +++ b/library/struct.po @@ -37,7 +37,7 @@ msgid "" "layer." msgstr "" "此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。" -"簡潔的\\ :ref:`格式字串 `\\ 描述了與 Python 數值之間預期的轉換。" +"簡潔的\ :ref:`格式字串 ` 描述了與 Python 數值之間預期的轉換。" "此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換," "或是 Python 應用程式與 C 層之間的資料傳輸。" @@ -52,10 +52,10 @@ msgid "" "for defining byte ordering and padding between elements. See :ref:`struct-" "alignment` for details." msgstr "" -"當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來\\" -"打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;\\" -"同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義\\" -"位元組順序和元素之間的填充。詳情請參見\\ :ref:`struct-alignment`。" +"當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來" +"打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;" +"同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義" +"位元組順序和元素之間的填充。詳情請參見\ :ref:`struct-alignment`。" #: ../../library/struct.rst:39 msgid "" @@ -67,10 +67,10 @@ msgid "" "of bytes implement the buffer protocol, so that they can be read/filled " "without additional copying from a :class:`bytes` object." msgstr "" -"一些\\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。\\" -"這是指實作\\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的\\" -"型別是\\ :class:`bytes` 和\\ :class:`bytearray`,但許多其他可以視為位元組陣列的\\" -"型別都實作了緩衝區協議,因此它們可以從\\ :class:`bytes` 物件讀取或填入資料而無需\\" +"一些\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。" +"這是指實作\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的" +"型別是\ :class:`bytes` 和\ :class:`bytearray`,但許多其他可以視為位元組陣列的" +"型別都實作了緩衝區協議,因此它們可以從\ :class:`bytes` 物件讀取或填入資料而無需" "額外的複製。" #: ../../library/struct.rst:48 @@ -94,7 +94,7 @@ msgid "" "to the format string *format*. The arguments must match the values required " "by the format exactly." msgstr "" -"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。\\" +"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。" "引數必須完全符合格式所需的數值。" #: ../../library/struct.rst:68 @@ -113,9 +113,9 @@ msgid "" "contains exactly one item. The buffer's size in bytes must match the size " "required by the format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)\\" -"解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的\\" -"大小,如\\ :func:`calcsize` 所示。" +"根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)" +"解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的" +"大小,如\ :func:`calcsize` 所示。" #: ../../library/struct.rst:83 msgid "" @@ -124,9 +124,9 @@ msgid "" "item. The buffer's size in bytes, starting at position *offset*, must be at " "least the size required by the format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組,\\" -"即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到\\" -"格式所需的大小,如\\ :func:`calcsize` 所示。" +"根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組," +"即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到" +"格式所需的大小,如\ :func:`calcsize` 所示。" #: ../../library/struct.rst:91 msgid "" @@ -136,9 +136,9 @@ msgid "" "buffer's size in bytes must be a multiple of the size required by the " "format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器,\\" -"它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是\\" -"格式所需大小的倍數,如\\ :func:`calcsize` 所示。" +"根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器," +"它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是" +"格式所需大小的倍數,如\ :func:`calcsize` 所示。" #: ../../library/struct.rst:97 msgid "Each iteration yields a tuple as specified by the format string." @@ -149,7 +149,7 @@ msgid "" "Return the size of the struct (and hence of the bytes object produced by " "``pack(format, ...)``) corresponding to the format string *format*." msgstr "" -"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)`` \\" +"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)``" "所產生的 bytes 物件的大小)。" #: ../../library/struct.rst:111 @@ -166,9 +166,9 @@ msgid "" "which describes the overall properties of the data and one or more format " "characters which describe the actual data values and padding." msgstr "" -"格式字串描述了打包和解包資料時的資料配置。它們由\\ :ref:`格式字元` \\" -"組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\\ :ref:`位元組順序、\\" -"大小和對齊`。每個格式字串由一個可選的前綴字元組成,描述資料的\\" +"格式字串描述了打包和解包資料時的資料配置。它們由\ :ref:`格式字元`" +"組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\ :ref:`位元組順序、" +"大小和對齊`。每個格式字串由一個可選的前綴字元組成,描述資料的" "整體屬性,以及一個或多個描述實際資料值和填充的格式字元。" #: ../../library/struct.rst:125 @@ -184,8 +184,8 @@ msgid "" "corresponding C struct. Whether to use native byte ordering and padding or " "standard formats depends on the application." msgstr "" -"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組\\" -"來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於\\" +"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組" +"來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於" "相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決於應用程式。" #: ../../library/struct.rst:143 From 2d1a1fbca460c8b53585637224fcd03b29e34862 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:49:56 +0000 Subject: [PATCH 08/12] Fix trailing backslashes in struct.po translations - Part 2 Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/struct.po b/library/struct.po index 1f81497842..b6fce86555 100644 --- a/library/struct.po +++ b/library/struct.po @@ -194,7 +194,7 @@ msgid "" "indicate the byte order, size and alignment of the packed data, according to " "the following table:" msgstr "" -"或者,格式字串的第一個字元可以用來指示打包資料的位元組順序、大小和對齊,\\" +"或者,格式字串的第一個字元可以用來指示打包資料的位元組順序、大小和對齊," "如下表所示:" #: ../../library/struct.rst:148 @@ -289,8 +289,8 @@ msgid "" "endian; IBM z and many legacy architectures are big-endian. " "Use :data:`sys.byteorder` to check the endianness of your system." msgstr "" -"原生位元組順序是大端序或小端序,取決於主機系統。例如,Intel x86、AMD64 (x86-64) \\" -"和 Apple M1 是小端序;IBM z 和許多舊架構是大端序。使用\\ :data:`sys.byteorder` \\" +"原生位元組順序是大端序或小端序,取決於主機系統。例如,Intel x86、AMD64 (x86-64)" +"和 Apple M1 是小端序;IBM z 和許多舊架構是大端序。使用\ :data:`sys.byteorder`" "來檢查您系統的位元組順序。" #: ../../library/struct.rst:183 @@ -298,7 +298,7 @@ msgid "" "Native size and alignment are determined using the C compiler's ``sizeof`` " "expression. This is always combined with native byte order." msgstr "" -"原生大小和對齊是使用 C 編譯器的 ``sizeof`` 表達式來決定的。這總是與原生位元組順序\\" +"原生大小和對齊是使用 C 編譯器的 ``sizeof`` 表達式來決定的。這總是與原生位元組順序" "結合使用。" #: ../../library/struct.rst:186 @@ -313,7 +313,7 @@ msgid "" "Note the difference between ``'@'`` and ``'='``: both use native byte order, " "but the size and alignment of the latter is standardized." msgstr "" -"請注意 ``'@'`` 和 ``'='`` 之間的差異:兩者都使用原生位元組順序,但後者的大小和\\" +"請注意 ``'@'`` 和 ``'='`` 之間的差異:兩者都使用原生位元組順序,但後者的大小和" "對齊是標準化的。" #: ../../library/struct.rst:192 @@ -321,7 +321,7 @@ msgid "" "The form ``'!'`` represents the network byte order which is always big-" "endian as defined in `IETF RFC 1700 `_." msgstr "" -"``'!'`` 形式表示網路位元組順序,根據 `IETF RFC 1700 `_ 的定義,\\" +"``'!'`` 形式表示網路位元組順序,根據 `IETF RFC 1700 `_ 的定義," "它總是大端序。" #: ../../library/struct.rst:195 @@ -329,7 +329,7 @@ msgid "" "There is no way to indicate non-native byte order (force byte-swapping); use " "the appropriate choice of ``'<'`` or ``'>'``." msgstr "" -"沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 ``'>'`` \\" +"沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 ``'>'``" "選擇。" #: ../../library/struct.rst:198 ../../library/struct.rst:277 @@ -356,8 +356,8 @@ msgid "" "type, end the format with the code for that type with a repeat count of " "zero. See :ref:`struct-examples`." msgstr "" -"要將結構的結尾對齊到特定型別的對齊需求,請以該型別的代碼結束格式,重複次數為零。\\" -"請參見\\ :ref:`struct-examples`。" +"要將結構的結尾對齊到特定型別的對齊需求,請以該型別的代碼結束格式,重複次數為零。" +"請參見\ :ref:`struct-examples`。" #: ../../library/struct.rst:214 msgid "Format Characters" @@ -372,9 +372,9 @@ msgid "" "``'!'`` or ``'='``. When using native size, the size of the packed value is " "platform-dependent." msgstr "" -"格式字元具有以下意義;在給定型別的情況下,C 和 Python 數值之間的轉換應該是顯而\\" -"易見的。「標準大小」欄位指的是使用標準大小時打包數值的位元組大小;也就是說,\\" -"當格式字串以 ``'<'``、``'>'``、``'!'`` 或 ``'='`` 其中之一開始時。使用原生大小時,\\" +"格式字元具有以下意義;在給定型別的情況下,C 和 Python 數值之間的轉換應該是顯而" +"易見的。「標準大小」欄位指的是使用標準大小時打包數值的位元組大小;也就是說," +"當格式字串以 ``'<'``、``'>'``、``'!'`` 或 ``'='`` 其中之一開始時。使用原生大小時," "打包數值的大小取決於平台。" #: ../../library/struct.rst:224 From a3207c26978d711b797ee5201e06cf80847fe39f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:52:57 +0000 Subject: [PATCH 09/12] Fix trailing backslashes in struct.po translations - Part 3 Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/library/struct.po b/library/struct.po index b6fce86555..00fdcb25de 100644 --- a/library/struct.po +++ b/library/struct.po @@ -667,7 +667,7 @@ msgid "" "The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type defined " "by C standards since C99. In standard mode, it is represented by one byte." msgstr "" -"``'?'`` 轉換代碼對應於自 C99 以來 C 標準定義的\\ :c:expr:`_Bool` 型別。\\" +"``'?'`` 轉換代碼對應於自 C99 以來 C 標準定義的\ :c:expr:`_Bool` 型別。" "在標準模式下,它由一個位元組表示。" #: ../../library/struct.rst:287 @@ -676,7 +676,7 @@ msgid "" "codes, if the non-integer has a :meth:`~object.__index__` method then that " "method is called to convert the argument to an integer before packing." msgstr "" -"當嘗試使用任何整數轉換代碼打包非整數時,如果非整數具有\\ :meth:`~object.__index__` \\" +"當嘗試使用任何整數轉換代碼打包非整數時,如果非整數具有\ :meth:`~object.__index__`" "方法,則會呼叫該方法在打包之前將引數轉換為整數。" #: ../../library/struct.rst:291 @@ -690,7 +690,7 @@ msgid "" "the standard size, you can use whichever of the other integer formats fits " "your application." msgstr "" -"``'n'`` 和 ``'N'`` 轉換代碼僅適用於原生大小(作為預設選擇或使用 ``'@'`` \\" +"``'n'`` 和 ``'N'`` 轉換代碼僅適用於原生大小(作為預設選擇或使用 ``'@'``" "位元組順序字元)。對於標準大小,您可以使用適合您應用程式的其他整數格式。" #: ../../library/struct.rst:301 @@ -700,8 +700,8 @@ msgid "" "``'f'``, ``'d'`` or ``'e'`` respectively), regardless of the floating-point " "format used by the platform." msgstr "" -"對於 ``'f'``、``'d'`` 和 ``'e'`` 轉換代碼,打包表示法使用 IEEE 754 binary32、\\" -"binary64 或 binary16 格式(分別對應於 ``'f'``、``'d'`` 或 ``'e'``),無論平台\\" +"對於 ``'f'``、``'d'`` 和 ``'e'`` 轉換代碼,打包表示法使用 IEEE 754 binary32、" +"binary64 或 binary16 格式(分別對應於 ``'f'``、``'d'`` 或 ``'e'``),無論平台" "使用何種浮點數格式。" #: ../../library/struct.rst:307 @@ -712,8 +712,8 @@ msgid "" "on the host system. The struct module does not interpret this as native " "ordering, so the ``'P'`` format is not available." msgstr "" -"``'P'`` 格式字元僅適用於原生位元組順序(作為預設選擇或使用 ``'@'`` 位元組順序字元)。\\" -"位元組順序字元 ``'='`` 根據主機系統選擇使用小端序或大端序。struct 模組不將其解釋為\\" +"``'P'`` 格式字元僅適用於原生位元組順序(作為預設選擇或使用 ``'@'`` 位元組順序字元)。" +"位元組順序字元 ``'='`` 根據主機系統選擇使用小端序或大端序。struct 模組不將其解釋為" "原生順序,因此 ``'P'`` 格式不可用。" #: ../../library/struct.rst:314 @@ -727,11 +727,11 @@ msgid "" "operations. See the Wikipedia page on the `half-precision floating-point " "format `_ for more information." msgstr "" -"IEEE 754 binary16「半精度」型別是在 2008 年的 `IEEE 754 標準 `_ \\" -"修訂版中引入的。它有一個符號位元、5 位元指數和 11 位元精度(明確儲存 10 位元),\\" -"可以全精度表示大約 ``6.1e-05`` 到 ``6.5e+04`` 之間的數字。此型別未被 C 編譯器\\" -"廣泛支援:在典型機器上,unsigned short 可以用於儲存,但不能用於數學運算。\\" -"請參見 Wikipedia 上的\\ `半精度浮點數格式 `_ 頁面以取得\\" +"IEEE 754 binary16「半精度」型別是在 2008 年的 `IEEE 754 標準 `_" +"修訂版中引入的。它有一個符號位元、5 位元指數和 11 位元精度(明確儲存 10 位元)," +"可以全精度表示大約 ``6.1e-05`` 到 ``6.5e+04`` 之間的數字。此型別未被 C 編譯器" +"廣泛支援:在典型機器上,unsigned short 可以用於儲存,但不能用於數學運算。" +"請參見 Wikipedia 上的\ `半精度浮點數格式 `_ 頁面以取得" "更多資訊。" #: ../../library/struct.rst:324 @@ -751,11 +751,11 @@ msgid "" "character consumes ``count`` bytes, but that the string returned can never " "contain more than 255 bytes." msgstr "" -"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長\\" -"字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組\\" -"在其後。如果傳遞給\\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前 \\" -"``count-1`` 個位元組。如果字串短於 ``count-1``\ ,則用空位元組填充,使得總共使用\\" -"恰好 count 個位元組。請注意,對於\\ :func:`unpack`,\\ ``'p'`` 格式字元消耗 \\" +"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長" +"字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組" +"在其後。如果傳遞給\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前" +"``count-1`` 個位元組。如果字串短於 ``count-1``,則用空位元組填充,使得總共使用" +"恰好 count 個位元組。請注意,對於\ :func:`unpack`,\ ``'p'`` 格式字元消耗" "``count`` 個位元組,但回傳的字串永遠不能包含超過 255 個位元組。" #: ../../library/struct.rst:339 @@ -772,12 +772,12 @@ msgid "" "number of bytes. As a special case, ``'0s'`` means a single, empty string " "(while ``'0c'`` means 0 characters)." msgstr "" -"對於 ``'s'`` 格式字元,計數被解釋為位元組的長度,而不是像其他格式字元那樣的重複\\" -"次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字串,\\" -"而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如,\\ ``cccccccccc``\ ),對應於\\" -"十個不同的 Python 位元組物件。(請參見\\ :ref:`struct-examples` 以了解具體差異\\" -"的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填充字串\\" -"以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊情況,\\" +"對於 ``'s'`` 格式字元,計數被解釋為位元組的長度,而不是像其他格式字元那樣的重複" +"次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字串," +"而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如,\ ``cccccccccc``),對應於" +"十個不同的 Python 位元組物件。(請參見\ :ref:`struct-examples` 以了解具體差異" +"的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填充字串" +"以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊情況," "``'0s'`` 表示單一空字串(而 ``'0c'`` 表示 0 個字元)。" #: ../../library/struct.rst:352 @@ -785,7 +785,7 @@ msgid "" "A format character may be preceded by an integral repeat count. For " "example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." msgstr "" -"格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'`` \\" +"格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'``" "意思完全相同。" #: ../../library/struct.rst:355 From 104f81c559220a51fbbfe59884a67b3d2c06d41f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:55:18 +0000 Subject: [PATCH 10/12] Fix trailing backslashes in struct.po translations - Part 4 Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/struct.po b/library/struct.po index 00fdcb25de..493257e89a 100644 --- a/library/struct.po +++ b/library/struct.po @@ -802,17 +802,17 @@ msgid "" "``'Q'``), if ``x`` is outside the valid range for that format " "then :exc:`struct.error` is raised." msgstr "" -"當使用整數格式之一(``'b'``、``'B'``、``'h'``、``'H'``、``'i'``、``'I'``、\\" -"``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該\\" -"格式的有效範圍,則會觸發\\ :exc:`struct.error`。" +"當使用整數格式之一(``'b'``、``'B'``、``'h'``、``'H'``、``'i'``、``'I'``、" +"``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該" +"格式的有效範圍,則會觸發\ :exc:`struct.error`。" #: ../../library/struct.rst:363 msgid "" "Previously, some of the integer formats wrapped out-of-range values and " "raised :exc:`DeprecationWarning` instead of :exc:`struct.error`." msgstr "" -"以前,一些整數格式會環繞超出範圍的數值並觸發\\ :exc:`DeprecationWarning` \\" -"而不是\\ :exc:`struct.error`。" +"以前,一些整數格式會環繞超出範圍的數值並觸發\ :exc:`DeprecationWarning`" +"而不是\ :exc:`struct.error`。" #: ../../library/struct.rst:369 msgid "" @@ -821,8 +821,8 @@ msgid "" "used. Either 0 or 1 in the native or standard bool representation will be " "packed, and any non-zero value will be ``True`` when unpacking." msgstr "" -"對於 ``'?'`` 格式字元,回傳值是\\ :const:`True` 或\\ :const:`False`。打包時,\\" -"使用引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何\\" +"對於 ``'?'`` 格式字元,回傳值是\ :const:`True` 或\ :const:`False`。打包時," +"使用引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何" "非零值都將為 ``True``。" #: ../../library/struct.rst:379 @@ -835,7 +835,7 @@ msgid "" "of any prefix character) may not match what the reader's machine produces as " "that depends on the platform and compiler." msgstr "" -"原生位元組順序範例(由 ``'@'`` 格式前綴或缺少任何前綴字元指定)可能與讀者機器\\" +"原生位元組順序範例(由 ``'@'`` 格式前綴或缺少任何前綴字元指定)可能與讀者機器" "產生的結果不符,因為這取決於平台和編譯器。" #: ../../library/struct.rst:387 @@ -930,9 +930,9 @@ msgid "" "integer on a four-byte boundary. In this example, the output was produced on " "a little endian machine::" msgstr "" -"在原生模式下,格式字元的順序可能會影響大小,因為填充是隱式的。在標準模式下,\\" -"使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 ``'#'`` \\" -"之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例中,輸出是在\\" +"在原生模式下,格式字元的順序可能會影響大小,因為填充是隱式的。在標準模式下," +"使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 ``'#'``" +"之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例中,輸出是在" "小端序機器上產生的: ::" #: ../../library/struct.rst:432 @@ -960,7 +960,7 @@ msgid "" "The following format ``'llh0l'`` results in two pad bytes being added at the " "end, assuming the platform's longs are aligned on 4-byte boundaries::" msgstr "" -"假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個\\" +"假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個" "填充位元組: ::" #: ../../library/struct.rst:444 From 69f56c384897baac97ca3a025e26e0e5ca5f1e0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:57:06 +0000 Subject: [PATCH 11/12] Complete removal of unnecessary trailing backslashes in struct.po Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- library/struct.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/struct.po b/library/struct.po index 493257e89a..8b78ca0a9e 100644 --- a/library/struct.po +++ b/library/struct.po @@ -1008,9 +1008,9 @@ msgid "" "layout (:ref:`standard formats`). Generally " "speaking, the format strings constructed for these two domains are distinct." msgstr "" -":mod:`struct` 模組有兩個主要應用:在應用程式內或使用相同編譯器編譯的另一個應用\\" -"程式之間進行 Python 和 C 程式碼的資料交換(\\ :ref:`原生格式`),\\" -"以及使用約定資料配置的應用程式之間的資料交換(\\ :ref:`標準格式`)。\\" +":mod:`struct` 模組有兩個主要應用:在應用程式內或使用相同編譯器編譯的另一個應用" +"程式之間進行 Python 和 C 程式碼的資料交換(\ :ref:`原生格式`)," +"以及使用約定資料配置的應用程式之間的資料交換(\ :ref:`標準格式`)。" "一般來說,為這兩個領域構造的格式字串是不同的。" #: ../../library/struct.rst:476 @@ -1177,8 +1177,8 @@ msgid "" "its methods is more efficient than calling module-level functions with the " "same format since the format string is only compiled once." msgstr "" -"回傳一個新的 Struct 物件,它根據格式字串 *format* 寫入和讀取二進位資料。\\" -"建立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率,\\" +"回傳一個新的 Struct 物件,它根據格式字串 *format* 寫入和讀取二進位資料。" +"建立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率," "因為格式字串只編譯一次。" #: ../../library/struct.rst:569 @@ -1187,8 +1187,8 @@ msgid "" "level functions are cached, so programs that use only a few format strings " "needn't worry about reusing a single :class:`Struct` instance." msgstr "" -"傳遞給模組層級函式的最近格式字串的編譯版本會被快取,因此僅使用少數格式字串的\\" -"程式無需擔心重複使用單一\\ :class:`Struct` 實例。" +"傳遞給模組層級函式的最近格式字串的編譯版本會被快取,因此僅使用少數格式字串的" +"程式無需擔心重複使用單一\ :class:`Struct` 實例。" #: ../../library/struct.rst:574 msgid "Compiled Struct objects support the following methods and attributes:" @@ -1218,15 +1218,15 @@ msgid "" "The buffer's size in bytes, starting at position *offset*, must be at " "least :attr:`size`." msgstr "" -"與\\ :func:`unpack_from` 函式相同,使用編譯的格式。緩衝區從位置 *offset* \\" -"開始的位元組大小必須至少為\\ :attr:`size`。" +"與\ :func:`unpack_from` 函式相同,使用編譯的格式。緩衝區從位置 *offset*" +"開始的位元組大小必須至少為\ :attr:`size`。" #: ../../library/struct.rst:602 msgid "" "Identical to the :func:`iter_unpack` function, using the compiled format. " "The buffer's size in bytes must be a multiple of :attr:`size`." msgstr "" -"與\\ :func:`iter_unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須是\\ :attr:`size` \\" +"與\ :func:`iter_unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須是\ :attr:`size`" "的倍數。" #: ../../library/struct.rst:609 From 08b13d0e0ced3b5eb0fd549330ad797768820183 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Mon, 14 Jul 2025 19:14:17 +0800 Subject: [PATCH 12/12] fix translation of `library/struct.po` --- library/struct.po | 303 +++++++++++++++++++------------------- tutorial/floatingpoint.po | 6 +- 2 files changed, 154 insertions(+), 155 deletions(-) diff --git a/library/struct.po b/library/struct.po index 8b78ca0a9e..b05f0e78c5 100644 --- a/library/struct.po +++ b/library/struct.po @@ -1,15 +1,15 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# Matt Wang , 2025 msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 16:11+0000\n" -"Last-Translator: Adrian Liaw \n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -24,7 +24,7 @@ msgstr ":mod:`!struct` --- 將位元組直譯為打包起來的二進位資料" #: ../../library/struct.rst:11 msgid "**Source code:** :source:`Lib/struct.py`" -msgstr "**原始碼:**\\ :source:`Lib/struct.py`" +msgstr "**原始碼:**:source:`Lib/struct.py`" #: ../../library/struct.rst:19 msgid "" @@ -36,10 +36,10 @@ msgid "" "connections), or data transfer between the Python application and the C " "layer." msgstr "" -"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉換。" -"簡潔的\ :ref:`格式字串 ` 描述了與 Python 數值之間預期的轉換。" -"此模組的函式和物件可用於兩種截然不同的應用:與外部來源(檔案或網路連線)的資料交換," -"或是 Python 應用程式與 C 層之間的資料傳輸。" +"此模組可在 Python 數值與以 Python :class:`bytes` 物件表示的 C 結構之間進行轉" +"換。簡潔的\\ :ref:`格式字串 `\\ 描述了與 Python 數值之" +"間預期的轉換。此模組的函式和物件可用於兩種截然不同的應用程式:與外部來源(檔" +"案或網路連線)的資料交換,或是 Python 應用程式與 C 層之間的資料傳輸。" #: ../../library/struct.rst:29 msgid "" @@ -52,10 +52,11 @@ msgid "" "for defining byte ordering and padding between elements. See :ref:`struct-" "alignment` for details." msgstr "" -"當未給定前綴字元時,原生模式為預設模式。它會根據建構 Python 直譯器的平台和編譯器來" -"打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正確對齊;" -"同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式設計師需負責定義" -"位元組順序和元素之間的填充。詳情請參見\ :ref:`struct-alignment`。" +"當未給定前綴字元時會預設為原生模式。它會根據建構 Python 直譯器的平台和編譯器" +"來打包或解包資料。打包給定 C 結構的結果包含填充位元組,以維持相關 C 型別的正" +"確對齊;同樣地,解包時也會考量對齊。相反地,當在外部來源之間傳輸資料時,程式" +"設計師需負責定義位元組順序和元素之間的填充。詳情請參見 :ref:`struct-" +"alignment`。" #: ../../library/struct.rst:39 msgid "" @@ -67,11 +68,11 @@ msgid "" "of bytes implement the buffer protocol, so that they can be read/filled " "without additional copying from a :class:`bytes` object." msgstr "" -"一些\ :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。" -"這是指實作\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此目的的" -"型別是\ :class:`bytes` 和\ :class:`bytearray`,但許多其他可以視為位元組陣列的" -"型別都實作了緩衝區協議,因此它們可以從\ :class:`bytes` 物件讀取或填入資料而無需" -"額外的複製。" +"一些 :mod:`struct` 函式(和 :class:`Struct` 的方法)接受一個 *buffer* 引數。" +"這是指實作\\ :ref:`bufferobjects` 並提供可讀或可讀寫緩衝區的物件。最常用於此" +"目的的型別是 :class:`bytes` 和 :class:`bytearray`,但許多其他可以視為位元組陣" +"列的型別都實作了緩衝區協定,因此它們可以從 :class:`bytes` 物件讀取或填入資料" +"而無需額外的複製。" #: ../../library/struct.rst:48 msgid "Functions and Exceptions" @@ -85,8 +86,7 @@ msgstr "此模組定義了以下例外和函式:" msgid "" "Exception raised on various occasions; argument is a string describing what " "is wrong." -msgstr "" -"在各種情況下觸發的例外;引數是一個描述錯誤內容的字串。" +msgstr "在各種情況下都可能觸發的例外;引數是一個描述錯誤內容的字串。" #: ../../library/struct.rst:61 msgid "" @@ -94,8 +94,8 @@ msgid "" "to the format string *format*. The arguments must match the values required " "by the format exactly." msgstr "" -"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的 bytes 物件。" -"引數必須完全符合格式所需的數值。" +"回傳一個包含依照格式字串 *format* 打包的數值 *v1*、*v2*、... 的位元組物件。引" +"數必須完全符合格式所需的數值。" #: ../../library/struct.rst:68 msgid "" @@ -103,8 +103,8 @@ msgid "" "write the packed bytes into the writable buffer *buffer* starting at " "position *offset*. Note that *offset* is a required argument." msgstr "" -"依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩衝區 " -"*buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。" +"依照格式字串 *format* 打包數值 *v1*、*v2*、...,並將打包後的位元組寫入可寫緩" +"衝區 *buffer* 中從位置 *offset* 開始的地方。請注意 *offset* 是必要的引數。" #: ../../library/struct.rst:75 msgid "" @@ -113,9 +113,9 @@ msgid "" "contains exactly one item. The buffer's size in bytes must match the size " "required by the format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 從緩衝區 *buffer*(推測是由 ``pack(format, ...)`` 打包的)" -"解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合格式所需的" -"大小,如\ :func:`calcsize` 所示。" +"根據格式字串 *format* 從緩衝區 *buffer*\\ (推測是由 ``pack(format, ...)`` 打" +"包的)解包。結果是一個元組,即使它只包含一個項目。緩衝區的位元組大小必須符合" +"格式所需的大小,如 :func:`calcsize` 所示。" #: ../../library/struct.rst:83 msgid "" @@ -124,9 +124,9 @@ msgid "" "item. The buffer's size in bytes, starting at position *offset*, must be at " "least the size required by the format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 從 *buffer* 的位置 *offset* 開始解包。結果是一個元組," -"即使它只包含一個項目。緩衝區從位置 *offset* 開始的位元組大小,必須至少達到" -"格式所需的大小,如\ :func:`calcsize` 所示。" +"根據格式字串 *format* 從 *buffer* 的 *offset* 位置開始解包。即使它只包含一個" +"項目,結果也都是一個元組。緩衝區從位置 *offset* 開始的位元組大小,必須至少達" +"到格式所需的大小,如 :func:`calcsize` 所示。" #: ../../library/struct.rst:91 msgid "" @@ -136,21 +136,21 @@ msgid "" "buffer's size in bytes must be a multiple of the size required by the " "format, as reflected by :func:`calcsize`." msgstr "" -"根據格式字串 *format* 迭代地從緩衝區 *buffer* 解包。此函式回傳一個迭代器," -"它會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是" -"格式所需大小的倍數,如\ :func:`calcsize` 所示。" +"根據格式字串 *format* 疊代地從緩衝區 *buffer* 解包。此函式回傳一個疊代器,它" +"會從緩衝區讀取等大小的區塊,直到消耗完所有內容。緩衝區的位元組大小必須是格式" +"所需大小的倍數,如 :func:`calcsize` 所示。" #: ../../library/struct.rst:97 msgid "Each iteration yields a tuple as specified by the format string." -msgstr "每次迭代都會產出由格式字串指定的元組。" +msgstr "每次疊代都會產生 (yield) 出一個由格式字串指定的元組。" #: ../../library/struct.rst:104 msgid "" "Return the size of the struct (and hence of the bytes object produced by " "``pack(format, ...)``) corresponding to the format string *format*." msgstr "" -"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)``" -"所產生的 bytes 物件的大小)。" +"回傳對應於格式字串 *format* 的結構大小(因此也是 ``pack(format, ...)`` 所產生" +"的位元組物件的大小)。" #: ../../library/struct.rst:111 msgid "Format Strings" @@ -166,10 +166,11 @@ msgid "" "which describes the overall properties of the data and one or more format " "characters which describe the actual data values and padding." msgstr "" -"格式字串描述了打包和解包資料時的資料配置。它們由\ :ref:`格式字元`" -"組成,這些字元指定了要打包或解包的資料型別。此外,特殊字元控制\ :ref:`位元組順序、" -"大小和對齊`。每個格式字串由一個可選的前綴字元組成,描述資料的" -"整體屬性,以及一個或多個描述實際資料值和填充的格式字元。" +"格式字串描述了打包和解包資料時的資料配置 (layout)。它們由\\ :ref:`格式字元 " +"`\\ 組成,這些字元指定了要打包或解包的資料型別。此外,特殊" +"字元控制\\ :ref:`位元組順序、大小和對齊 `。每個格式字串由一" +"個可選的前綴字元組成,描述資料的整體屬性,以及一個或多個描述實際資料值和填充" +"的格式字元。" #: ../../library/struct.rst:125 msgid "Byte Order, Size, and Alignment" @@ -184,9 +185,10 @@ msgid "" "corresponding C struct. Whether to use native byte ordering and padding or " "standard formats depends on the application." msgstr "" -"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位元組" -"來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完全對應於" -"相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決於應用程式。" +"預設情況下,C 型別以機器的原生格式和位元組順序表示,並在必要時透過跳過填充位" +"元組來正確對齊(根據 C 編譯器所使用的規則)。選擇此行為使得打包結構的位元組完" +"全對應於相對應 C 結構的記憶體配置。是否使用原生位元組順序和填充或標準格式取決" +"於應用程式。" #: ../../library/struct.rst:143 msgid "" @@ -194,8 +196,8 @@ msgid "" "indicate the byte order, size and alignment of the packed data, according to " "the following table:" msgstr "" -"或者,格式字串的第一個字元可以用來指示打包資料的位元組順序、大小和對齊," -"如下表所示:" +"或者,格式字串的第一個字元可以用來指示打包資料的位元組順序、大小和對齊,如下" +"表所示:" #: ../../library/struct.rst:148 msgid "Character" @@ -267,8 +269,7 @@ msgstr "如果第一個字元不是這些字元之一,則假設為 ``'@'``。" msgid "" "The number 1023 (``0x3ff`` in hexadecimal) has the following byte " "representations:" -msgstr "" -"數字 1023(十六進位為 ``0x3ff``)具有以下位元組表示法:" +msgstr "數字 1023(十六進位為 ``0x3ff``)具有以下位元組表示法:" #: ../../library/struct.rst:167 msgid "``03 ff`` in big-endian (``>``)" @@ -289,48 +290,48 @@ msgid "" "endian; IBM z and many legacy architectures are big-endian. " "Use :data:`sys.byteorder` to check the endianness of your system." msgstr "" -"原生位元組順序是大端序或小端序,取決於主機系統。例如,Intel x86、AMD64 (x86-64)" -"和 Apple M1 是小端序;IBM z 和許多舊架構是大端序。使用\ :data:`sys.byteorder`" -"來檢查您系統的位元組順序。" +"原生位元組順序是大端序或小端序,會取決於主機系統。例如,Intel x86、AMD64 " +"(x86-64)和 Apple M1 是小端序;IBM z 和許多舊架構是大端序。可使" +"用 :data:`sys.byteorder` 來檢查你系統的位元組順序。" #: ../../library/struct.rst:183 msgid "" "Native size and alignment are determined using the C compiler's ``sizeof`` " "expression. This is always combined with native byte order." msgstr "" -"原生大小和對齊是使用 C 編譯器的 ``sizeof`` 表達式來決定的。這總是與原生位元組順序" -"結合使用。" +"原生大小和對齊是使用 C 編譯器的 ``sizeof`` 運算式來決定的。這總是與原生位元組" +"順序結合使用。" #: ../../library/struct.rst:186 msgid "" "Standard size depends only on the format character; see the table in " "the :ref:`format-characters` section." msgstr "" -"標準大小僅取決於格式字元;請參見\\ :ref:`format-characters` 區段中的表格。" +"標準大小僅取決於格式字元;請參見\\ :ref:`format-characters`\\ 區塊中的表格。" #: ../../library/struct.rst:189 msgid "" "Note the difference between ``'@'`` and ``'='``: both use native byte order, " "but the size and alignment of the latter is standardized." msgstr "" -"請注意 ``'@'`` 和 ``'='`` 之間的差異:兩者都使用原生位元組順序,但後者的大小和" -"對齊是標準化的。" +"請注意 ``'@'`` 和 ``'='`` 之間的差異:兩者都使用原生位元組順序,但後者的大小" +"和對齊是標準化的。" #: ../../library/struct.rst:192 msgid "" "The form ``'!'`` represents the network byte order which is always big-" "endian as defined in `IETF RFC 1700 `_." msgstr "" -"``'!'`` 形式表示網路位元組順序,根據 `IETF RFC 1700 `_ 的定義," -"它總是大端序。" +"``'!'`` 形式表示網路位元組順序,根據 `IETF RFC 1700 `_ 的定" +"義,它總是大端序。" #: ../../library/struct.rst:195 msgid "" "There is no way to indicate non-native byte order (force byte-swapping); use " "the appropriate choice of ``'<'`` or ``'>'``." msgstr "" -"沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 ``'>'``" -"選擇。" +"沒有方法來指示非原生位元組順序(強制位元組交換);請使用適當的 ``'<'`` 或 " +"``'>'`` 選擇。" #: ../../library/struct.rst:198 ../../library/struct.rst:277 msgid "Notes:" @@ -356,8 +357,8 @@ msgid "" "type, end the format with the code for that type with a repeat count of " "zero. See :ref:`struct-examples`." msgstr "" -"要將結構的結尾對齊到特定型別的對齊需求,請以該型別的代碼結束格式,重複次數為零。" -"請參見\ :ref:`struct-examples`。" +"要將結構的結尾對齊到特定型別的對齊需求,請以該型別的碼結束格式,重複次數為" +"零。請參見\\ :ref:`struct-examples`。" #: ../../library/struct.rst:214 msgid "Format Characters" @@ -372,10 +373,10 @@ msgid "" "``'!'`` or ``'='``. When using native size, the size of the packed value is " "platform-dependent." msgstr "" -"格式字元具有以下意義;在給定型別的情況下,C 和 Python 數值之間的轉換應該是顯而" -"易見的。「標準大小」欄位指的是使用標準大小時打包數值的位元組大小;也就是說," -"當格式字串以 ``'<'``、``'>'``、``'!'`` 或 ``'='`` 其中之一開始時。使用原生大小時," -"打包數值的大小取決於平台。" +"格式字元具有以下意義;在給定型別的情況下,C 和 Python 數值之間的轉換應該是顯" +"而易見的。「標準大小」欄位指的是使用標準大小時(即當格式字串以 ``'<'``、" +"``'>'``、``'!'`` 或 ``'='`` 其中之一開始時)打包數值的位元組大小。使用原生大" +"小時,打包數值的大小取決於平台。" #: ../../library/struct.rst:224 msgid "Format" @@ -667,8 +668,8 @@ msgid "" "The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type defined " "by C standards since C99. In standard mode, it is represented by one byte." msgstr "" -"``'?'`` 轉換代碼對應於自 C99 以來 C 標準定義的\ :c:expr:`_Bool` 型別。" -"在標準模式下,它由一個位元組表示。" +"``'?'`` 轉換碼對應於自 C99 以來 C 標準定義的 :c:expr:`_Bool` 型別。在標準模式" +"下,它由一個位元組表示。" #: ../../library/struct.rst:287 msgid "" @@ -676,8 +677,8 @@ msgid "" "codes, if the non-integer has a :meth:`~object.__index__` method then that " "method is called to convert the argument to an integer before packing." msgstr "" -"當嘗試使用任何整數轉換代碼打包非整數時,如果非整數具有\ :meth:`~object.__index__`" -"方法,則會呼叫該方法在打包之前將引數轉換為整數。" +"當嘗試使用任何整數轉換碼打包非整數時,如果非整數具" +"有 :meth:`~object.__index__` 方法,則會呼叫該方法在打包之前將引數轉換為整數。" #: ../../library/struct.rst:291 msgid "Added use of the :meth:`~object.__index__` method for non-integers." @@ -690,8 +691,8 @@ msgid "" "the standard size, you can use whichever of the other integer formats fits " "your application." msgstr "" -"``'n'`` 和 ``'N'`` 轉換代碼僅適用於原生大小(作為預設選擇或使用 ``'@'``" -"位元組順序字元)。對於標準大小,您可以使用適合您應用程式的其他整數格式。" +"``'n'`` 和 ``'N'`` 轉換碼僅適用於原生大小(作為預設選擇或使用 ``'@'`` 位元組" +"順序字元)。對於標準大小,你可以使用適合你應用程式的其他整數格式。" #: ../../library/struct.rst:301 msgid "" @@ -700,7 +701,7 @@ msgid "" "``'f'``, ``'d'`` or ``'e'`` respectively), regardless of the floating-point " "format used by the platform." msgstr "" -"對於 ``'f'``、``'d'`` 和 ``'e'`` 轉換代碼,打包表示法使用 IEEE 754 binary32、" +"對於 ``'f'``、``'d'`` 和 ``'e'`` 轉換碼,打包表示法使用 IEEE 754 binary32、" "binary64 或 binary16 格式(分別對應於 ``'f'``、``'d'`` 或 ``'e'``),無論平台" "使用何種浮點數格式。" @@ -712,9 +713,9 @@ msgid "" "on the host system. The struct module does not interpret this as native " "ordering, so the ``'P'`` format is not available." msgstr "" -"``'P'`` 格式字元僅適用於原生位元組順序(作為預設選擇或使用 ``'@'`` 位元組順序字元)。" -"位元組順序字元 ``'='`` 根據主機系統選擇使用小端序或大端序。struct 模組不將其解釋為" -"原生順序,因此 ``'P'`` 格式不可用。" +"``'P'`` 格式字元僅適用於原生位元組順序(作為預設選擇或使用 ``'@'`` 位元組順序" +"字元)。位元組順序字元 ``'='`` 根據主機系統選擇使用小端序或大端序。struct 模" +"組不將其解釋為原生順序,因此 ``'P'`` 格式不可用。" #: ../../library/struct.rst:314 msgid "" @@ -727,12 +728,12 @@ msgid "" "operations. See the Wikipedia page on the `half-precision floating-point " "format `_ for more information." msgstr "" -"IEEE 754 binary16「半精度」型別是在 2008 年的 `IEEE 754 標準 `_" -"修訂版中引入的。它有一個符號位元、5 位元指數和 11 位元精度(明確儲存 10 位元)," -"可以全精度表示大約 ``6.1e-05`` 到 ``6.5e+04`` 之間的數字。此型別未被 C 編譯器" -"廣泛支援:在典型機器上,unsigned short 可以用於儲存,但不能用於數學運算。" -"請參見 Wikipedia 上的\ `半精度浮點數格式 `_ 頁面以取得" -"更多資訊。" +"IEEE 754 binary16「半精度 (half precision)」型別是在 2008 年的 `IEEE 754 標" +"準 `_\\ 修訂版中引入的。它有一個符號位元 (sign bit)、5 位" +"元指數和 11 位元精度(明確儲存 10 位元),可以全精度表示大約 ``6.1e-05`` 到 " +"``6.5e+04`` 之間的數字。此型別未被 C 編譯器廣泛支援:在典型機器上,unsigned " +"short 可以用於儲存但不能用於數學運算。請參見 Wikipedia 上的\\ `半精度浮點數格" +"式 `_\\ 頁面以取得更多資訊。" #: ../../library/struct.rst:324 msgid "When packing, ``'x'`` inserts one NUL byte." @@ -751,12 +752,13 @@ msgid "" "character consumes ``count`` bytes, but that the string returned can never " "contain more than 255 bytes." msgstr "" -"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在 *固定位元組數* 中的短變長" -"字串,由計數指定。儲存的第一個位元組是字串的長度,或 255,取較小者。字串的位元組" -"在其後。如果傳遞給\ :func:`pack` 的字串太長(長於計數減 1),則只儲存字串的前" -"``count-1`` 個位元組。如果字串短於 ``count-1``,則用空位元組填充,使得總共使用" -"恰好 count 個位元組。請注意,對於\ :func:`unpack`,\ ``'p'`` 格式字元消耗" -"``count`` 個位元組,但回傳的字串永遠不能包含超過 255 個位元組。" +"``'p'`` 格式字元編碼一個「Pascal 字串」,意思是儲存在\\ *固定位元組數*\\ 中的" +"短、長度可變字串,由計數指定。儲存的第一個位元組是字串的長度,或與 255 間取較" +"小者。字串的位元組在其後。如果傳遞給 :func:`pack` 的字串太長(長於計數減 " +"1),則只儲存字串的前 ``count-1`` 個位元組。如果字串短於 ``count-1``,則用空" +"位元組填充,使得總共使用恰好 count 個位元組。請注意,對於 :func:`unpack`, " +"``'p'`` 格式字元消耗 ``count`` 個位元組,但回傳的字串永遠不能包含超過 255 個" +"位元組。" #: ../../library/struct.rst:339 msgid "" @@ -772,28 +774,27 @@ msgid "" "number of bytes. As a special case, ``'0s'`` means a single, empty string " "(while ``'0c'`` means 0 characters)." msgstr "" -"對於 ``'s'`` 格式字元,計數被解釋為位元組的長度,而不是像其他格式字元那樣的重複" -"次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字串," -"而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如,\ ``cccccccccc``),對應於" -"十個不同的 Python 位元組物件。(請參見\ :ref:`struct-examples` 以了解具體差異" -"的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填充字串" -"以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊情況," -"``'0s'`` 表示單一空字串(而 ``'0c'`` 表示 0 個字元)。" +"對於 ``'s'`` 格式字元,計數被直譯為位元組的長度,而不是像其他格式字元那樣的重" +"複次數;例如,``'10s'`` 表示一個 10 位元組字串,對應於單一 Python 位元組字" +"串,而 ``'10c'`` 表示 10 個獨立的單位元組字元元素(例如 ``cccccccccc``),對" +"應於十個不同的 Python 位元組物件。(請參見 :ref:`struct-examples` 以了解具體" +"差異的示範。)如果未給定計數,則預設為 1。打包時,會適當地截斷或用空位元組填" +"充字串以使其適合。解包時,結果位元組物件總是恰好具有指定的位元組數。作為特殊" +"情況,``'0s'`` 表示單一空字串(而 ``'0c'`` 表示 0 個字元)。" #: ../../library/struct.rst:352 msgid "" "A format character may be preceded by an integral repeat count. For " "example, the format string ``'4h'`` means exactly the same as ``'hhhh'``." msgstr "" -"格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'``" -"意思完全相同。" +"格式字元前面可以加上整數重複次數。例如,格式字串 ``'4h'`` 與 ``'hhhh'`` 意思" +"完全相同。" #: ../../library/struct.rst:355 msgid "" "Whitespace characters between formats are ignored; a count and its format " "must not contain whitespace though." -msgstr "" -"格式之間的空白字元會被忽略;但是計數和其格式不能包含空白字元。" +msgstr "格式之間的空白字元會被忽略;但是計數和其格式不能包含空白字元。" #: ../../library/struct.rst:358 msgid "" @@ -803,16 +804,16 @@ msgid "" "then :exc:`struct.error` is raised." msgstr "" "當使用整數格式之一(``'b'``、``'B'``、``'h'``、``'H'``、``'i'``、``'I'``、" -"``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該" -"格式的有效範圍,則會觸發\ :exc:`struct.error`。" +"``'l'``、``'L'``、``'q'``、``'Q'``)打包數值 ``x`` 時,如果 ``x`` 超出該格式" +"的有效範圍,則會觸發 :exc:`struct.error`。" #: ../../library/struct.rst:363 msgid "" "Previously, some of the integer formats wrapped out-of-range values and " "raised :exc:`DeprecationWarning` instead of :exc:`struct.error`." msgstr "" -"以前,一些整數格式會環繞超出範圍的數值並觸發\ :exc:`DeprecationWarning`" -"而不是\ :exc:`struct.error`。" +"以前一些整數格式會環繞超出範圍的數值並引發 :exc:`DeprecationWarning` 而不" +"是 :exc:`struct.error`。" #: ../../library/struct.rst:369 msgid "" @@ -821,9 +822,9 @@ msgid "" "used. Either 0 or 1 in the native or standard bool representation will be " "packed, and any non-zero value will be ``True`` when unpacking." msgstr "" -"對於 ``'?'`` 格式字元,回傳值是\ :const:`True` 或\ :const:`False`。打包時," -"使用引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何" -"非零值都將為 ``True``。" +"對於 ``'?'`` 格式字元,回傳值是 :const:`True` 或 :const:`False`。打包時,使用" +"引數物件的真值。原生或標準布林值表示法中的 0 或 1 將被打包,解包時任何非零值" +"都將為 ``True``。" #: ../../library/struct.rst:379 msgid "Examples" @@ -842,8 +843,7 @@ msgstr "" msgid "" "Pack and unpack integers of three different sizes, using big endian " "ordering::" -msgstr "" -"使用大端序打包和解包三種不同大小的整數: ::" +msgstr "使用大端序打包和解包三種不同大小的整數: ::" #: ../../library/struct.rst:390 msgid "" @@ -900,8 +900,7 @@ msgstr "" msgid "" "Unpacked fields can be named by assigning them to variables or by wrapping " "the result in a named tuple::" -msgstr "" -"解包的欄位可以透過將其指派給變數或將結果包裝在具名元組中來命名: ::" +msgstr "解包的欄位可以透過將其指派給變數或將結果包裝在具名元組中來命名: ::" #: ../../library/struct.rst:416 msgid "" @@ -931,9 +930,9 @@ msgid "" "a little endian machine::" msgstr "" "在原生模式下,格式字元的順序可能會影響大小,因為填充是隱式的。在標準模式下," -"使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 ``'#'``" -"之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例中,輸出是在" -"小端序機器上產生的: ::" +"使用者負責插入任何所需的填充。請注意下面第一個 ``pack`` 呼叫中,在打包的 " +"``'#'`` 之後加入了三個 NUL 位元組,以將後續整數對齊到四位元組邊界。在此範例" +"中,輸出是在小端序機器上產生的: ::" #: ../../library/struct.rst:432 msgid "" @@ -960,8 +959,8 @@ msgid "" "The following format ``'llh0l'`` results in two pad bytes being added at the " "end, assuming the platform's longs are aligned on 4-byte boundaries::" msgstr "" -"假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個" -"填充位元組: ::" +"假設平台的 long 對齊到 4 位元組邊界,以下格式 ``'llh0l'`` 會在結尾加入兩個填" +"充位元組: ::" #: ../../library/struct.rst:444 msgid "" @@ -1008,10 +1007,11 @@ msgid "" "layout (:ref:`standard formats`). Generally " "speaking, the format strings constructed for these two domains are distinct." msgstr "" -":mod:`struct` 模組有兩個主要應用:在應用程式內或使用相同編譯器編譯的另一個應用" -"程式之間進行 Python 和 C 程式碼的資料交換(\ :ref:`原生格式`)," -"以及使用約定資料配置的應用程式之間的資料交換(\ :ref:`標準格式`)。" -"一般來說,為這兩個領域構造的格式字串是不同的。" +":mod:`struct` 模組有兩種主要應用程式:在應用程式內或使用相同編譯器編譯的另一" +"個應用程式之間進行 Python 和 C 程式碼的資料交換(:ref:`原生格式 `),以及使用約定資料配置的應用程式之間的資料交換(:ref:`標準" +"格式 `)。一般來說,為這兩個領域建構的格式字串是不同" +"的。" #: ../../library/struct.rst:476 msgid "Native Formats" @@ -1027,10 +1027,10 @@ msgid "" "format string to round up to the correct byte boundary for proper alignment " "of consecutive chunks of data." msgstr "" -"當構造模擬原生配置的格式字串時,編譯器和機器架構決定位元組順序和填充。在這種\\" -"情況下,應該使用 ``@`` 格式字元來指定原生位元組順序和資料大小。內部填充位元組\\" -"通常會自動插入。可能需要在格式字串的結尾使用零重複格式代碼來向上舍入到正確的\\" -"位元組邊界,以便正確對齊連續的資料區塊。" +"當構造模擬原生配置的格式字串時,編譯器和機器架構會決定位元組順序和填充。在這" +"種情況下,應該使用 ``@`` 格式字元來指定原生位元組順序和資料大小。內部填充位元" +"組通常會自動插入。可能需要在格式字串的結尾使用零重複格式碼來向上舍入到正確的" +"位元組邊界,以便正確對齊連續的資料區塊 (chunks)。" #: ../../library/struct.rst:486 msgid "" @@ -1055,8 +1055,8 @@ msgid "" "string without the use of extra padding. A zero-repeat format code solves " "that problem::" msgstr "" -"在第二個格式字串的結尾,如果不使用額外填充,資料不會填充到 8 位元組邊界。\\" -"零重複格式代碼解決了這個問題: ::" +"在第二個格式字串的結尾,如果不使用額外填充,資料不會填充到 8 位元組邊界。零重" +"複格式碼解決了這個問題: ::" #: ../../library/struct.rst:498 msgid "" @@ -1071,15 +1071,14 @@ msgid "" "The ``'x'`` format code can be used to specify the repeat, but for native " "formats it is better to use a zero-repeat format like ``'0l'``." msgstr "" -"``'x'`` 格式代碼可以用來指定重複,但對於原生格式,最好使用像 ``'0l'`` 這樣的\\" +"``'x'`` 格式碼可以用來指定重複,但對於原生格式來說最好使用像 ``'0l'`` 這樣的" "零重複格式。" #: ../../library/struct.rst:504 msgid "" "By default, native byte ordering and alignment is used, but it is better to " "be explicit and use the ``'@'`` prefix character." -msgstr "" -"預設使用原生位元組順序和對齊,但最好明確使用 ``'@'`` 前綴字元。" +msgstr "預設使用原生位元組順序和對齊,但最好明確使用 ``'@'`` 前綴字元。" #: ../../library/struct.rst:511 msgid "Standard Formats" @@ -1098,12 +1097,12 @@ msgid "" "must explicitly add ``'x'`` pad bytes where needed. Revisiting the examples " "from the previous section, we have::" msgstr "" -"當與您的程序之外的網路或儲存等交換資料時,要精確。指定確切的位元組順序、大小\\" -"和對齊。不要假設它們與特定機器的原生順序匹配。例如,網路位元組順序是大端序,\\" -"而許多流行的 CPU 是小端序。透過明確定義這一點,使用者無需關心其程式碼運行的\\" -"平台細節。第一個字元通常應該是 ``<`` 或 ``>``\ (或 ``!``\ )。填充是程式設計師\\" -"的責任。零重複格式字元不會起作用。相反,使用者必須在需要的地方明確加入 ``'x'`` \\" -"填充位元組。重新檢視上一節的範例,我們有: ::" +"當與你的行程之外的網路或儲存區等交換資料時,要夠精確。指定確切的位元組順序、" +"大小和對齊。不要假設它們與特定機器的原生順序匹配。例如,網路位元組順序是大端" +"序,而許多流行的 CPU 是小端序。透過明確定義這一點,使用者無需關心其程式碼運行" +"的平台細節。第一個字元通常應該是 ``<`` 或 ``>``\\ (或 ``!``)。填充是程式設" +"計師的責任。零重複格式字元不會起作用。取而代之的是使用者必須在需要的地方明確" +"加入 ``'x'`` 填充位元組。重新檢視上一節的範例,我們有: ::" #: ../../library/struct.rst:525 msgid "" @@ -1143,8 +1142,8 @@ msgid "" "when executed on different machines. For example, the examples below were " "executed on a 32-bit machine::" msgstr "" -"上述結果(在 64 位元機器上執行)在不同機器上執行時不保證匹配。例如,下面的\\" -"範例是在 32 位元機器上執行的: ::" +"上述結果(在 64 位元機器上執行)和在不同機器上執行時不保證會匹配。例如,下面" +"的範例是在 32 位元機器上執行的: ::" #: ../../library/struct.rst:544 msgid "" @@ -1177,9 +1176,9 @@ msgid "" "its methods is more efficient than calling module-level functions with the " "same format since the format string is only compiled once." msgstr "" -"回傳一個新的 Struct 物件,它根據格式字串 *format* 寫入和讀取二進位資料。" -"建立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率," -"因為格式字串只編譯一次。" +"回傳一個新的 Struct 物件,它會根據格式字串 *format* 寫入和讀取二進位資料。建" +"立一次 ``Struct`` 物件並呼叫其方法比使用相同格式呼叫模組層級函式更有效率,因" +"為格式字串只編譯一次。" #: ../../library/struct.rst:569 msgid "" @@ -1187,30 +1186,32 @@ msgid "" "level functions are cached, so programs that use only a few format strings " "needn't worry about reusing a single :class:`Struct` instance." msgstr "" -"傳遞給模組層級函式的最近格式字串的編譯版本會被快取,因此僅使用少數格式字串的" -"程式無需擔心重複使用單一\ :class:`Struct` 實例。" +"傳遞給模組層級函式的最近一個格式字串的編譯版本會被快取起來,因此僅使用少數格" +"式字串的程式無需擔心重複使用單一 :class:`Struct` 實例。" #: ../../library/struct.rst:574 msgid "Compiled Struct objects support the following methods and attributes:" -msgstr "編譯的 Struct 物件支援以下方法和屬性:" +msgstr "編譯過的 Struct 物件支援以下方法和屬性:" #: ../../library/struct.rst:578 msgid "" "Identical to the :func:`pack` function, using the compiled format. " "(``len(result)`` will equal :attr:`size`.)" msgstr "" -"與\\ :func:`pack` 函式相同,使用編譯的格式。(``len(result)`` 將等於\\ :attr:`size`。)" +"與 :func:`pack` 函式相同,會使用編譯過的格式。(``len(result)`` 將等" +"於 :attr:`size`。)" #: ../../library/struct.rst:584 msgid "Identical to the :func:`pack_into` function, using the compiled format." -msgstr "與\\ :func:`pack_into` 函式相同,使用編譯的格式。" +msgstr "與 :func:`pack_into` 函式相同,會使用編譯過的格式。" #: ../../library/struct.rst:589 msgid "" "Identical to the :func:`unpack` function, using the compiled format. The " "buffer's size in bytes must equal :attr:`size`." msgstr "" -"與\\ :func:`unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須等於\\ :attr:`size`。" +"與 :func:`unpack` 函式相同,會使用編譯過的格式。緩衝區的位元組大小必須等" +"於 :attr:`size`。" #: ../../library/struct.rst:595 msgid "" @@ -1218,32 +1219,32 @@ msgid "" "The buffer's size in bytes, starting at position *offset*, must be at " "least :attr:`size`." msgstr "" -"與\ :func:`unpack_from` 函式相同,使用編譯的格式。緩衝區從位置 *offset*" -"開始的位元組大小必須至少為\ :attr:`size`。" +"與 :func:`unpack_from` 函式相同,會使用編譯過的格式。緩衝區從位置 *offset* 開" +"始的位元組大小必須至少為 :attr:`size`。" #: ../../library/struct.rst:602 msgid "" "Identical to the :func:`iter_unpack` function, using the compiled format. " "The buffer's size in bytes must be a multiple of :attr:`size`." msgstr "" -"與\ :func:`iter_unpack` 函式相同,使用編譯的格式。緩衝區的位元組大小必須是\ :attr:`size`" -"的倍數。" +"與 :func:`iter_unpack` 函式相同,會使用編譯過的格式。緩衝區的位元組大小必須" +"是 :attr:`size` 的倍數。" #: ../../library/struct.rst:609 msgid "The format string used to construct this Struct object." -msgstr "用於構造此 Struct 物件的格式字串。" +msgstr "用於建構此 Struct 物件的格式字串。" #: ../../library/struct.rst:611 msgid "The format string type is now :class:`str` instead of :class:`bytes`." -msgstr "格式字串型別現在是\\ :class:`str` 而不是\\ :class:`bytes`。" +msgstr "格式字串型別現在是 :class:`str` 而不是 :class:`bytes`。" #: ../../library/struct.rst:616 msgid "" "The calculated size of the struct (and hence of the bytes object produced by " "the :meth:`pack` method) corresponding to :attr:`format`." msgstr "" -"對應於\\ :attr:`format` 的結構的計算大小(因此也是\\ :meth:`pack` 方法所產生的\\" -"bytes 物件的大小)。" +"對應於 :attr:`format` 的結構之計算出的大小(因此也是 :meth:`pack` 方法所產生" +"的位元組物件的大小)。" #: ../../library/struct.rst:619 msgid "The *repr()* of structs has changed. It is now:" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 1492e25182..32a61b128d 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -510,11 +510,9 @@ msgstr "" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" -"... total += x # 在標準精度中進行多次捨入 " -"\n" +"... total += x # 在標準精度中進行多次捨入\n" "...\n" -">>> total # 直接相加沒有正確的數字 " -"\n" +">>> total # 直接相加沒有正確的數字\n" "-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260