-
-
Notifications
You must be signed in to change notification settings - Fork 214
Translate tutorial/controlflow.po #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
16e885a
134c413
441bf43
e136599
87af5af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,22 +6,22 @@ | |||||
# Liang-Bo Wang <me@liang2.tw>, 2015 | ||||||
# Liang-Bo Wang <me@liang2.tw>, 2016 | ||||||
# hsiao yi <hsiaoyi0504@gmail.com>, 2015 | ||||||
# Steven Hsu <hsuhaochun@gmail.com>, 2021 | ||||||
# Steven Hsu <hsuhaochun@gmail.com>, 2021-2022 | ||||||
msgid "" | ||||||
msgstr "" | ||||||
"Project-Id-Version: Python 3.10\n" | ||||||
"Report-Msgid-Bugs-To: \n" | ||||||
"POT-Creation-Date: 2022-06-22 00:18+0000\n" | ||||||
"PO-Revision-Date: 2021-06-01 22:43+0800\n" | ||||||
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n" | ||||||
"PO-Revision-Date: 2022-07-05 15:44+0800\n" | ||||||
"Last-Translator: Steven Hsu <hsuhaochun@gmail.com>\n" | ||||||
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" | ||||||
"tw)\n" | ||||||
"Language: zh_TW\n" | ||||||
"MIME-Version: 1.0\n" | ||||||
"Content-Type: text/plain; charset=UTF-8\n" | ||||||
"Content-Transfer-Encoding: 8bit\n" | ||||||
"Plural-Forms: nplurals=1; plural=0;\n" | ||||||
"X-Generator: Poedit 2.4.3\n" | ||||||
"X-Generator: Poedit 3.1\n" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:5 | ||||||
msgid "More Control Flow Tools" | ||||||
|
@@ -67,6 +67,8 @@ msgid "" | |||||
"specific types or attributes, you may also find the :keyword:`!match` " | ||||||
"statement useful. For more details see :ref:`tut-match`." | ||||||
msgstr "" | ||||||
"如果你要將同一個值與多個常數進行比較,或者檢查特定的型別或屬性,你可能會發" | ||||||
"現 :keyword:`!match` 陳述式也很有用。更多的細節,請參閱 :ref:`tut-match`。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:46 | ||||||
msgid ":keyword:`!for` Statements" | ||||||
|
@@ -295,28 +297,45 @@ msgid "" | |||||
"also extract components (sequence elements or object attributes) from the " | ||||||
"value into variables." | ||||||
msgstr "" | ||||||
":keyword:`match` 陳述式會拿取一個運算式,並將其值與多個連續的型樣 (pattern) " | ||||||
"進行比較,這些型樣是以一個或多個 case 區塊來表示。表面上,這類似 C、Java 或 " | ||||||
"JavaScript(以及許多其他語言)中的 switch 陳述式,但它與 Rust 或 Haskell 等語" | ||||||
"言中的型樣匹配 (pattern matching) 更為相近。只有第一個匹配成功的型樣會被執" | ||||||
"行,而它也可以將成分(序列元素或物件屬性)從值中提取到變數中。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:261 | ||||||
msgid "" | ||||||
"The simplest form compares a subject value against one or more literals::" | ||||||
msgstr "" | ||||||
"最簡單的形式,是將一個主題值 (subject value) 與一個或多個字面值 (literal) 進" | ||||||
"行比較:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:274 | ||||||
msgid "" | ||||||
"Note the last block: the \"variable name\" ``_`` acts as a *wildcard* and " | ||||||
"never fails to match. If no case matches, none of the branches is executed." | ||||||
msgstr "" | ||||||
"請注意最後一段:「變數名稱」\\ ``_`` 是作為\\ *通用字元*\\ 的角色,且永遠不會" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 補一下原文好了
Suggested change
|
||||||
"匹配失敗。如果沒有 case 匹配成功,則不會執行任何的分支。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:277 | ||||||
msgid "" | ||||||
"You can combine several literals in a single pattern using ``|`` (\"or\")::" | ||||||
msgstr "" | ||||||
"你可以使用 ``|``\\ (「或」)來將多個字面值組合在單一型樣中:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:282 | ||||||
msgid "" | ||||||
"Patterns can look like unpacking assignments, and can be used to bind " | ||||||
"variables::" | ||||||
msgstr "" | ||||||
"型樣可以看起來像是拆解賦值 (unpacking assignment),且可以用來連結變數:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:298 | ||||||
msgid "" | ||||||
|
@@ -327,13 +346,21 @@ msgid "" | |||||
"which makes it conceptually similar to the unpacking assignment ``(x, y) = " | ||||||
"point``." | ||||||
msgstr "" | ||||||
"請仔細研究那個例子!第一個型樣有兩個字面值,可以想作是之前所述的字面值型樣的" | ||||||
"延伸。但是接下來的兩個型樣結合了一個字面值和一個變數,且該變數\\ *連結*\\ 了" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: 既有翻譯大多譯作「繫結」
Suggested change
|
||||||
"來自主題 (``point``) 的一個值。第四個型樣會擷取兩個值,這使得它在概念上類似於" | ||||||
"拆解賦值 ``(x, y) = point``。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:305 | ||||||
msgid "" | ||||||
"If you are using classes to structure your data you can use the class name " | ||||||
"followed by an argument list resembling a constructor, but with the ability " | ||||||
"to capture attributes into variables::" | ||||||
msgstr "" | ||||||
"如果你要用 class 來結構化你的資料,你可以使用該 class 的名稱加上一個引數列" | ||||||
"表,類似一個建構式 (constructor),但它能夠將屬性擷取到變數中:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:326 | ||||||
msgid "" | ||||||
|
@@ -344,6 +371,12 @@ msgid "" | |||||
"\"y\"), the following patterns are all equivalent (and all bind the ``y`` " | ||||||
"attribute to the ``var`` variable)::" | ||||||
msgstr "" | ||||||
"你可以將位置參數 (positional parameter) 與一些能夠排序其屬性的內建 class(例" | ||||||
"如 dataclasses)一起使用。你也可以透過在 class 中設定特殊屬性 " | ||||||
"``__match_args__``,來定義型樣中屬性們的特定位置。如果它被設定為 (“x”, “y”)," | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"則以下的型樣都是等價的(且都會將屬性 ``y`` 連結到變數 ``var``):\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:337 | ||||||
msgid "" | ||||||
|
@@ -355,30 +388,46 @@ msgid "" | |||||
"(recognized by the \"(...)\" next to them like ``Point`` above) are never " | ||||||
"assigned to." | ||||||
msgstr "" | ||||||
"理解型樣的一種推薦方法,是將它們看作是你會放在賦值 (assignment) 左側內容的一" | ||||||
"種延伸形式,這樣就可以了解哪些變數會被設為何值。只有獨立的名稱(像是上面的 " | ||||||
"``var``)能被 match 陳述式賦值。點分隔名稱(如 ``foo.bar``)、屬性名稱(上面" | ||||||
"的 ``x=`` 及 ``y=``)或 class 名稱(由它們後面的 \"(...)\" 被辨識,如上面的 " | ||||||
"``Point``)則永遠無法被賦值。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:344 | ||||||
msgid "" | ||||||
"Patterns can be arbitrarily nested. For example, if we have a short list of " | ||||||
"points, we could match it like this::" | ||||||
msgstr "" | ||||||
"型樣可以任意地被巢套 (nested)。例如,如果我們有一個由某些點所組成的簡短 " | ||||||
"list,我們就可以像這樣來對它進行匹配:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:359 | ||||||
msgid "" | ||||||
"We can add an ``if`` clause to a pattern, known as a \"guard\". If the " | ||||||
"guard is false, ``match`` goes on to try the next case block. Note that " | ||||||
"value capture happens before the guard is evaluated::" | ||||||
msgstr "" | ||||||
"我們可以在型樣中加入一個 ``if`` 子句,稱為「防護 (guard)」。如果該防護為假," | ||||||
"則 ``match`` 會繼續嘗試下一個 case 區塊。請注意,值的擷取會發生在防護的評估之" | ||||||
"前:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:369 | ||||||
msgid "Several other key features of this statement:" | ||||||
msgstr "" | ||||||
msgstr "此種陳述式的其他幾個重要特色:" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:371 | ||||||
msgid "" | ||||||
"Like unpacking assignments, tuple and list patterns have exactly the same " | ||||||
"meaning and actually match arbitrary sequences. An important exception is " | ||||||
"that they don't match iterators or strings." | ||||||
msgstr "" | ||||||
"與拆解賦值的情況類似,tuple(元組)和 list 型樣具有完全相同的意義,而且實際上" | ||||||
"可以匹配任意的序列。一個重要的例外,是它們不能匹配疊代器 (iterator) 或字串。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:375 | ||||||
msgid "" | ||||||
|
@@ -387,6 +436,10 @@ msgid "" | |||||
"also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two items " | ||||||
"without binding the remaining items." | ||||||
msgstr "" | ||||||
"序列型樣 (sequence pattern) 可支援擴充拆解 (extended unpacking):\\ ``[x, y, " | ||||||
"*rest]`` 與 ``(x, y, *rest)`` 的作用類似於拆解賦值。\\ ``*`` 後面的名稱也可以" | ||||||
"是 ``_``,所以 ``(x, y, *_)`` 會匹配一個至少兩項的序列,且不會連結那兩項以外" | ||||||
"的其餘項。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:380 | ||||||
msgid "" | ||||||
|
@@ -395,34 +448,50 @@ msgid "" | |||||
"sequence patterns, extra keys are ignored. An unpacking like ``**rest`` is " | ||||||
"also supported. (But ``**_`` would be redundant, so it is not allowed.)" | ||||||
msgstr "" | ||||||
"映射型樣 (mapping pattern):\\ ``{\"bandwidth\": b, \"latency\": l}`` 能從一" | ||||||
"個 dictionary(字典)中擷取 ``\"bandwidth\"`` 及 ``\"latency\"`` 的值。與序列" | ||||||
"型樣不同,額外的鍵 (key) 會被忽略。一種像是 ``**rest`` 的拆解方式,也是可被支" | ||||||
"援的。(但 ``**_`` 則是多餘的做法,所以它並不被允許。)" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:385 | ||||||
msgid "Subpatterns may be captured using the ``as`` keyword::" | ||||||
msgstr "" | ||||||
"使用關鍵字 ``as`` 可以擷取子型樣 (subpattern):\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:389 | ||||||
msgid "" | ||||||
"will capture the second element of the input as ``p2`` (as long as the input " | ||||||
"is a sequence of two points)" | ||||||
msgstr "" | ||||||
"將會擷取輸入的第二個元素作為 ``p2``\\ (只要該輸入是一個由兩個點所組成的序" | ||||||
"列)。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:392 | ||||||
msgid "" | ||||||
"Most literals are compared by equality, however the singletons ``True``, " | ||||||
"``False`` and ``None`` are compared by identity." | ||||||
msgstr "" | ||||||
"大部分的字面值是藉由相等性 (equality) 來比較,但是單例物件 (singleton) " | ||||||
"``True``\\ 、\\ ``False`` 和 ``None`` 是藉由身份 (identity) 來比較。" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.python.org/zh-tw/3/library/functions.html#id
Suggested change
|
||||||
|
||||||
#: ../../tutorial/controlflow.rst:395 | ||||||
msgid "" | ||||||
"Patterns may use named constants. These must be dotted names to prevent " | ||||||
"them from being interpreted as capture variable::" | ||||||
msgstr "" | ||||||
"型樣可以使用附名常數 (named constant)。這些型樣必須是點分隔名稱,以免它們被解" | ||||||
"釋為擷取變數:\n" | ||||||
"\n" | ||||||
"::" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:414 | ||||||
msgid "" | ||||||
"For a more detailed explanation and additional examples, you can look into :" | ||||||
"pep:`636` which is written in a tutorial format." | ||||||
msgstr "" | ||||||
"關於更詳細的解釋和其他範例,你可以閱讀 :pep:`636`,它是以教學的格式編寫而成。" | ||||||
|
||||||
#: ../../tutorial/controlflow.rst:420 | ||||||
msgid "Defining Functions" | ||||||
|
@@ -1275,23 +1344,3 @@ msgstr "" | |||||
"實際上,\\ *傳址呼叫 (call by object reference)* 的說法可能較為貼切。因為,若" | ||||||
"傳遞的是一個可變物件時,呼叫者將看得見被呼叫者對物件做出的任何改變(例如被插" | ||||||
"入 list 內的新項目)。" | ||||||
|
||||||
#~ msgid "" | ||||||
#~ "If you need to modify the sequence you are iterating over while inside " | ||||||
#~ "the loop (for example to duplicate selected items), it is recommended " | ||||||
#~ "that you first make a copy. Iterating over a sequence does not " | ||||||
#~ "implicitly make a copy. The slice notation makes this especially " | ||||||
#~ "convenient::" | ||||||
#~ msgstr "" | ||||||
#~ "如果你在迴圈中需要修改一個你正在疊代的序列(例如重複一些選擇的元素),那麼" | ||||||
#~ "會建議你先建立一個序列的拷貝。疊代序列並不暗示建立新的拷貝。此時 slice 語" | ||||||
#~ "法就讓這件事十分容易完成:\n" | ||||||
#~ "\n" | ||||||
#~ "::" | ||||||
|
||||||
#~ msgid "" | ||||||
#~ "With ``for w in words:``, the example would attempt to create an infinite " | ||||||
#~ "list, inserting ``defenestrate`` over and over again." | ||||||
#~ msgstr "" | ||||||
#~ "在 ``for w in words:`` 的情況,這個例子會試著重覆不斷地插入 " | ||||||
#~ "``defenestrate``,產生一個無限長的 list。" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
還是比較希望 pattern 被翻成「模式」,感覺比較口語化?