From dff233b6dc2d312d312261e3320f22ac165efb04 Mon Sep 17 00:00:00 2001 From: "Matt.Wang" Date: Wed, 9 Feb 2022 19:41:06 +0800 Subject: [PATCH 1/2] translate `library/asyncio-sync.po` --- library/asyncio-sync.po | 138 ++++++++++++++++++++++++++++++---------- 1 file changed, 106 insertions(+), 32 deletions(-) diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index 32b3a2597d..8a4e0a3c55 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -8,7 +8,7 @@ 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 14:39+0000\n" +"PO-Revision-Date: 2022-02-09 19:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -17,10 +17,11 @@ 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.1\n" #: ../../library/asyncio-sync.rst:7 msgid "Synchronization Primitives" -msgstr "" +msgstr "同步化原始物件 (Synchronization Primitives)" #: ../../library/asyncio-sync.rst:9 msgid "**Source code:** :source:`Lib/asyncio/locks.py`" @@ -31,12 +32,16 @@ msgid "" "asyncio synchronization primitives are designed to be similar to those of " "the :mod:`threading` module with two important caveats:" msgstr "" +"asyncio 的同步化原始物件被設計成和那些 :mod:`threading` 模組 (module) 中的同" +"名物件相似,但有兩個重要的限制條件:" #: ../../library/asyncio-sync.rst:16 msgid "" "asyncio primitives are not thread-safe, therefore they should not be used " "for OS thread synchronization (use :mod:`threading` for that);" msgstr "" +"asyncio 原始物件並不支援執行緒安全 (thread-safe),因此他們不可被用於 OS 執行" +"緒同步化(請改用 :mod:`threading`\\ );" #: ../../library/asyncio-sync.rst:20 msgid "" @@ -44,10 +49,12 @@ msgid "" "argument; use the :func:`asyncio.wait_for` function to perform operations " "with timeouts." msgstr "" +"這些同步化原始物件的方法 (method) 並不接受 *timeout* 引數;要達成有超時 " +"(timeout) 設定的操作請改用 :func:`asyncio.wait_for` 函式。" #: ../../library/asyncio-sync.rst:24 msgid "asyncio has the following basic synchronization primitives:" -msgstr "" +msgstr "asyncio 有以下基礎同步化原始物件:" #: ../../library/asyncio-sync.rst:26 msgid ":class:`Lock`" @@ -71,26 +78,33 @@ msgstr ":class:`BoundedSemaphore`" #: ../../library/asyncio-sync.rst:37 msgid "Lock" -msgstr "" +msgstr "Lock" #: ../../library/asyncio-sync.rst:41 msgid "Implements a mutex lock for asyncio tasks. Not thread-safe." msgstr "" +"實作了一個給 asyncio 任務 (task) 用的互斥鎖 (mutex lock)。不支援執行緒安全。" #: ../../library/asyncio-sync.rst:43 msgid "" "An asyncio lock can be used to guarantee exclusive access to a shared " "resource." -msgstr "" +msgstr "一個 asyncio 的鎖可以用來確保一個共享資源的存取權被獨佔。" #: ../../library/asyncio-sync.rst:46 msgid "The preferred way to use a Lock is an :keyword:`async with` statement::" msgstr "" +"使用 Lock 的推薦方式是透過 :keyword:`async with` 陳述式:\n" +"\n" +"::" #: ../../library/asyncio-sync.rst:55 ../../library/asyncio-sync.rst:207 #: ../../library/asyncio-sync.rst:309 msgid "which is equivalent to::" msgstr "" +"這等價於:\n" +"\n" +"::" #: ../../library/asyncio-sync.rst:71 ../../library/asyncio-sync.rst:119 #: ../../library/asyncio-sync.rst:197 ../../library/asyncio-sync.rst:299 @@ -100,58 +114,67 @@ msgid "" "running loop since 3.7. See :ref:`What's New in 3.10's Removed section " "` for more information." msgstr "" +"``loop`` 參數。自從 3.7 版本開始,此類別會隱晦地拿到當前正在運行的事件迴圈。" +"更多資訊請見 :ref:`3.10 有什麼新功能中的被移除功能相關段落 `\\ 。" #: ../../library/asyncio-sync.rst:74 msgid "Acquire the lock." -msgstr "" +msgstr "獲得鎖。" #: ../../library/asyncio-sync.rst:76 msgid "" "This method waits until the lock is *unlocked*, sets it to *locked* and " "returns ``True``." msgstr "" +"此方法會持續等待直到鎖的狀態成為 *unlocked*\\ ,並將其設置為 *locked* 和回傳 " +"``True``\\ 。" #: ../../library/asyncio-sync.rst:79 msgid "" "When more than one coroutine is blocked in :meth:`acquire` waiting for the " "lock to be unlocked, only one coroutine eventually proceeds." msgstr "" +"當多於一個的協程 (coroutine) 在 :meth:`acquire` 中等待解鎖而被阻塞,最終只會" +"有其中的一個被處理。" #: ../../library/asyncio-sync.rst:83 msgid "" "Acquiring a lock is *fair*: the coroutine that proceeds will be the first " "coroutine that started waiting on the lock." msgstr "" +"鎖的獲取方式是\\ *公平*\\ 的:被處理的協程會是最早開始等待解鎖的那一個。" #: ../../library/asyncio-sync.rst:88 msgid "Release the lock." -msgstr "" +msgstr "釋放鎖。" #: ../../library/asyncio-sync.rst:90 msgid "When the lock is *locked*, reset it to *unlocked* and return." -msgstr "" +msgstr "如果鎖的狀態為 *locked* 則將其重置為 *unlocked* 並回傳。" #: ../../library/asyncio-sync.rst:92 msgid "If the lock is *unlocked*, a :exc:`RuntimeError` is raised." -msgstr "" +msgstr "如果鎖的狀態為 *unlocked* 則 :exc:`RuntimeError` 會被引發。" #: ../../library/asyncio-sync.rst:96 msgid "Return ``True`` if the lock is *locked*." -msgstr "" +msgstr "如果鎖的狀態為 *locked* 則回傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:100 msgid "Event" -msgstr "" +msgstr "Event" #: ../../library/asyncio-sync.rst:104 msgid "An event object. Not thread-safe." -msgstr "" +msgstr "一個事件 (event) 物件。不支援執行緒安全。" #: ../../library/asyncio-sync.rst:106 msgid "" "An asyncio event can be used to notify multiple asyncio tasks that some " "event has happened." msgstr "" +"一個 asyncio 事件可以被用於通知多個有發生某些事件於其中的 asyncio 任務。" #: ../../library/asyncio-sync.rst:109 msgid "" @@ -160,6 +183,10 @@ msgid "" "method. The :meth:`~Event.wait` method blocks until the flag is set to " "*true*. The flag is set to *false* initially." msgstr "" +"一個 Event 物件會管理一個內部旗標 (flag),它可以透過 :meth:`~Event.set` 方法" +"來被設為 *true* 並透過 :meth:`clear` 方法來重置為 *false*\\ 。\\ :meth:" +"`~Event.wait` 方法會被阻塞 (block) 直到該旗標被設為 *true*\\ 。該旗標初始設置" +"為 *false*\\ 。" #: ../../library/asyncio-sync.rst:122 msgid "Example::" @@ -170,49 +197,55 @@ msgstr "" #: ../../library/asyncio-sync.rst:147 msgid "Wait until the event is set." -msgstr "" +msgstr "持續等待直到事件被設置。" #: ../../library/asyncio-sync.rst:149 msgid "" "If the event is set, return ``True`` immediately. Otherwise block until " "another task calls :meth:`~Event.set`." msgstr "" +"如果事件有被設置則立刻回傳 ``True``\\ 。否則持續阻塞直到另一個任務呼叫 :meth:" +"`~Event.set`\\ 。" #: ../../library/asyncio-sync.rst:154 msgid "Set the event." -msgstr "" +msgstr "設置事件。" #: ../../library/asyncio-sync.rst:156 msgid "All tasks waiting for event to be set will be immediately awakened." -msgstr "" +msgstr "所有正在等待事件被設置的任務會立即被喚醒。" #: ../../library/asyncio-sync.rst:161 msgid "Clear (unset) the event." -msgstr "" +msgstr "清除(還原)事件。" #: ../../library/asyncio-sync.rst:163 msgid "" "Tasks awaiting on :meth:`~Event.wait` will now block until the :meth:`~Event." "set` method is called again." msgstr "" +"正透過 :meth:`~Event.wait` 等待的 Tasks 現在會持續阻塞直到 :meth:`~Event." +"set` 方法再次被呼叫。" #: ../../library/asyncio-sync.rst:168 msgid "Return ``True`` if the event is set." -msgstr "" +msgstr "如果事件有被設置則回傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:172 msgid "Condition" -msgstr "" +msgstr "Condition" #: ../../library/asyncio-sync.rst:176 msgid "A Condition object. Not thread-safe." -msgstr "" +msgstr "一個條件 (codition) 物件。不支援執行緒安全。" #: ../../library/asyncio-sync.rst:178 msgid "" "An asyncio condition primitive can be used by a task to wait for some event " "to happen and then get exclusive access to a shared resource." msgstr "" +"一個 asyncio 條件原始物件可以被任務用來等待某事件發生,並獲得一個共享資源的獨" +"佔存取權。" #: ../../library/asyncio-sync.rst:182 msgid "" @@ -222,33 +255,45 @@ msgid "" "shared resource between different tasks interested in particular states of " "that shared resource." msgstr "" +"本質上,一個 Condition 物件會結合 :class:`Event` 和 :class:`Lock` 的功能。多" +"個 Condition 物件共享一個 Lock 是有可能發生的,這能夠協調關注同一共享資源的不" +"同狀態以獲取其獨佔存取權的多個任務。" #: ../../library/asyncio-sync.rst:188 msgid "" "The optional *lock* argument must be a :class:`Lock` object or ``None``. In " "the latter case a new Lock object is created automatically." msgstr "" +"可選的 *lock* 引數必須是一個 :class:`Lock` 物件或者為 ``None``\\ 。如為後者則" +"一個新的 Lock 物件會被自動建立。" #: ../../library/asyncio-sync.rst:198 msgid "" "The preferred way to use a Condition is an :keyword:`async with` statement::" msgstr "" +"使用 Condition 的推薦方式是透過 :keyword:`async with` 陳述式:\n" +"\n" +"::" #: ../../library/asyncio-sync.rst:220 msgid "Acquire the underlying lock." -msgstr "" +msgstr "獲取底層的鎖。" #: ../../library/asyncio-sync.rst:222 msgid "" "This method waits until the underlying lock is *unlocked*, sets it to " "*locked* and returns ``True``." msgstr "" +"此方法會持續等待直到底層的鎖為 *unlocked*\\ ,並將其設為 *locked* 並回傳 " +"``True``\\ 。" #: ../../library/asyncio-sync.rst:227 msgid "" "Wake up at most *n* tasks (1 by default) waiting on this condition. The " "method is no-op if no tasks are waiting." msgstr "" +"喚醒至多 *n* 個正在等待此條件的任務(預設為 1),如果沒有正在等待的任務則此方" +"法為空操作 (no-op)。" #: ../../library/asyncio-sync.rst:230 ../../library/asyncio-sync.rst:245 msgid "" @@ -256,36 +301,40 @@ msgid "" "after. If called with an *unlocked* lock a :exc:`RuntimeError` error is " "raised." msgstr "" +"在此方法被呼叫前必須先獲得鎖,並在之後立刻將其釋放。如果呼叫於一個 " +"*unlocked* 的鎖則 :exc:`RuntimeError` 錯誤會被引發。" #: ../../library/asyncio-sync.rst:236 msgid "Return ``True`` if the underlying lock is acquired." -msgstr "" +msgstr "如果已獲取底層的鎖則回傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:240 msgid "Wake up all tasks waiting on this condition." -msgstr "" +msgstr "喚醒所有正在等待此條件的任務。" #: ../../library/asyncio-sync.rst:242 msgid "This method acts like :meth:`notify`, but wakes up all waiting tasks." -msgstr "" +msgstr "這個方法的行為就像 :meth:`notify`\\ ,但會喚醒所有正在等待的任務。" #: ../../library/asyncio-sync.rst:251 msgid "Release the underlying lock." -msgstr "" +msgstr "釋放底層的鎖。" #: ../../library/asyncio-sync.rst:253 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." -msgstr "" +msgstr "當調用於一個未被解開的鎖之上時,會引發一個 :exc:`RuntimeError`\\ 。" #: ../../library/asyncio-sync.rst:258 msgid "Wait until notified." -msgstr "" +msgstr "持續等待直到被通知 (notify)。" #: ../../library/asyncio-sync.rst:260 msgid "" "If the calling task has not acquired the lock when this method is called, a :" "exc:`RuntimeError` is raised." msgstr "" +"當此方法被呼叫時,如果呼叫它的任務還沒有獲取所的話,\\ :exc:`RuntimeError` 會" +"被引發。" #: ../../library/asyncio-sync.rst:263 msgid "" @@ -293,24 +342,29 @@ msgid "" "awakened by a :meth:`notify` or :meth:`notify_all` call. Once awakened, the " "Condition re-acquires its lock and this method returns ``True``." msgstr "" +"此方法會釋放底層的鎖,然後持續阻塞直到被 :meth:`notify` 或 :meth:" +"`notify_all` 的呼叫所喚醒。一但被喚醒,Condition 會重新獲取該鎖且此方法會回" +"傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:270 msgid "Wait until a predicate becomes *true*." -msgstr "" +msgstr "持續等待直到謂語 (predicate) 成為 *true*\\ 。" #: ../../library/asyncio-sync.rst:272 msgid "" "The predicate must be a callable which result will be interpreted as a " "boolean value. The final value is the return value." msgstr "" +"謂語必須是一個結果可被直譯為一個 boolean 值的可呼叫物件 (callable)。最終值為" +"回傳值。" #: ../../library/asyncio-sync.rst:278 msgid "Semaphore" -msgstr "" +msgstr "Semaphore" #: ../../library/asyncio-sync.rst:282 msgid "A Semaphore object. Not thread-safe." -msgstr "" +msgstr "一個旗號 (semaphore) 物件。不支援執行緒安全。" #: ../../library/asyncio-sync.rst:284 msgid "" @@ -319,6 +373,9 @@ msgid "" "never go below zero; when :meth:`acquire` finds that it is zero, it blocks, " "waiting until some task calls :meth:`release`." msgstr "" +"一個旗號物件會管理一個內部計數器,會在每次呼叫 :meth:`acquire` 時減少一、每次" +"呼叫 :meth:`release` 時增加一。此計數器永遠不會少於零;當 :meth:`acquire` 發" +"現它是零時,它會持續阻塞並等待某任務呼叫 :meth:`release`\\ 。" #: ../../library/asyncio-sync.rst:290 msgid "" @@ -326,15 +383,20 @@ msgid "" "counter (``1`` by default). If the given value is less than ``0`` a :exc:" "`ValueError` is raised." msgstr "" +"可選的 *value* 引數給定了內部計數器的初始值(預設為 ``1``\\ )。如給定的值少" +"於 ``0`` 則 :exc:`ValueError` 會被引發。" #: ../../library/asyncio-sync.rst:300 msgid "" "The preferred way to use a Semaphore is an :keyword:`async with` statement::" msgstr "" +"使用 Semaphore 的推薦方式是透過 :keyword:`async with` 陳述式:\n" +"\n" +"::" #: ../../library/asyncio-sync.rst:322 msgid "Acquire a semaphore." -msgstr "" +msgstr "獲取一個旗號。" #: ../../library/asyncio-sync.rst:324 msgid "" @@ -342,22 +404,28 @@ msgid "" "``True`` immediately. If it is zero, wait until a :meth:`release` is called " "and return ``True``." msgstr "" +"如果內部計數器大於零,將其減一並立刻回傳 ``True``\\ 。如果為零,則持續等待直" +"到 :meth:`release` 被呼叫,並回傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:330 msgid "Returns ``True`` if semaphore can not be acquired immediately." -msgstr "" +msgstr "如果旗號無法立即被取得則回傳 ``True``\\ 。" #: ../../library/asyncio-sync.rst:334 msgid "" "Release a semaphore, incrementing the internal counter by one. Can wake up a " "task waiting to acquire the semaphore." msgstr "" +"釋放一個旗號,並為其內部的計數器數值增加一。可以把一個正在等待獲取旗號的任務" +"叫醒。" #: ../../library/asyncio-sync.rst:337 msgid "" "Unlike :class:`BoundedSemaphore`, :class:`Semaphore` allows making more " "``release()`` calls than ``acquire()`` calls." msgstr "" +"和 :class:`BoundedSemaphore` 不同,\\ :class:`Semaphore` 允許 ``release()`` " +"的呼叫次數多於 ``acquire()``\\ 。" #: ../../library/asyncio-sync.rst:342 msgid "BoundedSemaphore" @@ -365,7 +433,7 @@ msgstr "BoundedSemaphore" #: ../../library/asyncio-sync.rst:346 msgid "A bounded semaphore object. Not thread-safe." -msgstr "" +msgstr "一個有界的旗號物件。不支援執行緒安全。" #: ../../library/asyncio-sync.rst:348 msgid "" @@ -373,6 +441,9 @@ msgid "" "`ValueError` in :meth:`~Semaphore.release` if it increases the internal " "counter above the initial *value*." msgstr "" +"Bounded Semaphore 是 :class:`Semaphore` 的另一版本,如果其內部的計數器數值增" +"加至大於初始 *value* 值的話,\\ :exc:`ValueError` 會在 :meth:`~Semaphore." +"release` 時被引發。" #: ../../library/asyncio-sync.rst:364 msgid "" @@ -380,3 +451,6 @@ msgid "" "`with` statement (``with await lock``, ``with (yield from lock)``) was " "removed. Use ``async with lock`` instead." msgstr "" +"透過 ``await lock`` 或 ``yield from lock`` 和/或 :keyword:`with` 陳述式 " +"(``with await lock``, ``with (yield from lock)``) 來獲取鎖的方式已被移除。請" +"改用 ``async with lock``\\ 。" From 12d583b0623ce56c34fce94d95221ddd273be650 Mon Sep 17 00:00:00 2001 From: Josix Date: Tue, 15 Feb 2022 19:13:54 +0800 Subject: [PATCH 2/2] Update library/asyncio-sync.po --- library/asyncio-sync.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index 8a4e0a3c55..e589c94133 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -333,7 +333,7 @@ msgid "" "If the calling task has not acquired the lock when this method is called, a :" "exc:`RuntimeError` is raised." msgstr "" -"當此方法被呼叫時,如果呼叫它的任務還沒有獲取所的話,\\ :exc:`RuntimeError` 會" +"當此方法被呼叫時,如果呼叫它的任務還沒有獲取鎖的話,\\ :exc:`RuntimeError` 會" "被引發。" #: ../../library/asyncio-sync.rst:263