Skip to content

Commit 16e885a

Browse files
StevenHsuYLmattwang44
authored andcommitted
translate match statement
in tutorial/controlflow.po
1 parent 453e0c1 commit 16e885a

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

tutorial/controlflow.po

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
# Liang-Bo Wang <me@liang2.tw>, 2015
77
# Liang-Bo Wang <me@liang2.tw>, 2016
88
# hsiao yi <hsiaoyi0504@gmail.com>, 2015
9-
# Steven Hsu <hsuhaochun@gmail.com>, 2021
9+
# Steven Hsu <hsuhaochun@gmail.com>, 2021-2022
1010
msgid ""
1111
msgstr ""
1212
"Project-Id-Version: Python 3.10\n"
1313
"Report-Msgid-Bugs-To: \n"
14-
"POT-Creation-Date: 2022-06-22 00:18+0000\n"
15-
"PO-Revision-Date: 2021-06-01 22:43+0800\n"
16-
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
14+
"POT-Creation-Date: 2022-03-09 00:12+0000\n"
15+
"PO-Revision-Date: 2022-06-09 02:11+0800\n"
16+
"Last-Translator: Steven Hsu <hsuhaochun@gmail.com>\n"
1717
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1818
"tw)\n"
1919
"Language: zh_TW\n"
2020
"MIME-Version: 1.0\n"
2121
"Content-Type: text/plain; charset=UTF-8\n"
2222
"Content-Transfer-Encoding: 8bit\n"
2323
"Plural-Forms: nplurals=1; plural=0;\n"
24-
"X-Generator: Poedit 2.4.3\n"
24+
"X-Generator: Poedit 3.1\n"
2525

2626
#: ../../tutorial/controlflow.rst:5
2727
msgid "More Control Flow Tools"
@@ -67,6 +67,8 @@ msgid ""
6767
"specific types or attributes, you may also find the :keyword:`!match` "
6868
"statement useful. For more details see :ref:`tut-match`."
6969
msgstr ""
70+
"如果你要將同一個值與多個常數進行比較,或者檢查特定的型別或屬性,你可能會發"
71+
"現 :keyword:`!match` 陳述式也很有用。更多的細節,請參閱 :ref:`tut-match`。"
7072

7173
#: ../../tutorial/controlflow.rst:46
7274
msgid ":keyword:`!for` Statements"
@@ -295,28 +297,44 @@ msgid ""
295297
"also extract components (sequence elements or object attributes) from the "
296298
"value into variables."
297299
msgstr ""
300+
":keyword:`match` 陳述式會拿取一個運算式,並將其值與多個連續的型樣 (pattern) "
301+
"進行比較,這些型樣是以一個或多個 case 區塊來表示。表面上,這類似 C、Java 或 "
302+
"JavaScript(以及許多其他語言)中的 switch 陳述式,但它也可以將成分(序列元素"
303+
"或物件屬性)從該值中提取到變數中。"
298304

299305
#: ../../tutorial/controlflow.rst:261
300306
msgid ""
301307
"The simplest form compares a subject value against one or more literals::"
302308
msgstr ""
309+
"最簡單的形式,是將一個主題值 (subject value) 與一個或多個字面值 (literal) 進"
310+
"行比較:\n"
311+
"\n"
312+
"::"
303313

304314
#: ../../tutorial/controlflow.rst:274
305315
msgid ""
306316
"Note the last block: the \"variable name\" ``_`` acts as a *wildcard* and "
307317
"never fails to match. If no case matches, none of the branches is executed."
308318
msgstr ""
319+
"請注意最後一段:「變數名稱」\\ ``_`` 是作為\\ *通用字元*\\ 的角色,且永遠不會"
320+
"匹配失敗。如果沒有 case 匹配成功,則不會執行任何的分支。"
309321

310322
#: ../../tutorial/controlflow.rst:277
311323
msgid ""
312324
"You can combine several literals in a single pattern using ``|`` (\"or\")::"
313325
msgstr ""
326+
"你可以使用 ``|``\\ (「或」)來將多個字面值組合在單一型樣中:\n"
327+
"\n"
328+
"::"
314329

