diff --git a/library/urllib.request.po b/library/urllib.request.po index 5cdf222026..1045e4c60d 100644 --- a/library/urllib.request.po +++ b/library/urllib.request.po @@ -3,13 +3,14 @@ # This file is distributed under the same license as the Python package. # # Translators: +# Adrian Liaw , 2018 msgid "" msgstr "" "Project-Id-Version: Python 3.10\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-10-26 16:47+0000\n" -"PO-Revision-Date: 2018-05-23 16:14+0000\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2021-12-08 23:01+0800\n" +"Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -17,14 +18,15 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.0\n" #: ../../library/urllib.request.rst:2 msgid ":mod:`urllib.request` --- Extensible library for opening URLs" -msgstr "" +msgstr ":mod:`urllib.request` --- 用來開啟 URLs 的可擴充函式庫" #: ../../library/urllib.request.rst:11 msgid "**Source code:** :source:`Lib/urllib/request.py`" -msgstr "" +msgstr "**原始碼:**\\ :source:`Lib/urllib/request.py`" #: ../../library/urllib.request.rst:15 msgid "" @@ -32,22 +34,27 @@ msgid "" "opening URLs (mostly HTTP) in a complex world --- basic and digest " "authentication, redirections, cookies and more." msgstr "" +":mod:`urllib.request` module(模組)定義了一些函式與 class(類別)用以開啟 " +"URLs(大部分是 HTTP),並處理各式複雜情況如:basic 驗證與 digest 驗證、重新導" +"向、cookies。" #: ../../library/urllib.request.rst:21 msgid "" "The `Requests package `_ is " "recommended for a higher-level HTTP client interface." msgstr "" +"有關於更高階的 HTTP 用戶端介面,推薦使用 `Requests 套件 `_\\ 。" #: ../../library/urllib.request.rst:25 msgid "The :mod:`urllib.request` module defines the following functions:" -msgstr "" +msgstr ":mod:`urllib.request` module 定義下列函式:" #: ../../library/urllib.request.rst:30 msgid "" "Open the URL *url*, which can be either a string or a :class:`Request` " "object." -msgstr "" +msgstr "打開 URL *url*,其值可以是一個字串或是一個 :class:`Request` 物件。" #: ../../library/urllib.request.rst:33 msgid "" @@ -55,12 +62,16 @@ msgid "" "server, or ``None`` if no such data is needed. See :class:`Request` for " "details." msgstr "" +"*data* 必須是一個包含傳送給伺服器額外資料的物件,若不需要傳送額外資料則指定" +"為 ``None``\\ 。更多細節請見 :class:`Request`\\ 。" #: ../../library/urllib.request.rst:37 msgid "" "urllib.request module uses HTTP/1.1 and includes ``Connection:close`` header " "in its HTTP requests." msgstr "" +"urllib.request module 使用 HTTP/1.1 並包含 ``Connection:close`` header(標" +"頭)在其 HTTP 請求中。" #: ../../library/urllib.request.rst:40 msgid "" @@ -69,6 +80,9 @@ msgid "" "timeout setting will be used). This actually only works for HTTP, HTTPS and " "FTP connections." msgstr "" +"透過選擇性參數 *timeout* 來指定 blocking operations(阻塞性操作,如:嘗試連" +"接)的 timeout(超時時間),以秒為單位。若沒有指定值,則會使用全域預設超時時" +"間設定。實際上,此參數僅作用於 HTTP、HTTPS 以及 FTP 的連接。" #: ../../library/urllib.request.rst:45 msgid "" @@ -76,6 +90,8 @@ msgid "" "describing the various SSL options. See :class:`~http.client." "HTTPSConnection` for more details." msgstr "" +"若 *context* 有被指定時,它必須是一個 :class:`ssl.SSLContext` 的實例並描述著" +"各種 SSL 選項。更多細節請見 :class:`~http.client.HTTPSConnection`\\ 。" #: ../../library/urllib.request.rst:49 msgid "" @@ -85,10 +101,14 @@ msgid "" "directory of hashed certificate files. More information can be found in :" "meth:`ssl.SSLContext.load_verify_locations`." msgstr "" +"選擇性參數 *cafile* 與 *capath* 用來指定一組 HTTPS 請求中所需之受信任 CA 憑" +"證。*cafile* 的值應該指向內容包含一堆 CA 憑證的單一檔案,而 *capath* 則指向存" +"放一堆雜湊後的憑證檔案的目錄。欲瞭解更多的資訊請參見 :meth:`ssl.SSLContext." +"load_verify_locations`\\ 。" #: ../../library/urllib.request.rst:55 msgid "The *cadefault* parameter is ignored." -msgstr "" +msgstr "參數 *cadefault* 已被忽略。" #: ../../library/urllib.request.rst:57 msgid "" @@ -96,6 +116,9 @@ msgid "" "manager` and has the properties *url*, *headers*, and *status*. See :class:" "`urllib.response.addinfourl` for more detail on these properties." msgstr "" +"這個函數總是回傳一個可作為 :term:`context manager` 使用的物件,並有著特性 " +"(property) *url*、*headers* 與 *status*。欲知更多這些特性細節請參見 :class:" +"`urllib.response.addinfourl`\\ 。" #: ../../library/urllib.request.rst:61 msgid "" @@ -106,6 +129,11 @@ msgid "" "server --- instead of the response headers as it is specified in the " "documentation for :class:`~http.client.HTTPResponse`." msgstr "" +"對於 HTTP 與 HTTPS 的 URLs,這個函式回傳一個稍有不同的 :class:`http.client." +"HTTPResponse` 物件。除了上述提到的三個方法外,另有 msg 屬性並有著與 :attr:" +"`~http.client.HTTPResponse.reason` 相同的資訊 --- 由伺服器回傳的原因敘述 " +"(reason phrase),而不是在 :class:`~http.client.HTTPResponse` 文件中提到的回" +"應 headers。" #: ../../library/urllib.request.rst:69 msgid "" @@ -113,10 +141,13 @@ msgid "" "class:`URLopener` and :class:`FancyURLopener` classes, this function returns " "a :class:`urllib.response.addinfourl` object." msgstr "" +"對於 FTP、檔案、資料的 URLs、以及那些由傳統 classes :class:`URLopener` 與 :" +"class:`FancyURLopener` 所處理的請求,這個函式會回傳一個 :class:`urllib." +"response.addinfourl` 物件。" #: ../../library/urllib.request.rst:73 msgid "Raises :exc:`~urllib.error.URLError` on protocol errors." -msgstr "" +msgstr "當遇到協定上的錯誤時會引發 :exc:`~urllib.error.URLError`\\ 。" #: ../../library/urllib.request.rst:75 msgid "" @@ -124,6 +155,9 @@ msgid "" "the default installed global :class:`OpenerDirector` uses :class:" "`UnknownHandler` to ensure this never happens)." msgstr "" +"請注意若沒有 handler 處理請求時,``None`` 值將會被回傳。(即使有預設的全域類" +"別 :class:`OpenerDirector` 使用 :class:`UnknownHandler` 來確保這種情況不會發" +"生)" #: ../../library/urllib.request.rst:79 msgid "" @@ -132,6 +166,9 @@ msgid "" "`ProxyHandler` is default installed and makes sure the requests are handled " "through the proxy." msgstr "" +"另外,若有偵測到代理服務的設定(例如當 ``*_proxy`` 環境變數像是:\\ :envvar:" +"`http_proxy` 有被設置時),:class:`ProxyHandler` 會被預設使用以確保請求有透過" +"代理服務來處理。" #: ../../library/urllib.request.rst:84 msgid "" @@ -141,12 +178,18 @@ msgid "" "parameter to ``urllib.urlopen``, can be obtained by using :class:" "`ProxyHandler` objects." msgstr "" +"Python 2.6 或更早版本的遺留函式 ``urllib.urlopen`` 已經不再被維護;新函式 :" +"func:`urllib.request.urlopen` 對應到舊函式 ``urllib2.urlopen``。有關代理服務" +"的處理,以往是透過傳遞 dictionary(字典)參數給 ``urllib.urlopen`` 來取得的," +"現在則可以透過 :class:`ProxyHandler` 物件來取得。" #: ../../library/urllib.request.rst:90 msgid "" "Raises an :ref:`auditing event ` ``urllib.Request`` with arguments " "``fullurl``, ``data``, ``headers``, ``method``." msgstr "" +"觸發一個 :ref:`auditing event ` ``urllib.Request`` 及其引數 " +"``fullurl``、``data``、``headers``、``method``。" #: ../../library/urllib.request.rst:92 msgid "" @@ -154,28 +197,32 @@ msgid "" "Request`` with arguments ``fullurl``, ``data``, ``headers``, ``method`` " "taken from the request object." msgstr "" +"預設的 opener 會觸發一個 :ref:`auditing event ` ``urllib.Request`` " +"與其從請求物件中所獲得的引數 ``fullurl``、``data``、``headers``、``method``。" #: ../../library/urllib.request.rst:96 msgid "*cafile* and *capath* were added." -msgstr "" +msgstr "新增 *cafile* 與 *capath*。" #: ../../library/urllib.request.rst:99 msgid "" "HTTPS virtual hosts are now supported if possible (that is, if :data:`ssl." "HAS_SNI` is true)." msgstr "" +"HTTPS 虛擬主機 (virtual hosts) 現已支援,只要 :data:`ssl.HAS_SNI` 的值為 " +"true。" #: ../../library/urllib.request.rst:103 msgid "*data* can be an iterable object." -msgstr "" +msgstr "*data* 可以是一個可疊代物件。" #: ../../library/urllib.request.rst:106 msgid "*cadefault* was added." -msgstr "" +msgstr "*cadefault* 被新增。" #: ../../library/urllib.request.rst:109 msgid "*context* was added." -msgstr "" +msgstr "*context* 被新增。" #: ../../library/urllib.request.rst:112 msgid "" @@ -183,6 +230,9 @@ msgid "" "``http/1.1`` when no *context* is given. Custom *context* should set ALPN " "protocols with :meth:`~ssl.SSLContext.set_alpn_protocol`." msgstr "" +"當 *context* 沒有被指定時,HTTPS 連線現在會傳送一個帶有協定指示器 " +"``http/1.1`` 的 ALPN 擴充 (extension)。自訂的 *context* 應該利用 :meth:`~ssl." +"SSLContext.set_alpn_protocol` 來自行設定 ALPN 協定。" #: ../../library/urllib.request.rst:119 msgid "" @@ -190,6 +240,9 @@ msgid "" "Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let :func:`ssl." "create_default_context` select the system's trusted CA certificates for you." msgstr "" +"*cafile*、*capath*、*cadefault* 已經被棄用並應改為使用 *context*。請改用 :" +"meth:`ssl.SSLContext.load_cert_chain`,或是讓 :func:`ssl." +"create_default_context` 選取系統中受信任的 CA 憑證。" #: ../../library/urllib.request.rst:127 msgid "" @@ -199,6 +252,11 @@ msgid "" "`~urllib.request.urlopen`. The code does not check for a real :class:" "`OpenerDirector`, and any class with the appropriate interface will work." msgstr "" +"安裝一個 :class:`OpenerDirector` 實例作為預設的全域 opener。僅在當你想要讓 " +"urlopen 使用該 opener 時安裝一個 opener,否則的話應直接呼叫 :meth:" +"`OpenerDirector.open` 而非 :func:`~urllib.request.urlopen`\\ 。程式碼不會檢" +"查 class 是否真的為 :class:`OpenerDirector`,而是任何具有正確介面的 class 都" +"能適用。" #: ../../library/urllib.request.rst:137 msgid "" @@ -213,18 +271,31 @@ msgid "" "`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`, :class:" "`HTTPErrorProcessor`." msgstr "" +"回傳一個 :class:`OpenerDirector` 實例,以給定的順序把 handlers 串接起來。" +"*handler*\\s 可以是 :class:`BaseHandler` 的實例,亦或是 :class:`BaseHandler` " +"的 subclasses(這個情況下必須有不帶參數的建構函式能夠被呼叫)。以下 classes " +"的實例順位會在 *handler*\\s 之前,除非 *handler*\\s 已經包含它們,是它們的實" +"例,或是它們的 subclasses:\\ :class:`ProxyHandler`\\ (如果代理服務設定被偵" +"測到)、\\ :class:`UnknownHandler`\\ 、\\ :class:`HTTPHandler`\\ 、\\ :class:" +"`HTTPDefaultErrorHandler`\\ 、\\ :class:`HTTPRedirectHandler`\\ 、\\ :class:" +"`FTPHandler`\\ 、\\ :class:`FileHandler`\\ 、\\ :class:`HTTPErrorProcessor`" +"\\ 。" #: ../../library/urllib.request.rst:147 msgid "" "If the Python installation has SSL support (i.e., if the :mod:`ssl` module " "can be imported), :class:`HTTPSHandler` will also be added." msgstr "" +"如果 Python 安裝時已帶有 SSL 支援(如果 :mod:`ssl` module 能夠被 import)," +"則 :class:`HTTPSHandler` 也在上述 class 之中。" #: ../../library/urllib.request.rst:150 msgid "" "A :class:`BaseHandler` subclass may also change its :attr:`handler_order` " "attribute to modify its position in the handlers list." msgstr "" +"一個 :class:`BaseHandler` 的 subclass 可能透過改變其 :attr:`handler_order` 屬" +"性來調整它在 handlers list 中的位置。" #: ../../library/urllib.request.rst:156 msgid "" @@ -233,6 +304,9 @@ msgid "" "The return value will already be quoted using the :func:`~urllib.parse." "quote` function." msgstr "" +"將路徑名 *path* 從路徑的本地語法 (local syntax) 轉換為 URL 中的 path " +"component(路徑元件)格式。本函式並不會產生完整的 URL。回傳值將使用 :func:" +"`~urllib.parse.quote` 函式先進行編碼過。" #: ../../library/urllib.request.rst:163 msgid "" @@ -240,6 +314,9 @@ msgid "" "syntax for a path. This does not accept a complete URL. This function " "uses :func:`~urllib.parse.unquote` to decode *path*." msgstr "" +"將一個用 \"%\" 編碼過的 URL path component *path* 轉換為路徑的本地語法 " +"(local syntax)。本函式並不接受完整的 URL。本函式使用 :func:`~urllib.parse." +"unquote` 來將 *path* 解碼。" #: ../../library/urllib.request.rst:169 msgid "" @@ -250,6 +327,11 @@ msgid "" "macOS and Windows Systems Registry for Windows. If both lowercase and " "uppercase environment variables exist (and disagree), lowercase is preferred." msgstr "" +"這個輔助函式 (helper function) 回傳一個代理伺服器 URL mappings(對映)的 " +"dictionary。在所有的作業系統中,它首先掃描環境中有著 ``_proxy`` 名稱" +"的變數(忽略大小寫的),如果找不到的話就會在 macOS 中的系統設定 (System " +"Configuration) 或是 Windows 系統中的 Windows Systems Registry 尋找代理服務設" +"定。如果大小寫的環境變數同時存在且值有不同,小寫的環境變數會被選用。" #: ../../library/urllib.request.rst:179 msgid "" @@ -261,18 +343,24 @@ msgid "" "``ProxyHandler`` explicitly, or make sure the variable name is in lowercase " "(or at least the ``_proxy`` suffix)." msgstr "" +"如果環境變數 ``REQUEST_METHOD`` 有被設置(通常這代表著你的 script 是運行在一" +"個共用閘道介面 (CGI) 環境中),那麼環境變數 ``HTTP_PROXY`` (大寫的 " +"``_PROXY``)將被忽略。這是因為變數可以透過使用 \"Proxy:\" HTTP header 被注" +"入。如果需要在共用閘道介面環境中使用 HTTP 代理服務,可以明確使用 " +"``ProxyHandler``,亦或是確認變數名稱是小寫的(或至少 ``_proxy`` 後綴是小寫" +"的)。" #: ../../library/urllib.request.rst:188 msgid "The following classes are provided:" -msgstr "" +msgstr "提供了以下的 classes:" #: ../../library/urllib.request.rst:192 msgid "This class is an abstraction of a URL request." -msgstr "" +msgstr "這個 class 是一個 URL 請求的抽象 class。" #: ../../library/urllib.request.rst:194 msgid "*url* should be a string containing a valid URL." -msgstr "" +msgstr "*url* 是一個包含有效 URL 的字串。" #: ../../library/urllib.request.rst:196 msgid "" @@ -286,6 +374,14 @@ msgid "" "specified in :rfc:`7230`, Section 3.3.1 will be used to send files and other " "iterables." msgstr "" +"*data* 必須是一個包含要送到伺服器的附加資料的物件,若不需帶附加資料則其值應" +"為 ``None``。目前 HTTP 請求是唯一有使用 *data* 參數的,其支援的物件型別包含位" +"元組、類檔案物件 (file-like objects)、以及可疊代的類位元組串物件 (bytes-like " +"objects)。如果沒有提供 ``Content-Length`` 及 ``Transfer-Encoding`` headers 欄" +"位,:class:`HTTPHandler` 將會根據 *data* 的型別設置這些 header。``Content-" +"Length`` 會被用來傳送位元組串物件,而 :rfc:`7230` 章節 3.3.1 所定義的 " +"``Transfer-Encoding: chunked`` 則會被用來傳送檔案或是其它可疊代物件 " +"(iterables)。" #: ../../library/urllib.request.rst:206 msgid "" @@ -295,6 +391,10 @@ msgid "" "returns an ASCII string in this format. It should be encoded to bytes before " "being used as the *data* parameter." msgstr "" +"對於一個 HTTP POST 請求方法,*data* 應為一個標準 :mimetype:`application/x-" +"www-form-urlencoded` 格式的 buffer。:func:`urllib.parse.urlencode` 方法接受一" +"個 mapping 或是 sequence(序列)的 2-tuples,並回傳一個對應格式的 ASCII 字" +"串。在被作為 *data* 參數前它應該被編碼成位元組串。" #: ../../library/urllib.request.rst:212 msgid "" @@ -307,6 +407,13 @@ msgid "" "Firefox/2.0.0.11\"``, while :mod:`urllib`'s default user agent string is ``" "\"Python-urllib/2.6\"`` (on Python 2.6)." msgstr "" +"*headers* 必須是一個 dictionary,並會被視為如同每對 key 和 value 作為引數來呼" +"叫 :meth:`add_header`\\ 。經常用於「偽裝」 ``User-Agent`` header 的值,這個 " +"header 是用來讓一個瀏覽器向伺服器表明自己的身分 --- 有些 HTTP 伺服器僅允許來" +"自普通瀏覽器的請求,而不接受來自程式腳本的請求。例如,Mozilla Firefox 會將 " +"header 的值設為 ``\"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 " +"Firefox/2.0.0.11\"``,而 :mod:`urllib` 的值則是 ``\"Python-urllib/2.6\"``\\ " +"(在 Python 2.6 上)。" #: ../../library/urllib.request.rst:222 msgid "" @@ -315,12 +422,16 @@ msgid "" "None, ``Content-Type: application/x-www-form-urlencoded`` will be added as a " "default." msgstr "" +"當有給定 *data* 引數時,一個適當的 ``Content-Type`` header 應該被設置。如果這" +"個 header 沒有被提供且 *data* 也不為 None 時,預設值 ``Content-Type: " +"application/x-www-form-urlencoded`` 會被新增至請求中。" #: ../../library/urllib.request.rst:227 msgid "" "The next two arguments are only of interest for correct handling of third-" "party HTTP cookies:" msgstr "" +"接下來的兩個引數的介紹提供給那些有興趣正確處理第三方 HTTP cookies 的使用者:" #: ../../library/urllib.request.rst:230 msgid "" @@ -331,6 +442,10 @@ msgid "" "an image in an HTML document, this should be the request-host of the request " "for the page containing the image." msgstr "" +"*origin_req_host* 應為原始傳輸互動的請求主機 (request-host),如同在 :rfc:" +"`2965` 中的定義。預設值為 ``http.cookiejar.request_host(self)``\\ 。這是使用" +"者發起的原始請求的主機名稱或是 IP 位址。例如當請求是要求一個 HTML 文件中的一" +"個影像,則這個屬性應為請求包含影像頁面的請求主機。" #: ../../library/urllib.request.rst:238 msgid "" @@ -340,6 +455,10 @@ msgid "" "if the request is for an image in an HTML document, and the user had no " "option to approve the automatic fetching of the image, this should be true." msgstr "" +"*unverifiable* 應該標示一個請求是否是無法驗證的,如同在 :rfc:`2965` 中的定" +"義。其預設值為 ``False``。一個無法驗證的請求是指使用者沒有機會去批准請求的 " +"URL,例如一個對於 HTML 文件中的影像所做的請求,而使用者沒有機會去批准是否能自" +"動擷取影像,則這個值應該為 true。" #: ../../library/urllib.request.rst:245 msgid "" @@ -350,6 +469,11 @@ msgid "" "indicate a different default method by setting the :attr:`~Request.method` " "attribute in the class itself." msgstr "" +"*method* 應為一個標示 HTTP 請求方法的字串(例如:``'HEAD'``)。如果有提供值," +"則會被存在 :attr:`~Request.method` 屬性中且被 :meth:`get_method()` 所使用。" +"當 *data* 是 ``None`` 時,其預設值為 ``'GET'``,否則預設值為 ``'POST'``。" +"Subclasses 可以透過設置其 :attr:`~Request.method` 屬性來設定不一樣的預設請求" +"方法。" #: ../../library/urllib.request.rst:253 msgid "" @@ -360,14 +484,18 @@ msgid "" "the headers. There is no support for a 100-continue expectation in the " "library." msgstr "" +"如果資料物件無法重複提供其內容(例如一個檔案或是只能產生一次內容的可疊代物" +"件)且請求因為 HTTP 重導向 (redirects) 或是 HTTP 驗證 (authentication) 而被重" +"新嘗試傳送,則該請求不會正常運作。*data* 會接在 headers 之後被送至 HTTP 伺服" +"器。此函式庫沒有支援 100-continue expectation。" #: ../../library/urllib.request.rst:260 msgid ":attr:`Request.method` argument is added to the Request class." -msgstr "" +msgstr "新增 :attr:`Request.method` 引數到 Request class。" #: ../../library/urllib.request.rst:263 msgid "Default :attr:`Request.method` may be indicated at the class level." -msgstr "" +msgstr "能夠在 class 中設置預設的 :attr:`Request.method`\\ 。" #: ../../library/urllib.request.rst:266 msgid "" @@ -375,6 +503,9 @@ msgid "" "*data* is neither ``None`` nor a bytes object. Fall back to use chunked " "transfer encoding instead." msgstr "" +"如果 ``Content-Length`` 尚未被提供且 *data* 既不是 ``None`` 也不是一個位元組" +"串物件,則不會觸發錯誤,並 fall back(後備)使用分塊傳輸編碼 (chunked " +"transfer encoding)。" #: ../../library/urllib.request.rst:273 msgid ""