Skip to content

Commit d48b8ca

Browse files
authoredMar 15, 2025
Merge pull request #1014 from mindihx/library/http.cookies
Translate library/http.cookies
2 parents 2851e68 + 43ad743 commit d48b8ca

File tree

1 file changed

+116
-19
lines changed

1 file changed

+116
-19
lines changed
 

‎library/http.cookies.po

+116-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: Python 3.13\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2024-12-14 00:14+0000\n"
10-
"PO-Revision-Date: 2016-11-19 00:31+0000\n"
10+
"PO-Revision-Date: 2024-12-24 18:49+0800\n"
1111
"Last-Translator: Liang-Bo Wang <me@liang2.tw>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
@@ -32,6 +32,9 @@ msgid ""
3232
"string-only cookies, and provides an abstraction for having any serializable "
3333
"data-type as cookie value."
3434
msgstr ""
35+
":mod:`http.cookies` 模組定義了 cookie 概念的抽象化的類別,cookie 是一種 HTTP "
36+
"狀態管理機制。它支援簡單的純字串 cookie,也提供了將任何可序列化的資料型別作"
37+
"為 cookie 值的抽象化。"
3538

3639
#: ../../library/http.cookies.rst:19
3740
msgid ""
@@ -42,30 +45,39 @@ msgid ""
4245
"comes to cookie handling. As a result, this module now uses parsing rules "
4346
"that are a bit less strict than they once were."
4447
msgstr ""
48+
"此模組原先嚴格遵循了 :rfc:`2109` 和 :rfc:`2068` 規範所描述的剖析規則。自從發"
49+
"現 MSIE 3.0x 並不遵循這些規範所描述的字元規則,許多當前的瀏覽器和伺服器也在處"
50+
"理 cookie 時放寬了剖析規則。因此,此模組現在使用的剖析規則比之前的更為寬鬆。"
4551

4652
#: ../../library/http.cookies.rst:26
4753
msgid ""
4854
"The character set, :data:`string.ascii_letters`, :data:`string.digits` and "
4955
"``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this "
5056
"module in a cookie name (as :attr:`~Morsel.key`)."
5157
msgstr ""
58+
"字元集 :data:`string.ascii_letters`、:data:`string.digits` 和 ``!#$%&'*+-."
59+
"^_`|~`` 表示此模組在 cookie 名稱 (:attr:`~Morsel.key`) 中允許的合法字元集合。"
5260

5361
#: ../../library/http.cookies.rst:30
5462
msgid "Allowed ':' as a valid cookie name character."
55-
msgstr ""
63+
msgstr "允許 ':' 作為有效的 cookie 名稱字元。"
5664

5765
#: ../../library/http.cookies.rst:36
5866
msgid ""
5967
"On encountering an invalid cookie, :exc:`CookieError` is raised, so if your "
6068
"cookie data comes from a browser you should always prepare for invalid data "
6169
"and catch :exc:`CookieError` on parsing."
6270
msgstr ""
71+
"當遇到無效的 cookie 時,會引發 :exc:`CookieError`,因此如果你的 cookie 資料來"
72+
"自瀏覽器,在剖析時你應該總是為無效資料作準備並捕捉 :exc:`CookieError`。"
6373

6474
#: ../../library/http.cookies.rst:43
6575
msgid ""
6676
"Exception failing because of :rfc:`2109` invalidity: incorrect attributes, "
6777
"incorrect :mailheader:`Set-Cookie` header, etc."
6878
msgstr ""
79+
"因為不符合 :rfc:`2109` 而引發的例外:不正確的屬性、不正確的 :mailheader:`Set-"
80+
"Cookie` 標頭等。"
6981

7082
#: ../../library/http.cookies.rst:49
7183
msgid ""
@@ -74,10 +86,12 @@ msgid ""
7486
"value, the value is first converted to a :class:`Morsel` containing the key "
7587
"and the value."
7688
msgstr ""
89+
"這個類別是一個類似字典的物件,其中的鍵是字串,而值則是 :class:`Morsel` 實例。"
90+
"請注意,當設定鍵的值時,值會先被轉換為一個包含該鍵和值的 :class:`Morsel`。"
7791