315330
#: ../../tutorial/controlflow.rst:282
316331
msgid ""
317332
"Patterns can look like unpacking assignments, and can be used to bind "
318333
"variables::"
319334
msgstr ""
335+
"型樣可以看起來像是拆解賦值 (unpacking assignment),且可以用來連結變數:\n"
336+
"\n"
337+
"::"
320338

321339
#: ../../tutorial/controlflow.rst:298
322340
msgid ""
@@ -327,13 +345,21 @@ msgid ""
327345
"which makes it conceptually similar to the unpacking assignment ``(x, y) = "
328346
"point``."
329347
msgstr ""
348+
"請仔細研究那個例子!第一個型樣有兩個字面值,可以想作是之前所述的字面值型樣的"
349+
"延伸。但是接下來的兩個型樣結合了一個字面值和一個變數,且該變數\\ *連結*\\ 了"
350+
"來自主題 (``point``) 的一個值。第四個型樣會擷取兩個值,這使得它在概念上類似於"
351+
"拆解賦值 ``(x, y) = point``。"
330352

331353
#: ../../tutorial/controlflow.rst:305
332354
msgid ""
333355
"If you are using classes to structure your data you can use the class name "
334356
"followed by an argument list resembling a constructor, but with the ability "
335357
"to capture attributes into variables::"
336358
msgstr ""
359+
"如果你要用 class 來結構化你的資料,你可以使用該 class 的名稱加上一個引數列"
360+
"表,類似一個建構式 (constructor),但它能夠將屬性擷取到變數中:\n"
361+
"\n"
362+
"::"
337363

338364
#: ../../tutorial/controlflow.rst:326
339365
msgid ""
@@ -344,6 +370,12 @@ msgid ""
344370
"\"y\"), the following patterns are all equivalent (and all bind the ``y`` "
345371
"attribute to the ``var`` variable)::"
346372
msgstr ""
373+
"你可以將位置參數 (positional parameter) 與一些能夠排序其屬性的內建 class(例"
374+
"如 dataclasses)一起使用。你也可以透過在 class 中設定特殊屬性 "
375+
"``__match_args__``,來定義型樣中屬性們的特定位置。如果它被設定為 (“x”, “y”),"
376+
"則以下的型樣都是等價的(且都會將屬性 ``y`` 連結到變數 ``var``):\n"
377+
"\n"
378+
"::"
347379

348380
#: ../../tutorial/controlflow.rst:337
349381
msgid ""
@@ -355,30 +387,46 @@ msgid ""
355387
"(recognized by the \"(...)\" next to them like ``Point`` above) are never "
356388
"assigned to."
357389
msgstr ""
390+
"理解型樣的一種推薦方法,是將它們看作是你會放在賦值 (assignment) 左側內容的一"
391+
"種延伸形式,這樣就可以了解哪些變數會被設為何值。只有獨立的名稱(像是上面的 "
392+
"``var``)能被 match 陳述式賦值。點分隔名稱(如 ``foo.bar``)、屬性名稱(上面"
393+
"的 ``x=`` 及 ``y=``)或 class 名稱(由它們後面的 \"(...)\" 被辨識,如上面的 "
394+
"``Point``)則永遠無法被賦值。"
358395

359396
#: ../../tutorial/controlflow.rst:344
360397
msgid ""
361398
"Patterns can be arbitrarily nested. For example, if we have a short list of "
362399
"points, we could match it like this::"
363400
msgstr ""
401+
"型樣可以任意地被巢套 (nested)。例如,如果我們有一個由某些點所組成的簡短 "
402+
"list,我們就可以像這樣來對它進行匹配:\n"
403+
"\n"
404+
"::"
364405

365406
#: ../../tutorial/controlflow.rst:359
366407
msgid ""
367408
"We can add an ``if`` clause to a pattern, known as a \"guard\". If the "
368409
"guard is false, ``match`` goes on to try the next case block. Note that "
369410
"value capture happens before the guard is evaluated::"
370411
msgstr ""
412+
"我們可以在型樣中加入一個 ``if`` 子句,稱為「防護 (guard)」。如果該防護為假,"
413+
"則 ``match`` 會繼續嘗試下一個 case 區塊。請注意,值的擷取會發生在防護的評估之"
414+
"前:\n"
415+
"\n"
416+
"::"
371417

