8000 docs(library/pickle.po): editing, up to line 212 · python/python-docs-zh-tw@e768ebe · GitHub
[go: up one dir, main page]

Skip to content

Commit e768ebe

Browse files
committed
docs(library/pickle.po): editing, up to line 212
1 parent ef59955 commit e768ebe

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

library/pickle.po

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This file is distributed under the same license as the Python package.
33
#
44
# Translators:
5+
# Skylull, 2024
56
msgid ""
67
msgstr ""
78
"Project-Id-Version: Python 3.12\n"
@@ -25,6 +26,14 @@ msgstr ":mod:`!pickle` --- Python 物件序列化"
2526
msgid "**Source code:** :source:`Lib/pickle.py`"
2627
msgstr "**原始碼:**\\ :source:`Lib/pickle.py`"
2728

29+
# Skylull: 我對 `pickle` 的命名原因進行了簡單的搜尋,只找到一則討論
30+
# https://stackoverflow.com/questions/27324986/pickles-why-are-they-called-
31+
# that
32+
# 其中表示這名字很可能只是為了隨便找一個p開頭的單字、或原始開發人員的內部玩笑造成的約定俗成。也有人表示醃製黃瓜(pickle-
33+
# ing)的目標就是保存和存放,所以取了這個名字。
34+
# 無論如何似乎沒有一個定論。
35+
# 因為不確定是否與醃漬的這個梗有關,我暫時選擇使用 `封裝` 與 `拆封` 作為譯文,大致保存那個把東西處裡後裝起來的感覺但又不至於太奇怪。
36+
# 唯一需要擔心的是是否有與 `encapsulation` (封裝,網路協定名詞)或 `package`(封包,網路協定名詞)搞混的可能。
2837
#: ../../library/pickle.rst:22
2938
msgid ""
3039
"The :mod:`pickle` module implements binary protocols for serializing and de-"
@@ -36,29 +45,40 @@ msgid ""
3645
"\"serialization\", \"marshalling,\" [#]_ or \"flattening\"; however, to "
3746
"avoid confusion, the terms used here are \"pickling\" and \"unpickling\"."
3847
msgstr ""
48+
":mod:`pickle` 模組實作的是一個在二進位層級上對 Python 物件進行序列化"
49+
"(serialize)或去序列化(de-serialize)。*\"Pickling\"* 用於專門指摘將一個 "
50+
"Python 物件轉換為一個二進位串流的過程,*\"unpickling\"* 則相反,指的是將一個"
51+
"(來自 :term:`binary file` 或 :term:`bytes-like object` 的)二進位串流轉換回 "
52+
"Python 物件的過程。Pickling(和 unpickling)的過程也可能被稱作 "
53+
"\"serialization\", \"marshalling,\" [#]_ 或 \"flattening\"。不過,為了避免混"
54+
"淆,本文件將統一稱作封裝(pickling)、拆封(unpickling)。"
3955

4056
#: ../../library/pickle.rst:33
4157
msgid "The ``pickle`` module **is not secure**. Only unpickle data you trust."
42-
msgstr ""
58+
msgstr "``pickle`` 模組**並不安全**,切記只拆封你信任的資料。"
4359

4460
#: ../../library/pickle.rst:35
4561
msgid ""
4662
"It is possible to construct malicious pickle data which will **execute "
4763
"arbitrary code during unpickling**. Never unpickle data that could have come "
4864
"from an untrusted source, or that could have been tampered with."
4965
msgstr ""
66+
"pickle 封包是有可能被建立來在拆封的時候**執行任意惡意程式碼**的。絕對不要拆封"
67+
"任何你無法信任其來源、或可能被修改過的 pickle 封包。"
5068

5169
#: ../../library/pickle.rst:39
5270
msgid ""
5371
"Consider signing data with :mod:`hmac` if you need to ensure that it has not "
5472
"been tampered with."
55-
msgstr ""
73+
msgstr "建議你可以使用 :mod:`hmac` 模組來簽署這個封包,以確保其未被修改過。"
5674

5775
#: ../../library/pickle.rst:42
5876
msgid ""
5977
"Safer serialization formats such as :mod:`json` may be more appropriate if "
6078
"you are processing untrusted data. See :ref:`comparison-with-json`."
6179
msgstr ""
80+
"如果你在處理不受信任的資料,其他比較安全的序列化格式(例如 :mod:`json`)可能"
81+
"會更適合。請參照 See :ref:`comparison-with-json` 的說明。"
6282

6383
#: ../../library/pickle.rst:47
6484
msgid "Relationship to other Python modules"
@@ -75,19 +95,24 @@ msgid ""
7595
"Python objects. :mod:`marshal` exists primarily to support Python's :file:`."
7696
"pyc` files."
7797
msgstr ""
98+
"Python 有另一個比較原始的序列化模組叫 :mod:`marshal`,不過其設計目的是為了支"
99+
"援 Python 的預編譯功能 :file:`.pyc` 運作。總地來說,沒事不要用 :mod:"
100+
"`marshal`。"
78101

79102
#: ../../library/pickle.rst:57
80103
msgid ""
81104
"The :mod:`pickle` module differs from :mod:`marshal` in several significant "
82105
"ways:"
83-
msgstr ""
106+
msgstr ":mod:`pickle` 和 :mod:`marshal` 有幾個明顯不同的地方:"
84107

