@@ -9,7 +9,7 @@ msgstr ""
99"Project-Id-Version : Python 3.12\n "
1010"Report-Msgid-Bugs-To : \n "
1111"POT-Creation-Date : 2023-07-24 00:03+0000\n "
12- "PO-Revision-Date : 2023-08-09 18:16 +0800\n "
12+ "PO-Revision-Date : 2023-08-12 15:09 +0800\n "
1313"
Last-Translator :
Adrian Liaw <[email protected] >\n "
1414"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
1515"tw)\n "
@@ -216,51 +216,57 @@ msgstr ""
216216
217217#: ../../howto/sorting.rst:190
218218msgid "Decorate-Sort-Undecorate"
219- msgstr ""
219+ msgstr "裝飾-排序-移除裝飾 (decorate-sort-undecorate) "
220220
221221#: ../../howto/sorting.rst:192
222222msgid "This idiom is called Decorate-Sort-Undecorate after its three steps:"
223- msgstr ""
223+ msgstr "這個用語的來源是因為它做了以下三件事情: "
224224
225225#: ../../howto/sorting.rst:194
226226msgid ""
227227"First, the initial list is decorated with new values that control the sort "
228228"order."
229- msgstr ""
229+ msgstr "首先,原始串列會裝飾 (decorated) 上新的值用來控制排序的順序。 "
230230
231231#: ../../howto/sorting.rst:196
232232msgid "Second, the decorated list is sorted."
233- msgstr ""
233+ msgstr "接下來,排序裝飾過的串列。 "
234234
235235#: ../../howto/sorting.rst:198
236236msgid ""
237237"Finally, the decorations are removed, creating a list that contains only the "
238238"initial values in the new order."
239- msgstr ""
239+ msgstr "最後,裝飾會被移除,並以新的順序產生一個只包含原始值的串列。 "
240240
241241#: ../../howto/sorting.rst:201
242242msgid ""
243243"For example, to sort the student data by *grade* using the DSU approach:"
244- msgstr ""
244+ msgstr "例如用上面說的方式來以 *grade* 排序學生資料: "
245245
246246#: ../../howto/sorting.rst:208
247247msgid ""
248248"This idiom works because tuples are compared lexicographically; the first "
249249"items are compared; if they are the same then the second items are compared, "
250250"and so on."
251251msgstr ""
252+ "這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較,先比較第"
253+ "一個項目,如果一樣再比較第二個項目,並依此類推。"
252254
253255#: ../../howto/sorting.rst:212
254256msgid ""
255257"It is not strictly necessary in all cases to include the index *i* in the "
256258"decorated list, but including it gives two benefits:"
257259msgstr ""
260+ "在所有情況下都把索引 *i* 加入已裝飾的串列並不是絕對需要的,但這樣做會有兩個好"
261+ "處:"
258262
259263#: ../../howto/sorting.rst:215
260264msgid ""
261265"The sort is stable -- if two items have the same key, their order will be "
262266"preserved in the sorted list."
263267msgstr ""
268+ "排序會是穩定的 -- 如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順"
269+ "序。"
264270
265271#: ../../howto/sorting.rst:218
266272msgid ""
@@ -269,29 +275,34 @@ msgid ""
269275"example the original list could contain complex numbers which cannot be "
270276"sorted directly."
271277msgstr ""
278+ "原始項目不需要是可以比較的,因為最多只會用到前兩個項目就能決定裝飾過的元組的"
279+ "順序。例如原始串列可以包含不能直接用來排序的複數。"
272280
273281#: ../../howto/sorting.rst:223
274282msgid ""
275283"Another name for this idiom is `Schwartzian transform <https://en.wikipedia."
276284"org/wiki/Schwartzian_transform>`_\\ , after Randal L. Schwartz, who "
277285"popularized it among Perl programmers."
278286msgstr ""
287+ "這個用語的另一個名字是 `Schwartzian transform <https://en.wikipedia.org/wiki/"
288+ "Schwartzian_transform>`_\\ ,是由於 Randal L. Schwartz 讓這個方法在 Perl 程式"
289+ "設計師間普及。"
279290
280291#: ../../howto/sorting.rst:227
281292msgid ""
282293"Now that Python sorting provides key-functions, this technique is not often "
283294"needed."
284- msgstr ""
295+ msgstr "而因為 Python 的排序提供了鍵函式,已經不太需要用到這個方法了。 "
285296
286297#: ../../howto/sorting.rst:230
287298msgid "Comparison Functions"
288- msgstr ""
299+ msgstr "比較函式 (comparison functions) "
289300
290301#: ../../howto/sorting.rst:232
291302msgid ""
292303"Unlike key functions that return an absolute value for sorting, a comparison "
293304"function computes the relative ordering for two inputs."
294- msgstr ""
305+ msgstr "不像鍵函式回傳一個用來排序的值,比較函式計算兩個輸入間的相對順序。 "
295306
296307#: ../../howto/sorting.rst:235
297308msgid ""
@@ -301,6 +312,10 @@ msgid ""
301312"function such as ``cmp(a, b)`` will return a negative value for less-than, "
302313"zero if the inputs are equal, or a positive value for greater-than."
303314msgstr ""
315+ "例如\\ `天秤 <https://upload.wikimedia.org/wikipedia/commons/1/17/"
316+ "Balance_à_tabac_1850.JPG>`_\\ 比較兩邊樣本並給出相對的順序:較輕、相同或較"
317+ "重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相"
318+ "同或正數代表大於。"
304319
305320#: ../../howto/sorting.rst:242
306321msgid ""
@@ -309,17 +324,21 @@ msgid ""
309324"part of their API. For example, :func:`locale.strcoll` is a comparison "
310325"function."
311326msgstr ""
327+ "當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 "
328+ "API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。"
312329
313330#: ../../howto/sorting.rst:246
314331msgid ""
315332"To accommodate those situations, Python provides :class:`functools."
316333"cmp_to_key` to wrap the comparison function to make it usable as a key "
317334"function::"
318335msgstr ""
336+ "為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式,"
337+ "讓其可以當作鍵函式來使用: ::"
319338
320339#: ../../howto/sorting.rst:253
321340msgid "Odds and Ends"
322- msgstr ""
341+ msgstr "雜項說明 "
323342
324343#: ../../howto/sorting.rst:255
325344msgid ""
@@ -328,6 +347,9 @@ msgid ""
328347"\" alphabetical\" sort orderings can vary across cultures even if the "
329348"underlying alphabet is the same."
330349msgstr ""
350+ "要處理能理解本地語系 (locale aware) 的排序可以使用 :func:`locale.strxfrm` 當"
351+ "作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同"
352+ "文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。"
331353
332354#: ../../howto/sorting.rst:260
333355msgid ""
@@ -336,19 +358,26 @@ msgid ""
336358"simulated without the parameter by using the builtin :func:`reversed` "
337359"function twice:"
338360msgstr ""
361+ "*reverse* 參數依然會維持排序穩定性(即有相同鍵的資料會保持原來順序)。有趣的"
362+ "是,不加這個參數也可以模擬這個效果,只要使用內建的 :func:`reversed` 函式兩"
363+ "次:"
339364
340365#: ../../howto/sorting.rst:274
341366msgid ""
342367"The sort routines use ``<`` when making comparisons between two objects. So, "
343368"it is easy to add a standard sort order to a class by defining an :meth:"
344369"`~object.__lt__` method:"
345370msgstr ""
371+ "排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入排序順序比較規則是簡單"
372+ "的,只要透過定義 :meth:`~object.__lt__` 方法:"
346373
347374#: ../../howto/sorting.rst:284
348375msgid ""
349376"However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :"
350377"meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`)."
351378msgstr ""
379+ "然而,需要注意如果沒有實作 :meth:`~object.__lt__`,則 ``<`` 會退而使用 :meth:"
380+ "`~object.__gt__`\\ (參見 :func:`object.__lt__`)。"
352381
353382#: ../../howto/sorting.rst:287
354383msgid ""
@@ -357,3 +386,5 @@ msgid ""
357386"grades are stored in a dictionary, they can be used to sort a separate list "
358387"of student names:"
359388msgstr ""
389+ "鍵函式不需要直接依賴用來排序的物件。鍵函式也可以存取外部資源,例如如果學生成"
390+ "績儲存在字典裡,它可以用來排序一個單獨的學生姓名串列:"
0 commit comments