7892
#: ../../library/http.cookies.rst:53
7993
msgid "If *input* is given, it is passed to the :meth:`load` method."
80-
msgstr ""
94+
msgstr "如果有給定 *input*,它會被傳遞給 :meth:`load` 方法。"
8195

8296
#: ../../library/http.cookies.rst:58
8397
msgid ""
@@ -87,6 +101,10 @@ msgid ""
87101
"SimpleCookie` calls the builtin :func:`str` to convert the value to a "
88102
"string. Values received from HTTP are kept as strings."
89103
msgstr ""
104+
"這個類別繼承自 :class:`BaseCookie` 並覆寫了 :meth:`~BaseCookie.value_decode` "
105+
"和 :meth:`~BaseCookie.value_encode`。:class:`!SimpleCookie` 支援字串作為 "
106+
"cookie 值。當設定值時,:class:`!SimpleCookie` 會呼叫內建的 :func:`str` 來將值"
107+
"轉換為字串。從 HTTP 接收的值會保持為字串。"
90108

91109
#: ../../library/http.cookies.rst:66
92110
msgid "Module :mod:`http.cookiejar`"
@@ -97,14 +115,16 @@ msgid ""
97115
"HTTP cookie handling for web *clients*. The :mod:`http.cookiejar` and :mod:"
98116
"`http.cookies` modules do not depend on each other."
99117
msgstr ""
118+
"用於網路\\ *用戶端*\\ 的 HTTP cookie 處理。:mod:`http.cookiejar` 和 :mod:"
119+
"`http.cookies` 模組互不相依。"
100120

101121
#: ../../library/http.cookies.rst:70
102122
msgid ":rfc:`2109` - HTTP State Management Mechanism"
103-
msgstr ""
123+
msgstr ":rfc:`2109` - HTTP 狀態管理機制"
104124

105125
#: ../../library/http.cookies.rst:71
106126
msgid "This is the state management specification implemented by this module."
107-
msgstr ""
127+
msgstr "這是此模組實作的狀態管理規範。"
108128

109129
#: ../../library/http.cookies.rst:77
110130
msgid "Cookie Objects"
@@ -116,19 +136,26 @@ msgid ""
116136
"``real_value`` can be any type. This method does no decoding in :class:"
117137
"`BaseCookie` --- it exists so it can be overridden."
118138
msgstr ""
139+
"從字串表示回傳 ``(real_value, coded_value)`` 的元組。``real_value`` 可以是任"
140+
"何型別。此方法在 :class:`BaseCookie` 中不做解碼 --- 它存在以便可以被覆寫。"
119141

120142
#: ../../library/http.cookies.rst:89
121143
msgid ""
122144
"Return a tuple ``(real_value, coded_value)``. *val* can be any type, but "
123145
"``coded_value`` will always be converted to a string. This method does no "
124146
"encoding in :class:`BaseCookie` --- it exists so it can be overridden."
125147
msgstr ""
148+
"回傳一個元組 ``(real_value, coded_value)``。*val* 可以是任何型別,但 "
149+
"``coded_value`` 總是會被轉換為字串。此方法在 :class:`BaseCookie` 中不做編碼 "
150+
"--- 它存在以便可以被覆寫。"
126151

127152
#: ../../library/http.cookies.rst:94
128153
msgid ""
129154
"In general, it should be the case that :meth:`value_encode` and :meth:"
130155
"`value_decode` are inverses on the range of *value_decode*."
131156
msgstr ""
157+
"一般來說,:meth:`value_encode` 和 :meth:`value_decode` 應該在 *value_decode* "
158+
"的範圍內是互逆的 (inverse)。"
132159

133160
#: ../../library/http.cookies.rst:100
134161
msgid ""
@@ -137,24 +164,31 @@ msgid ""
137164
"method. *sep* is used to join the headers together, and is by default the "
138165
"combination ``'\\r\\n'`` (CRLF)."
139166
msgstr ""
167+
"回傳一個適合作為 HTTP 標頭來傳送的字串表示。*attrs* 和 *header* 會傳送給每"
168+
"個 :class:`Morsel` 的 :meth:`~Morsel.output` 方法。*sep* 用來連接標頭,預設"
169+
"為 ``'\\r\\n'`` (CRLF) 的組合。"
140170