85108
#: ../../library/pickle.rst:59
86109
msgid ""
87110
"The :mod:`pickle` module keeps track of the objects it has already "
88111
"serialized, so that later references to the same object won't be serialized "
89112
"again. :mod:`marshal` doesn't do this."
90113
msgstr ""
114+
":mod:`pickle` 會記住哪些物件已經被序列化過了,稍後再次參照到這個物件的時候才"
115+
"不會進行重複的序列化。:mod:`marshal` 沒有這個功能。"
91116

92117
#: ../../library/pickle.rst:63
93118
msgid ""
@@ -101,6 +126,11 @@ msgid ""
101126
"Shared objects remain shared, which can be very important for mutable "
102127
"objects."
103128
msgstr ""
129+
"這對遞迴物件和物件共用都有影響。遞迴物件是指包含自我參照的物件。這些情況在 "
130+
"marshal 模組中不會被處理,若嘗試使用 marshal 處理遞迴物件會導致 Python 直譯器"
131+
"崩潰。物件共用發生在序列化的物件階層中,不同位置對同一物件有多個參照時。:mod:"
132+
"`pickle` 只會儲存這個被參照的物件一次,並確保所有其他參照指向這個主要的版本。"
133+
"共用的物件會保持共用,這對於可變(mutable)物件來說非常重要。"
104134

105135
#: ../../library/pickle.rst:72
106136
msgid ""
@@ -109,6 +139,9 @@ msgid ""
109139
"transparently, however the class definition must be importable and live in "
110140
"the same module as when the object was stored."
111141
msgstr ""
142+
":mod:`marshal` 無法序列化使用者自訂的類別和的實例。:mod:`pickle` 則可以讓使用"
143+
"者儲存並還原自訂的類別實例,前提是儲存時該類別的定義存在於與要被儲存的物件所"
144+
"在的模組中、且可以被引入(import)。"
112145

113146
#: ../../library/pickle.rst:77
114147
msgid ""
@@ -122,6 +155,11 @@ msgid ""
122155
"differences if your data is crossing that unique breaking change language "
123156
"boundary."
124157
msgstr ""
158+
":mod:`marshal` 序列化格式無法保證能在不同版本的 Python 之間移植。因為其主要的"
159+
"作用是支援 :file:`.pyc` 檔案的運作,Python 的實作人員會在需要時實作無法前向相"
160+
"容的序列化方式。但只要選擇了相容的 pickle 協定,且處理了 Python 2 和 Python "
161+
"3 之間的資料類型差異,:mod:`pickle` 序列化協定能保證在不同 Python 版本間的相"
162+
"容性。"
125163

126164
#: ../../library/pickle.rst:90
127165
msgid "Comparison with ``json``"
@@ -132,24 +170,34 @@ msgid ""
132170
"There are fundamental differences between the pickle protocols and `JSON "
133171
"(JavaScript Object Notation) <https://json.org>`_:"
134172
msgstr ""
173+
"pickle 協定和 `JSON (JavaScript Object Notation) <https://json.org>`_ 有一些"
174+
"根本上的不同:"
135175

136176
#: ../../library/pickle.rst:95
137177
msgid ""
138178
"JSON is a text serialization format (it outputs unicode text, although most "
139179
"of the time it is then encoded to ``utf-8``), while pickle is a binary "
140180
"serialization format;"
141181
msgstr ""
182+
"JSON 以文字形式作為序列化的輸出(輸出 unicode 文字,但大多數又會被編碼為 "
183+
"``UTF-8``),而 pickle 則是以二進位形式作為序列化的輸出;"
142184

143185
#: ../../library/pickle.rst:99
144186
msgid "JSON is human-readable, while pickle is not;"
145-
msgstr "JSON 是人類可讀的,而 pickle 不是;"
187+
msgstr "JSON 是人類可讀的,而 pickle 則無法;"
146188

147189
#: ../../library/pickle.rst:101
148190
msgid ""
149191
"JSON is interoperable and widely used outside of the Python ecosystem, while "
150192
"pickle is Python-specific;"
151193
msgstr ""
194+
"JSON 具有高互通性(interoperability)且在 Python 以外的環境也被大量利用,但 "
195+
"pickle 只能在 Python 內使用。"
152196

197+
# Skylull: introspection, introspection facilities
198+
# https://zh.wikipedia.org/wiki/%E5%86%85%E7%9C%81_(%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6)
199+
# https://book.pythontips.com/en/latest/object_introspection.html
200+
# https://www.geeksforgeeks.org/code-introspection-in-python/
153201
#: ../../library/pickle.rst:104
154202
msgid ""
155203
"JSON, by default, can only represent a subset of the Python built-in types, "
@@ -158,6 +206,9 @@ msgid ""
158206
"introspection facilities; complex cases can be tackled by implementing :ref:"
159207
"`specific object APIs <pickle-inst>`);"
160208
msgstr ""
209+
"預設狀態下的 JSON 只能紀錄一小部份的 Python 內建型別,且無法紀錄自訂類別;但"
210+
"透過 Python 的自省功能,pickle 可以紀錄絕大多數的 Python 型別(其他比較複雜的"
211+
"狀況也可以透過實作 :ref:`specific object APIs <pickle-inst>` 來解決);"
161212

162213
#: ../../library/pickle.rst:110
163214
msgid ""

0 commit comments

Comments
 (0)
0