372418
#: ../../tutorial/controlflow.rst:369
373419
msgid "Several other key features of this statement:"
374-
msgstr ""
420+
msgstr "此種陳述式的其他幾個重要特色:"
375421

376422
#: ../../tutorial/controlflow.rst:371
377423
msgid ""
378424
"Like unpacking assignments, tuple and list patterns have exactly the same "
379425
"meaning and actually match arbitrary sequences. An important exception is "
380426
"that they don't match iterators or strings."
381427
msgstr ""
428+
"與拆解賦值的情況類似,tuple(元組)和 list 型樣具有完全相同的意義,而且實際上"
429+
"可以匹配任意的序列。一個重要的例外,是它們不能匹配疊代器 (iterator) 或字串。"
382430

383431
#: ../../tutorial/controlflow.rst:375
384432
msgid ""
@@ -387,6 +435,10 @@ msgid ""
387435
"also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two items "
388436
"without binding the remaining items."
389437
msgstr ""
438+
"序列型樣 (sequence pattern) 可支援擴充拆解 (extended unpacking):\\ ``[x, y, "
439+
"*rest]`` 與 ``(x, y, *rest)`` 的作用類似於拆解賦值。\\ ``*`` 後面的名稱也可以"
440+
"是 ``_``,所以 ``(x, y, *_)`` 會匹配一個至少兩項的序列,且不會連結那兩項以外"
441+
"的其餘項。"
390442

391443
#: ../../tutorial/controlflow.rst:380
392444
msgid ""
@@ -395,34 +447,51 @@ msgid ""
395447
"sequence patterns, extra keys are ignored. An unpacking like ``**rest`` is "
396448
"also supported. (But ``**_`` would be redundant, so it is not allowed.)"
397449
msgstr ""
450+
"映射型樣 (mapping pattern):\\ ``{\"bandwidth\": b, \"latency\": l}`` 能從一"
451+
"個 dictionary(字典)中擷取 ``\"bandwidth\"`` 及 ``\"latency\"`` 的值。與序列"
452+
"型樣不同,額外的鍵 (key) 會被忽略。一種像是 ``**rest`` 的拆解方式,也是可被支"
453+
"援的。(但 ``**_`` 則是多餘的做法,所以它並不被允許。)"
398454

399455
#: ../../tutorial/controlflow.rst:385
400456
msgid "Subpatterns may be captured using the ``as`` keyword::"
401457
msgstr ""
458+
"使用關鍵字 ``as`` 可以擷取子型樣 (subpattern):\n"
459+
"\n"
460+
"::"
402461

403462
#: ../../tutorial/controlflow.rst:389
404463
msgid ""
405464
"will capture the second element of the input as ``p2`` (as long as the input "
406465
"is a sequence of two points)"
407466
msgstr ""
467+
"將會擷取輸入的第二個元素作為 ``p2``\\ (只要該輸入是一個由兩個點所組成的序"
468+
"列)。"
408469

409470
#: ../../tutorial/controlflow.rst:392
410471
msgid ""
411472
"Most literals are compared by equality, however the singletons ``True``, "
412473
"``False`` and ``None`` are compared by identity."
413474
msgstr ""
475+
"大部分的字面值是藉由相等性 (equality) 來比較,但是單例物件 (singleton) "
476+
"``True``\\\\ ``False`` 和 ``None`` 是藉由身份 (identity) 來比較。"
414477

415478
#: ../../tutorial/controlflow.rst:395
416479
msgid ""
417480
"Patterns may use named constants. These must be dotted names to prevent "
418481
"them from being interpreted as capture variable::"
419482
msgstr ""
483+
"型樣可以使用附名常數 (named constant)。這些型樣必須是點分隔名稱,以免它們被解"
484+
"釋為擷取變數:\n"
485+
"\n"
486+
"::"
420487

421488
#: ../../tutorial/controlflow.rst:414
422489
msgid ""
423490
"For a more detailed explanation and additional examples, you can look into :"
424491
"pep:`636` which is written in a tutorial format."
425492
msgstr ""
493+
"關於更詳細的解釋和其他範例,你可以閱讀 :pep:`636`\\ ,它是以教學的格式編寫而"
494+
"成。"
426495

427496
#: ../../tutorial/controlflow.rst:420
428497
msgid "Defining Functions"

0 commit comments

Comments
 (0)