From 33f56e06e1da503790ebffe92eae5d3111da6e31 Mon Sep 17 00:00:00 2001 From: minghx Date: Sat, 12 Aug 2023 07:43:30 +0000 Subject: [PATCH 1/3] Translate howto/sorting from section 'Decorate-Sort-Undecorate' to end --- howto/sorting.po | 55 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/howto/sorting.po b/howto/sorting.po index 2feb1b11fe..99e0188bb3 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" -"PO-Revision-Date: 2023-08-09 18:16+0800\n" +"PO-Revision-Date: 2023-08-12 15:09+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -216,32 +216,32 @@ msgstr "" #: ../../howto/sorting.rst:190 msgid "Decorate-Sort-Undecorate" -msgstr "" +msgstr "裝飾-排序-移除裝飾 (decorate-sort-undecorate)" #: ../../howto/sorting.rst:192 msgid "This idiom is called Decorate-Sort-Undecorate after its three steps:" -msgstr "" +msgstr "這個用語的來源是因為它做了以下三件事情:" #: ../../howto/sorting.rst:194 msgid "" "First, the initial list is decorated with new values that control the sort " "order." -msgstr "" +msgstr "首先,原始串列會裝飾 (decorated) 上新的值用來控制排序的順序。" #: ../../howto/sorting.rst:196 msgid "Second, the decorated list is sorted." -msgstr "" +msgstr "接下來,排序裝飾過的串列。" #: ../../howto/sorting.rst:198 msgid "" "Finally, the decorations are removed, creating a list that contains only the " "initial values in the new order." -msgstr "" +msgstr "最後,裝飾會被移除,並以新的順序產生一個只包含原始值的串列。" #: ../../howto/sorting.rst:201 msgid "" "For example, to sort the student data by *grade* using the DSU approach:" -msgstr "" +msgstr "例如用上面說的方式來以 *grade* 排序學生資料:" #: ../../howto/sorting.rst:208 msgid "" @@ -249,18 +249,24 @@ msgid "" "items are compared; if they are the same then the second items are compared, " "and so on." msgstr "" +"這個方式會有效是因為元組是依照字典順序來比較;先比較第一個項目;如果一樣再比" +"較第二個項目,並依此類推。" #: ../../howto/sorting.rst:212 msgid "" "It is not strictly necessary in all cases to include the index *i* in the " "decorated list, but including it gives two benefits:" msgstr "" +"在所有情況下都把索引 *i* 加入已裝飾的串列並不是絕對需要的,但這樣做會有兩個好" +"處:" #: ../../howto/sorting.rst:215 msgid "" "The sort is stable -- if two items have the same key, their order will be " "preserved in the sorted list." msgstr "" +"排序會是穩定的——如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順" +"序。" #: ../../howto/sorting.rst:218 msgid "" @@ -269,6 +275,8 @@ msgid "" "example the original list could contain complex numbers which cannot be " "sorted directly." msgstr "" +"原始項目不需要是可以比較的,因為最多只會用到前兩個項目就能決定裝飾過的元組的" +"順序。例如原始串列可以包含不能直接用來排序的複數。" #: ../../howto/sorting.rst:223 msgid "" @@ -276,22 +284,25 @@ msgid "" "org/wiki/Schwartzian_transform>`_\\, after Randal L. Schwartz, who " "popularized it among Perl programmers." msgstr "" +"這個用語的另一個名字是 `Schwartzian transform `_\\ ,是由於 Randal L. Schwartz 讓這個方法在 Perl 程式" +"設計師間普及。" #: ../../howto/sorting.rst:227 msgid "" "Now that Python sorting provides key-functions, this technique is not often " "needed." -msgstr "" +msgstr "而因為 Python 的排序提供了鍵函式,已經不太常需要這個方法了。" #: ../../howto/sorting.rst:230 msgid "Comparison Functions" -msgstr "" +msgstr "比較函式 (comparison functions)" #: ../../howto/sorting.rst:232 msgid "" "Unlike key functions that return an absolute value for sorting, a comparison " "function computes the relative ordering for two inputs." -msgstr "" +msgstr "不像鍵函式回傳一個用來排序的值,比較函式計算兩個輸入間的相對順序。" #: ../../howto/sorting.rst:235 msgid "" @@ -301,6 +312,10 @@ msgid "" "function such as ``cmp(a, b)`` will return a negative value for less-than, " "zero if the inputs are equal, or a positive value for greater-than." msgstr "" +"例如\\ `天秤 `_\\ 比較兩邊樣本並給出相對的順序:較輕、相同、或較" +"重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相" +"同、或正數代表大於。" #: ../../howto/sorting.rst:242 msgid "" @@ -309,6 +324,8 @@ msgid "" "part of their API. For example, :func:`locale.strcoll` is a comparison " "function." msgstr "" +"當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 " +"API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。" #: ../../howto/sorting.rst:246 msgid "" @@ -316,10 +333,14 @@ msgid "" "cmp_to_key` to wrap the comparison function to make it usable as a key " "function::" msgstr "" +"為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式," +"讓其可以當作鍵函式來使用:\n" +"\n" +"::" #: ../../howto/sorting.rst:253 msgid "Odds and Ends" -msgstr "" +msgstr "零星雜事" #: ../../howto/sorting.rst:255 msgid "" @@ -328,6 +349,9 @@ msgid "" "\"alphabetical\" sort orderings can vary across cultures even if the " "underlying alphabet is the same." msgstr "" +"要處理能理解本地語系 (locale aware) 的排序可以使用 :func:`locale.strxfrm` 當" +"作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同" +"文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。" #: ../../howto/sorting.rst:260 msgid "" @@ -336,6 +360,9 @@ msgid "" "simulated without the parameter by using the builtin :func:`reversed` " "function twice:" msgstr "" +"*reverse* 參數依然會維持排序穩定性(即有相同鍵的資料會保持原來順序)。有趣的" +"是,不加這個參數也可以模擬這個效果,只要使用內建的 :func:`reversed` 函式兩" +"次:" #: ../../howto/sorting.rst:274 msgid "" @@ -343,12 +370,16 @@ msgid "" "it is easy to add a standard sort order to a class by defining an :meth:" "`~object.__lt__` method:" msgstr "" +"排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入順序比較基準是簡單的," +"只要透過定義 :meth:`~object.__lt__` 方法:" #: ../../howto/sorting.rst:284 msgid "" "However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" "meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`)." msgstr "" +"然而,需要注意如果沒有實作 :meth:`~object.__lt__`,則 ``<`` 會退而使用 :meth:" +"`~object.__gt__`\\ (參見 :func:`object.__lt__`)。" #: ../../howto/sorting.rst:287 msgid "" @@ -357,3 +388,5 @@ msgid "" "grades are stored in a dictionary, they can be used to sort a separate list " "of student names:" msgstr "" +"鍵函式不需要直接依賴用來排序的物件。鍵函式也可以存取外部資源,例如如果學生成" +"績儲存在字典裡,它可以用來排序一個單獨的學生姓名串列:" From cac59221299d910cd454d36fef3c77195580dc0f Mon Sep 17 00:00:00 2001 From: minghx Date: Tue, 15 Aug 2023 01:18:05 +0000 Subject: [PATCH 2/3] Refine translation of howto/sorting --- howto/sorting.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/howto/sorting.po b/howto/sorting.po index 99e0188bb3..1e352a48f1 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -249,8 +249,8 @@ msgid "" "items are compared; if they are the same then the second items are compared, " "and so on." msgstr "" -"這個方式會有效是因為元組是依照字典順序來比較;先比較第一個項目;如果一樣再比" -"較第二個項目,並依此類推。" +"這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較;先比較第" +"一個項目;如果一樣再比較第二個項目,並依此類推。" #: ../../howto/sorting.rst:212 msgid "" @@ -292,7 +292,7 @@ msgstr "" msgid "" "Now that Python sorting provides key-functions, this technique is not often " "needed." -msgstr "而因為 Python 的排序提供了鍵函式,已經不太常需要這個方法了。" +msgstr "而因為 Python 的排序提供了鍵函式,已經不太需要用到這個方法了。" #: ../../howto/sorting.rst:230 msgid "Comparison Functions" @@ -313,9 +313,9 @@ msgid "" "zero if the inputs are equal, or a positive value for greater-than." msgstr "" "例如\\ `天秤 `_\\ 比較兩邊樣本並給出相對的順序:較輕、相同、或較" +"Balance_à_tabac_1850.JPG>`_\\ 比較兩邊樣本並給出相對的順序:較輕、相同或較" "重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相" -"同、或正數代表大於。" +"同或正數代表大於。" #: ../../howto/sorting.rst:242 msgid "" @@ -325,7 +325,7 @@ msgid "" "function." msgstr "" "當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 " -"API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。" +"API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。" #: ../../howto/sorting.rst:246 msgid "" @@ -340,7 +340,7 @@ msgstr "" #: ../../howto/sorting.rst:253 msgid "Odds and Ends" -msgstr "零星雜事" +msgstr "雜項說明" #: ../../howto/sorting.rst:255 msgid "" @@ -351,7 +351,7 @@ msgid "" msgstr "" "要處理能理解本地語系 (locale aware) 的排序可以使用 :func:`locale.strxfrm` 當" "作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同" -"文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。" +"文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。" #: ../../howto/sorting.rst:260 msgid "" @@ -370,8 +370,8 @@ msgid "" "it is easy to add a standard sort order to a class by defining an :meth:" "`~object.__lt__` method:" msgstr "" -"排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入順序比較基準是簡單的," -"只要透過定義 :meth:`~object.__lt__` 方法:" +"排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入排序順序比較規則是簡單" +"的,只要透過定義 :meth:`~object.__lt__` 方法:" #: ../../howto/sorting.rst:284 msgid "" From df72690de9f64a181de740ef2af98218501b11fd Mon Sep 17 00:00:00 2001 From: minghx Date: Wed, 16 Aug 2023 06:14:32 +0000 Subject: [PATCH 3/3] Refine translation for howto/sorting --- howto/sorting.po | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/howto/sorting.po b/howto/sorting.po index 1e352a48f1..358468a15f 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -249,8 +249,8 @@ msgid "" "items are compared; if they are the same then the second items are compared, " "and so on." msgstr "" -"這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較;先比較第" -"一個項目;如果一樣再比較第二個項目,並依此類推。" +"這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較,先比較第" +"一個項目,如果一樣再比較第二個項目,並依此類推。" #: ../../howto/sorting.rst:212 msgid "" @@ -265,7 +265,7 @@ msgid "" "The sort is stable -- if two items have the same key, their order will be " "preserved in the sorted list." msgstr "" -"排序會是穩定的——如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順" +"排序會是穩定的 -- 如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順" "序。" #: ../../howto/sorting.rst:218 @@ -334,9 +334,7 @@ msgid "" "function::" msgstr "" "為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式," -"讓其可以當作鍵函式來使用:\n" -"\n" -"::" +"讓其可以當作鍵函式來使用: ::" #: ../../howto/sorting.rst:253 msgid "Odds and Ends"