141171
#: ../../library/http.cookies.rst:108
142172
msgid ""
143173
"Return an embeddable JavaScript snippet, which, if run on a browser which "
144174
"supports JavaScript, will act the same as if the HTTP headers was sent."
145175
msgstr ""
176+
"回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的"
177+
"行為會與 HTTP 標頭被傳送的情況相同。"
146178

147179
#: ../../library/http.cookies.rst:111 ../../library/http.cookies.rst:207
148180
#: ../../library/http.cookies.rst:215
149181
msgid "The meaning for *attrs* is the same as in :meth:`output`."
150-
msgstr ""
182+
msgstr "*attrs* 的意義與 :meth:`output` 裡的相同。"
151183

152184
#: ../../library/http.cookies.rst:116
153185
msgid ""
154186
"If *rawdata* is a string, parse it as an ``HTTP_COOKIE`` and add the values "
155187
"found there as :class:`Morsel`\\ s. If it is a dictionary, it is equivalent "
156188
"to::"
157189
msgstr ""
190+
"如果 *rawdata* 是字串,會將其作為 ``HTTP_COOKIE`` 剖析,並將在其中找到的值當"
191+
"作 :class:`Morsel` 新增。如果它是一個字典,則等同於: ::"
158192

159193
#: ../../library/http.cookies.rst:119
160194
msgid ""
@@ -170,67 +204,76 @@ msgstr "Morsel 物件"
170204

171205
#: ../../library/http.cookies.rst:131
172206
msgid "Abstract a key/value pair, which has some :rfc:`2109` attributes."
173-
msgstr ""
207+
msgstr "抽象化一個鍵 / 值對,它有一些 :rfc:`2109` 屬性。"
174208

175209
#: ../../library/http.cookies.rst:133
176210
msgid ""
177211
"Morsels are dictionary-like objects, whose set of keys is constant --- the "
178212
"valid :rfc:`2109` attributes, which are:"
179213
msgstr ""
214+
"Morsel 是一種類似字典的物件,其鍵的集合是固定的 --- 有效的 :rfc:`2109` 屬性,"
215+
"它們是:"
180216

181217
#: ../../library/http.cookies.rst:146
182218
msgid ""
183219
"The attribute :attr:`httponly` specifies that the cookie is only transferred "
184220
"in HTTP requests, and is not accessible through JavaScript. This is intended "
185221
"to mitigate some forms of cross-site scripting."
186222
msgstr ""
223+
"屬性 :attr:`httponly` 指定 cookie 僅在 HTTP 請求中傳輸,而不可通過 "
224+
"JavaScript 存取。這是為了減輕某些形式的跨網站腳本攻擊。"
187225

188226
#: ../../library/http.cookies.rst:150
189227
msgid ""
190228
"The attribute :attr:`samesite` specifies that the browser is not allowed to "
191229
"send the cookie along with cross-site requests. This helps to mitigate CSRF "
192230
"attacks. Valid values for this attribute are \"Strict\" and \"Lax\"."
193231
msgstr ""
232+
"屬性 :attr:`samesite` 指定瀏覽器不能將 cookie 與跨網站請求一起傳送。這有助於"
233+
"減輕 CSRF 攻擊。此屬性的有效值為 \"Strict\"\"Lax\"。"
194234

195235
#: ../../library/http.cookies.rst:154
196236
msgid "The keys are case-insensitive and their default value is ``''``."
197-
msgstr ""
237+
msgstr "鍵不區分大小寫,其預設值為 ``''``。"
198238

199239
#: ../../library/http.cookies.rst:156
200240
msgid ""
201241
":meth:`!__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into "
202242
"account."
203243
msgstr ""
244+
":meth:`!__eq__` 現在會考慮 :attr:`~Morsel.key` 和 :attr:`~Morsel.value`。"
204245

