@@ -7,7 +7,7 @@ msgstr ""
7
7
"Project-Id-Version : Python 3.13\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
9
"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 "
11
11
"Last-Translator : Liang-Bo Wang <me@liang2.tw>\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -32,6 +32,9 @@ msgid ""
32
32
"string-only cookies, and provides an abstraction for having any serializable "
33
33
"data-type as cookie value."
34
34
msgstr ""
35
+ ":mod:`http.cookies` 模組定義了 cookie 概念的抽象化的類別,cookie 是一種 HTTP "
36
+ "狀態管理機制。它支援簡單的純字串 cookie,也提供了將任何可序列化的資料型別作"
37
+ "為 cookie 值的抽象化。"
35
38
36
39
#: ../../library/http.cookies.rst:19
37
40
msgid ""
@@ -42,30 +45,39 @@ msgid ""
42
45
"comes to cookie handling. As a result, this module now uses parsing rules "
43
46
"that are a bit less strict than they once were."
44
47
msgstr ""
48
+ "此模組原先嚴格遵循了 :rfc:`2109` 和 :rfc:`2068` 規範所描述的剖析規則。自從發"
49
+ "現 MSIE 3.0x 並不遵循這些規範所描述的字元規則,許多當前的瀏覽器和伺服器也在處"
50
+ "理 cookie 時放寬了剖析規則。因此,此模組現在使用的剖析規則比之前的更為寬鬆。"
45
51
46
52
#: ../../library/http.cookies.rst:26
47
53
msgid ""
48
54
"The character set, :data:`string.ascii_letters`, :data:`string.digits` and "
49
55
"``!#$%&'*+-.^_`|~:`` denote the set of valid characters allowed by this "
50
56
"module in a cookie name (as :attr:`~Morsel.key`)."
51
57
msgstr ""
58
+ "字元集 :data:`string.ascii_letters`、:data:`string.digits` 和 ``!#$%&'*+-."
59
+ "^_`|~`` 表示此模組在 cookie 名稱 (:attr:`~Morsel.key`) 中允許的合法字元集合。"
52
60
53
61
#: ../../library/http.cookies.rst:30
54
62
msgid "Allowed ':' as a valid cookie name character."
55
- msgstr ""
63
+ msgstr "允許 ':' 作為有效的 cookie 名稱字元。 "
56
64
57
65
#: ../../library/http.cookies.rst:36
58
66
msgid ""
59
67
"On encountering an invalid cookie, :exc:`CookieError` is raised, so if your "
60
68
"cookie data comes from a browser you should always prepare for invalid data "
61
69
"and catch :exc:`CookieError` on parsing."
62
70
msgstr ""
71
+ "當遇到無效的 cookie 時,會引發 :exc:`CookieError`,因此如果你的 cookie 資料來"
72
+ "自瀏覽器,在剖析時你應該總是為無效資料作準備並捕捉 :exc:`CookieError`。"
63
73
64
74
#: ../../library/http.cookies.rst:43
65
75
msgid ""
66
76
"Exception failing because of :rfc:`2109` invalidity: incorrect attributes, "
67
77
"incorrect :mailheader:`Set-Cookie` header, etc."
68
78
msgstr ""
79
+ "因為不符合 :rfc:`2109` 而引發的例外:不正確的屬性、不正確的 :mailheader:`Set-"
80
+ "Cookie` 標頭等。"
69
81
70
82
#: ../../library/http.cookies.rst:49
71
83
msgid ""
@@ -74,10 +86,12 @@ msgid ""
74
86
"value, the value is first converted to a :class:`Morsel` containing the key "
75
87
"and the value."
76
88
msgstr ""
89
+ "這個類別是一個類似字典的物件,其中的鍵是字串,而值則是 :class:`Morsel` 實例。"
90
+ "請注意,當設定鍵的值時,值會先被轉換為一個包含該鍵和值的 :class:`Morsel`。"
77
91
78
92
#: ../../library/http.cookies.rst:53
79
93
msgid "If *input* is given, it is passed to the :meth:`load` method."
80
- msgstr ""
94
+ msgstr "如果有給定 *input*,它會被傳遞給 :meth:`load` 方法。 "
81
95
82
96
#: ../../library/http.cookies.rst:58
83
97
msgid ""
@@ -87,6 +101,10 @@ msgid ""
87
101
"SimpleCookie` calls the builtin :func:`str` to convert the value to a "
88
102
"string. Values received from HTTP are kept as strings."
89
103
msgstr ""
104
+ "這個類別繼承自 :class:`BaseCookie` 並覆寫了 :meth:`~BaseCookie.value_decode` "
105
+ "和 :meth:`~BaseCookie.value_encode`。:class:`!SimpleCookie` 支援字串作為 "
106
+ "cookie 值。當設定值時,:class:`!SimpleCookie` 會呼叫內建的 :func:`str` 來將值"
107
+ "轉換為字串。從 HTTP 接收的值會保持為字串。"
90
108
91
109
#: ../../library/http.cookies.rst:66
92
110
msgid "Module :mod:`http.cookiejar`"
@@ -97,14 +115,16 @@ msgid ""
97
115
"HTTP cookie handling for web *clients*. The :mod:`http.cookiejar` and :mod:"
98
116
"`http.cookies` modules do not depend on each other."
99
117
msgstr ""
118
+ "用於網路\\ *用戶端*\\ 的 HTTP cookie 處理。:mod:`http.cookiejar` 和 :mod:"
119
+ "`http.cookies` 模組互不相依。"
100
120
101
121
#: ../../library/http.cookies.rst:70
102
122
msgid ":rfc:`2109` - HTTP State Management Mechanism"
103
- msgstr ""
123
+ msgstr ":rfc:`2109` - HTTP 狀態管理機制 "
104
124
105
125
#: ../../library/http.cookies.rst:71
106
126
msgid "This is the state management specification implemented by this module."
107
- msgstr ""
127
+ msgstr "這是此模組實作的狀態管理規範。 "
108
128
109
129
#: ../../library/http.cookies.rst:77
110
130
msgid "Cookie Objects"
@@ -116,19 +136,26 @@ msgid ""
116
136
"``real_value`` can be any type. This method does no decoding in :class:"
117
137
"`BaseCookie` --- it exists so it can be overridden."
118
138
msgstr ""
139
+ "從字串表示回傳 ``(real_value, coded_value)`` 的元組。``real_value`` 可以是任"
140
+ "何型別。此方法在 :class:`BaseCookie` 中不做解碼 --- 它存在以便可以被覆寫。"
119
141
120
142
#: ../../library/http.cookies.rst:89
121
143
msgid ""
122
144
"Return a tuple ``(real_value, coded_value)``. *val* can be any type, but "
123
145
"``coded_value`` will always be converted to a string. This method does no "
124
146
"encoding in :class:`BaseCookie` --- it exists so it can be overridden."
125
147
msgstr ""
148
+ "回傳一個元組 ``(real_value, coded_value)``。*val* 可以是任何型別,但 "
149
+ "``coded_value`` 總是會被轉換為字串。此方法在 :class:`BaseCookie` 中不做編碼 "
150
+ "--- 它存在以便可以被覆寫。"
126
151
127
152
#: ../../library/http.cookies.rst:94
128
153
msgid ""
129
154
"In general, it should be the case that :meth:`value_encode` and :meth:"
130
155
"`value_decode` are inverses on the range of *value_decode*."
131
156
msgstr ""
157
+ "一般來說,:meth:`value_encode` 和 :meth:`value_decode` 應該在 *value_decode* "
158
+ "的範圍內是互逆的 (inverse)。"
132
159
133
160
#: ../../library/http.cookies.rst:100
134
161
msgid ""
@@ -137,24 +164,31 @@ msgid ""
137
164
"method. *sep* is used to join the headers together, and is by default the "
138
165
"combination ``'\\ r\\ n'`` (CRLF)."
139
166
msgstr ""
167
+ "回傳一個適合作為 HTTP 標頭來傳送的字串表示。*attrs* 和 *header* 會傳送給每"
168
+ "個 :class:`Morsel` 的 :meth:`~Morsel.output` 方法。*sep* 用來連接標頭,預設"
169
+ "為 ``'\\ r\\ n'`` (CRLF) 的組合。"
140
170
141
171
#: ../../library/http.cookies.rst:108
142
172
msgid ""
143
173
"Return an embeddable JavaScript snippet, which, if run on a browser which "
144
174
"supports JavaScript, will act the same as if the HTTP headers was sent."
145
175
msgstr ""
176
+ "回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的"
177
+ "行為會與 HTTP 標頭被傳送的情況相同。"
146
178
147
179
#: ../../library/http.cookies.rst:111 ../../library/http.cookies.rst:207
148
180
#: ../../library/http.cookies.rst:215
149
181
msgid "The meaning for *attrs* is the same as in :meth:`output`."
150
- msgstr ""
182
+ msgstr "*attrs* 的意義與 :meth:`output` 裡的相同。 "
151
183
152
184
#: ../../library/http.cookies.rst:116
153
185
msgid ""
154
186
"If *rawdata* is a string, parse it as an ``HTTP_COOKIE`` and add the values "
155
187
"found there as :class:`Morsel`\\ s. If it is a dictionary, it is equivalent "
156
188
"to::"
157
189
msgstr ""
190
+ "如果 *rawdata* 是字串,會將其作為 ``HTTP_COOKIE`` 剖析,並將在其中找到的值當"
191
+ "作 :class:`Morsel` 新增。如果它是一個字典,則等同於: ::"
158
192
159
193
#: ../../library/http.cookies.rst:119
160
194
msgid ""
@@ -170,67 +204,76 @@ msgstr "Morsel 物件"
170
204
171
205
#: ../../library/http.cookies.rst:131
172
206
msgid "Abstract a key/value pair, which has some :rfc:`2109` attributes."
173
- msgstr ""
207
+ msgstr "抽象化一個鍵 / 值對,它有一些 :rfc:`2109` 屬性。 "
174
208
175
209
#: ../../library/http.cookies.rst:133
176
210
msgid ""
177
211
"Morsels are dictionary-like objects, whose set of keys is constant --- the "
178
212
"valid :rfc:`2109` attributes, which are:"
179
213
msgstr ""
214
+ "Morsel 是一種類似字典的物件,其鍵的集合是固定的 --- 有效的 :rfc:`2109` 屬性,"
215
+ "它們是:"
180
216
181
217
#: ../../library/http.cookies.rst:146
182
218
msgid ""
183
219
"The attribute :attr:`httponly` specifies that the cookie is only transferred "
184
220
"in HTTP requests, and is not accessible through JavaScript. This is intended "
185
221
"to mitigate some forms of cross-site scripting."
186
222
msgstr ""
223
+ "屬性 :attr:`httponly` 指定 cookie 僅在 HTTP 請求中傳輸,而不可通過 "
224
+ "JavaScript 存取。這是為了減輕某些形式的跨網站腳本攻擊。"
187
225
188
226
#: ../../library/http.cookies.rst:150
189
227
msgid ""
190
228
"The attribute :attr:`samesite` specifies that the browser is not allowed to "
191
229
"send the cookie along with cross-site requests. This helps to mitigate CSRF "
192
230
"attacks. Valid values for this attribute are \" Strict\" and \" Lax\" ."
193
231
msgstr ""
232
+ "屬性 :attr:`samesite` 指定瀏覽器不能將 cookie 與跨網站請求一起傳送。這有助於"
233
+ "減輕 CSRF 攻擊。此屬性的有效值為 \" Strict\" 和 \" Lax\" 。"
194
234
195
235
#: ../../library/http.cookies.rst:154
196
236
msgid "The keys are case-insensitive and their default value is ``''``."
197
- msgstr ""
237
+ msgstr "鍵不區分大小寫,其預設值為 ``''``。 "
198
238
199
239
#: ../../library/http.cookies.rst:156
200
240
msgid ""
201
241
":meth:`!__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into "
202
242
"account."
203
243
msgstr ""
244
+ ":meth:`!__eq__` 現在會考慮 :attr:`~Morsel.key` 和 :attr:`~Morsel.value`。"
204
245
205
246
#: ../../library/http.cookies.rst:160
206
247
msgid ""
207
248
"Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` and :attr:`~Morsel."
208
249
"coded_value` are read-only. Use :meth:`~Morsel.set` for setting them."
209
250
msgstr ""
251
+ "屬性 :attr:`~Morsel.key`、:attr:`~Morsel.value` 和 :attr:`~Morsel."
252
+ "coded_value` 是唯讀的。請使用 :meth:`~Morsel.set` 來設定它們。"
210
253
211
254
#: ../../library/http.cookies.rst:165
212
255
msgid "Added support for the :attr:`samesite` attribute."
213
- msgstr "新增 :attr:`samesite` 屬性的支援"
256
+ msgstr "新增對 :attr:`samesite` 屬性的支援。 "
214
257
215
258
#: ../../library/http.cookies.rst:171
216
259
msgid "The value of the cookie."
217
- msgstr ""
260
+ msgstr "cookie 的值。 "
218
261
219
262
#: ../../library/http.cookies.rst:176
220
263
msgid "The encoded value of the cookie --- this is what should be sent."
221
- msgstr ""
264
+ msgstr "cookie 的編碼值 --- 這是應該被傳送的值。 "
222
265
223
266
#: ../../library/http.cookies.rst:181
224
267
msgid "The name of the cookie."
225
- msgstr ""
268
+ msgstr "cookie 的名稱。 "
226
269
227
270
#: ../../library/http.cookies.rst:186
228
271
msgid "Set the *key*, *value* and *coded_value* attributes."
229
- msgstr ""
272
+ msgstr "設定 *key*、*value* 和 *coded_value* 屬性。 "
230
273
231
274
#: ../../library/http.cookies.rst:191
232
275
msgid "Whether *K* is a member of the set of keys of a :class:`Morsel`."
233
- msgstr ""
276
+ msgstr "*K* 是否為 :class:`Morsel` 的鍵集合中的成員。 "
234
277
235
278
#: ../../library/http.cookies.rst:196
236
279
msgid ""
@@ -239,43 +282,52 @@ msgid ""
239
282
"given, in which case it should be a list of attributes to use. *header* is "
240
283
"by default ``\" Set-Cookie:\" ``."
241
284
msgstr ""
285
+ "回傳適合作為 HTTP 標頭傳送的 Morsel 的字串表示。預設會包含所有屬性,除非有給"
286
+ "定 *attrs*,在此情況下,它應該是一個要使用的屬性的串列。預設的 *header* 是 "
287
+ "``\" Set-Cookie:\" ``。"
242
288
243
289
#: ../../library/http.cookies.rst:204
244
290
msgid ""
245
291
"Return an embeddable JavaScript snippet, which, if run on a browser which "
246
292
"supports JavaScript, will act the same as if the HTTP header was sent."
247
293
msgstr ""
294
+ "回傳一個可嵌入的 JavaScript 片段,如果在支援 JavaScript 的瀏覽器上執行,它的"
295
+ "行為會與 HTTP 標頭被傳送的情況相同。"
248
296
249
297
#: ../../library/http.cookies.rst:212
250
298
msgid ""
251
299
"Return a string representing the Morsel, without any surrounding HTTP or "
252
300
"JavaScript."
253
- msgstr ""
301
+ msgstr "回傳表示 Morsel 的字串,不包含周圍任何的 HTTP 或 JavaScript。 "
254
302
255
303
#: ../../library/http.cookies.rst:220
256
304
msgid ""
257
305
"Update the values in the Morsel dictionary with the values in the dictionary "
258
306
"*values*. Raise an error if any of the keys in the *values* dict is not a "
259
307
"valid :rfc:`2109` attribute."
260
308
msgstr ""
309
+ "更新 Morsel 字典中的值為 *values* 字典中的值。如果 *values* 字典中的任何鍵不"
310
+ "是有效的 :rfc:`2109` 屬性則引發錯誤。"
261
311
262
312
#: ../../library/http.cookies.rst:224
263
313
msgid "an error is raised for invalid keys."
264
- msgstr ""
314
+ msgstr "對於無效的鍵會引發錯誤。 "
265
315
266
316
#: ../../library/http.cookies.rst:230
267
317
msgid "Return a shallow copy of the Morsel object."
268
- msgstr ""
318
+ msgstr "回傳 Morsel 物件的淺層複製。 "
269
319
270
320
#: ../../library/http.cookies.rst:232
271
321
msgid "return a Morsel object instead of a dict."
272
- msgstr ""
322
+ msgstr "回傳 Morsel 物件而不是字典。 "
273
323
274
324
#: ../../library/http.cookies.rst:238
275
325
msgid ""
276
326
"Raise an error if key is not a valid :rfc:`2109` attribute, otherwise behave "
277
327
"the same as :meth:`dict.setdefault`."
278
328
msgstr ""
329
+ "如果鍵不是一個有效的 :rfc:`2109` 屬性會引發錯誤,否則行為與 :meth:`dict."
330
+ "setdefault` 相同。"
279
331
280
332
#: ../../library/http.cookies.rst:245
281
333
msgid "Example"
@@ -284,7 +336,7 @@ msgstr "範例"
284
336
#: ../../library/http.cookies.rst:247
285
337
msgid ""
286
338
"The following example demonstrates how to use the :mod:`http.cookies` module."
287
- msgstr ""
339
+ msgstr "以下範例示範如何使用 :mod:`http.cookies` 模組。 "
288
340
289
341
#: ../../library/http.cookies.rst:249
290
342
msgid ""
@@ -335,3 +387,48 @@ msgid ""
335
387
"Set-Cookie: number=7\n"
336
388
"Set-Cookie: string=seven"
337
389
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