205246
#: ../../library/http.cookies.rst:160
206247
msgid ""
207248
"Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` and :attr:`~Morsel."
208249
"coded_value` are read-only. Use :meth:`~Morsel.set` for setting them."
209250
msgstr ""
251+
"屬性 :attr:`~Morsel.key`、:attr:`~Morsel.value` 和 :attr:`~Morsel."
252+
"coded_value` 是唯讀的。請使用 :meth:`~Morsel.set` 來設定它們。"
210253

211254
#: ../../library/http.cookies.rst:165
212255
msgid "Added support for the :attr:`samesite` attribute."
213-
msgstr "新增 :attr:`samesite` 屬性的支援"
256+
msgstr "新增對 :attr:`samesite` 屬性的支援"
214257

215258
#: ../../library/http.cookies.rst:171
216259
msgid "The value of the cookie."
217-
msgstr ""
260+
msgstr "cookie 的值。"
218261

219262
#: ../../library/http.cookies.rst:176
220263
msgid "The encoded value of the cookie --- this is what should be sent."
221-
msgstr ""
264+
msgstr "cookie 的編碼值 --- 這是應該被傳送的值。"
222265

223266
#: ../../library/http.cookies.rst:181
224267
msgid "The name of the cookie."
225-
msgstr ""
268+
msgstr "cookie 的名稱。"
226269

227270
#: ../../library/http.cookies.rst:186
228271
msgid "Set the *key*, *value* and *coded_value* attributes."
229-
msgstr ""
272+
msgstr "設定 *key*、*value* 和 *coded_value* 屬性。"
230273

231274
#: ../../library/http.cookies.rst:191
232275
msgid "Whether *K* is a member of the set of keys of a :class:`Morsel`."
233-
msgstr ""
276+
msgstr "*K* 是否為 :class:`Morsel` 的鍵集合中的成員。"
234277

235278
#: ../../library/http.cookies.rst:196
236279
msgid ""
@@ -239,43 +282,52 @@ msgid ""
239282
"given, in which case it should be a list of attributes to use. *header* is "
240283
"by default ``\"Set-Cookie:\"``."
241284
msgstr ""
285+
"回傳適合作為 HTTP 標頭傳送的 Morsel 的字串表示。預設會包含所有屬性,除非有給"
286+
"定 *attrs*,在此情況下,它應該是一個要使用的屬性的串列。預設的 *header* 是 "
287+
"``\"Set-Cookie:\"``。"
242288

243289
#: ../../library/http.cookies.rst:204
244290
msgid ""
245291
"Return an embeddable JavaScript snippet, which, if run on a browser which "
246292
"supports JavaScript, will act the same as if the HTTP header was sent."
247293
msgstr ""
294+
"回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的"
295+
"行為會與 HTTP 標頭被傳送的情況相同。"
248296

249297
#: ../../library/http.cookies.rst:212
250298
msgid ""
251299
"Return a string representing the Morsel, without any surrounding HTTP or "
252300
"JavaScript."
253-
msgstr ""
301+
msgstr "回傳表示 Morsel 的字串,不包含周圍任何的 HTTP 或 JavaScript。"
254302

255303
#: ../../library/http.cookies.rst:220
256304
msgid ""
257305
"Update the values in the Morsel dictionary with the values in the dictionary "
258306
"*values*. Raise an error if any of the keys in the *values* dict is not a "
259307
"valid :rfc:`2109` attribute."
260308
msgstr ""
309+
"更新 Morsel 字典中的值為 *values* 字典中的值。如果 *values* 字典中的任何鍵不"
310+
"是有效的 :rfc:`2109` 屬性則引發錯誤。"
261311

262312
#: ../../library/http.cookies.rst:224
263313
msgid "an error is raised for invalid keys."
264-
msgstr ""
314+
msgstr "對於無效的鍵會引發錯誤。"
265315

266316
#: ../../library/http.cookies.rst:230
267317
msgid "Return a shallow copy of the Morsel object."
268-
msgstr ""
318+
msgstr "回傳 Morsel 物件的淺層複製。"
269319

270320
#: ../../library/http.cookies.rst:232
271321
msgid "return a Morsel object instead of a dict."
272-
msgstr ""
322+
msgstr "回傳 Morsel 物件而不是字典。"
273323

274324
#: ../../library/http.cookies.rst:238
275325
msgid ""
276326
"Raise an error if key is not a valid :rfc:`2109` attribute, otherwise behave "
277327
"the same as :meth:`dict.setdefault`."
278328
msgstr ""
329+
"如果鍵不是一個有效的 :rfc:`2109` 屬性會引發錯誤,否則行為與 :meth:`dict."
330+
"setdefault` 相同。"
279331

280332
#: ../../library/http.cookies.rst:245
281333
msgid "Example"
@@ -284,7 +336,7 @@ msgstr "範例"
284336
#: ../../library/http.cookies.rst:247
285337
msgid ""
286338
"The following example demonstrates how to use the :mod:`http.cookies` module."
287-
msgstr ""
339+
msgstr "以下範例示範如何使用 :mod:`http.cookies` 模組。"
288340

289341
#: ../../library/http.cookies.rst:249
290342
msgid ""
@@ -335,3 +387,48 @@ msgid ""
335387
"Set-Cookie: number=7\n"
336388
"Set-Cookie: string=seven"
337389
msgstr ""
390+
">>> from http import cookies\n"
391+
">>> C = cookies.SimpleCookie()\n"
392+
">>> C[\"fig\"] = \"newton\"\n"
393+
">>> C[\"sugar\"] = \"wafer\"\n"
394+
">>> print(C) # 產生 HTTP 標頭\n"
395+
"Set-Cookie: fig=newton\n"
396+
"Set-Cookie: sugar=wafer\n"
397+
">>> print(C.output()) # 同上\n"
398+
"Set-Cookie: fig=newton\n"
399+
"Set-Cookie: sugar=wafer\n"
400+
">>> C = cookies.SimpleCookie()\n"
401+
">>> C[\"rocky\"] = \"road\"\n"
402+
">>> C[\"rocky\"][\"path\"] = \"/cookie\"\n"
403+
">>> print(C.output(header=\"Cookie:\"))\n"
404+
"Cookie: rocky=road; Path=/cookie\n"
405+
">>> print(C.output(attrs=[], header=\"Cookie:\"))\n"
406+
"Cookie: rocky=road\n"
407+
">>> C = cookies.SimpleCookie()\n"
408+
">>> C.load(\"chips=ahoy; vienna=finger\") # 從字串(HTTP 標頭)載入\n"
409+
">>> print(C)\n"
410+
"Set-Cookie: chips=ahoy\n"
411+
"Set-Cookie: vienna=finger\n"
412+
">>> C = cookies.SimpleCookie()\n"
413+
">>> C.load('keebler=\"E=everybody; L=\\\\\"Loves\\\\\"; fudge=\\\\012;\";')\n"
414+
">>> print(C)\n"
415+
"Set-Cookie: keebler=\"E=everybody; L=\\\"Loves\\\"; fudge=\\012;\"\n"
416+
">>> C = cookies.SimpleCookie()\n"
417+
">>> C[\"oreo\"] = \"doublestuff\"\n"
418+
">>> C[\"oreo\"][\"path\"] = \"/\"\n"
419+
">>> print(C)\n"
420+
"Set-Cookie: oreo=doublestuff; Path=/\n"
421+
">>> C = cookies.SimpleCookie()\n"
422+
">>> C[\"twix\"] = \"none for you\"\n"
423+
">>> C[\"twix\"].value\n"
424+
"'none for you'\n"
425+
">>> C = cookies.SimpleCookie()\n"
426+
">>> C[\"number\"] = 7 # 等同於 C[\"number\"] = str(7)\n"
427+
">>> C[\"string\"] = \"seven\"\n"
428+
">>> C[\"number\"].value\n"
429+
"'7'\n"
430+
">>> C[\"string\"].value\n"
431+
"'seven'\n"
432+
">>> print(C)\n"
433+
"Set-Cookie: number=7\n"
434+
"Set-Cookie: string=seven"

0 commit comments

Comments
 (0)
Failed to load comments.