6
6
# Liang-Bo Wang <me@liang2.tw>, 2015
7
7
# Liang-Bo Wang <me@liang2.tw>, 2016
8
8
# hsiao yi <hsiaoyi0504@gmail.com>, 2015
9
- # Steven Hsu <hsuhaochun@gmail.com>, 2021
9
+ # Steven Hsu <hsuhaochun@gmail.com>, 2021-2022
10
10
msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.10\n "
13
13
"Report-Msgid-Bugs-To : \n "
14
14
"POT-Creation-Date : 2022-03-09 00:12+0000\n "
15
- "PO-Revision-Date : 2021 -06-01 22:43 +0800\n "
16
- "Last-Translator : Adrian Liaw <adrianliaw2000 @gmail.com>\n "
15
+ "PO-Revision-Date : 2022 -06-09 02:11 +0800\n "
16
+ "Last-Translator : Steven Hsu <hsuhaochun @gmail.com>\n "
17
17
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
18
18
"tw)\n "
19
19
"Language : zh_TW\n "
20
20
"MIME-Version : 1.0\n "
21
21
"Content-Type : text/plain; charset=UTF-8\n "
22
22
"Content-Transfer-Encoding : 8bit\n "
23
23
"Plural-Forms : nplurals=1; plural=0;\n "
24
- "X-Generator : Poedit 2.4.3 \n "
24
+ "X-Generator : Poedit 3.1 \n "
25
25
26
26
#: ../../tutorial/controlflow.rst:5
27
27
msgid "More Control Flow Tools"
@@ -67,6 +67,8 @@ msgid ""
67
67
"specific types or attributes, you may also find the :keyword:`!match` "
68
68
"statement useful. For more details see :ref:`tut-match`."
69
69
msgstr ""
70
+ "如果你要將同一個值與多個常數進行比較,或者檢查特定的型別或屬性,你可能會發"
71
+ "現 :keyword:`!match` 陳述式也很有用。更多的細節,請參閱 :ref:`tut-match`。"
70
72
71
73
#: ../../tutorial/controlflow.rst:46
72
74
msgid ":keyword:`!for` Statements"
@@ -293,28 +295,44 @@ msgid ""
293
295
"languages), but it can also extract components (sequence elements or object "
294
296
"attributes) from the value into variables."
295
297
msgstr ""
298
+ ":keyword:`match` 陳述式會拿取一個運算式,並將其值與多個連續的型樣 (pattern) "
299
+ "進行比較,這些型樣是以一個或多個 case 區塊來表示。表面上,這類似 C、Java 或 "
300
+ "JavaScript(以及許多其他語言)中的 switch 陳述式,但它也可以將成分(序列元素"
301
+ "或物件屬性)從該值中提取到變數中。"
296
302
297
303
#: ../../tutorial/controlflow.rst:259
298
304
msgid ""
299
305
"The simplest form compares a subject value against one or more literals::"
300
306
msgstr ""
307
+ "最簡單的形式,是將一個主題值 (subject value) 與一個或多個字面值 (literal) 進"
308
+ "行比較:\n"
309
+ "\n"
310
+ "::"
301
311
302
312
#: ../../tutorial/controlflow.rst:272
303
313
msgid ""
304
314
"Note the last block: the \" variable name\" ``_`` acts as a *wildcard* and "
305
315
"never fails to match. If no case matches, none of the branches is executed."
306
316
msgstr ""
317
+ "請注意最後一段:「變數名稱」\\ ``_`` 是作為\\ *通用字元*\\ 的角色,且永遠不會"
318
+ "匹配失敗。如果沒有 case 匹配成功,則不會執行任何的分支。"
307
319
308
320
#: ../../tutorial/controlflow.rst:275
309
321
msgid ""
310
322
"You can combine several literals in a single pattern using ``|`` (\" or\" )::"
311
323
msgstr ""
324
+ "你可以使用 ``|``\\ (「或」)來將多個字面值組合在單一型樣中:\n"
325
+ "\n"
326
+ "::"
312
327
313
328
#: ../../tutorial/controlflow.rst:280
314
329
msgid ""
315
330
"Patterns can look like unpacking assignments, and can be used to bind "
316
331
"variables::"
317
332
msgstr ""
333
+ "型樣可以看起來像是拆解賦值 (unpacking assignment),且可以用來連結變數:\n"
334
+ "\n"
335
+ "::"
318
336
319
337
#: ../../tutorial/controlflow.rst:296
320
338
msgid ""
@@ -325,13 +343,21 @@ msgid ""
325
343
"which makes it conceptually similar to the unpacking assignment ``(x, y) = "
326
344
"point``."
327
345
msgstr ""
346
+ "請仔細研究那個例子!第一個型樣有兩個字面值,可以想作是之前所述的字面值型樣的"
347
+ "延伸。但是接下來的兩個型樣結合了一個字面值和一個變數,且該變數\\ *連結*\\ 了"
348
+ "來自主題 (``point``) 的一個值。第四個型樣會擷取兩個值,這使得它在概念上類似於"
349
+ "拆解賦值 ``(x, y) = point``。"
328
350
329
351
#: ../../tutorial/controlflow.rst:303
330
352
msgid ""
331
353
"If you are using classes to structure your data you can use the class name "
332
354
"followed by an argument list resembling a constructor, but with the ability "
333
355
"to capture attributes into variables::"
334
356
msgstr ""
357
+ "如果你要用 class 來結構化你的資料,你可以使用該 class 的名稱加上一個引數列"
358
+ "表,類似一個建構式 (constructor),但它能夠將屬性擷取到變數中:\n"
359
+ "\n"
360
+ "::"
335
361
336
362
#: ../../tutorial/controlflow.rst:324
337
363
msgid ""
@@ -342,6 +368,12 @@ msgid ""
342
368
"\" y\" ), the following patterns are all equivalent (and all bind the ``y`` "
343
369
"attribute to the ``var`` variable)::"
344
370
msgstr ""
371
+ "你可以將位置參數 (positional parameter) 與一些能夠排序其屬性的內建 class(例"
372
+ "如 dataclasses)一起使用。你也可以透過在 class 中設定特殊屬性 "
373
+ "``__match_args__``,來定義型樣中屬性們的特定位置。如果它被設定為 (“x”, “y”),"
374
+ "則以下的型樣都是等價的(且都會將屬性 ``y`` 連結到變數 ``var``):\n"
375
+ "\n"
376
+ "::"
345
377
346
378
#: ../../tutorial/controlflow.rst:335
347
379
msgid ""
@@ -353,30 +385,46 @@ msgid ""
353
385
"(recognized by the \" (...)\" next to them like ``Point`` above) are never "
354
386
"assigned to."
355
387
msgstr ""
388
+ "理解型樣的一種推薦方法,是將它們看作是你會放在賦值 (assignment) 左側內容的一"
389
+ "種延伸形式,這樣就可以了解哪些變數會被設為何值。只有獨立的名稱(像是上面的 "
390
+ "``var``)能被 match 陳述式賦值。點分隔名稱(如 ``foo.bar``)、屬性名稱(上面"
391
+ "的 ``x=`` 及 ``y=``)或 class 名稱(由它們後面的 \" (...)\" 被辨識,如上面的 "
392
+ "``Point``)則永遠無法被賦值。"
356
393
357
394
#: ../../tutorial/controlflow.rst:342
358
395
msgid ""
359
396
"Patterns can be arbitrarily nested. For example, if we have a short list of "
360
397
"points, we could match it like this::"
361
398
msgstr ""
399
+ "型樣可以任意地被巢套 (nested)。例如,如果我們有一個由某些點所組成的簡短 "
400
+ "list,我們就可以像這樣來對它進行匹配:\n"
401
+ "\n"
402
+ "::"
362
403
363
404
#: ../../tutorial/controlflow.rst:357
364
405
msgid ""
365
406
"We can add an ``if`` clause to a pattern, known as a \" guard\" . If the "
366
407
"guard is false, ``match`` goes on to try the next case block. Note that "
367
408
"value capture happens before the guard is evaluated::"
368
409
msgstr ""
410
+ "我們可以在型樣中加入一個 ``if`` 子句,稱為「防護 (guard)」。如果該防護為假,"
411
+ "則 ``match`` 會繼續嘗試下一個 case 區塊。請注意,值的擷取會發生在防護的評估之"
412
+ "前:\n"
413
+ "\n"
414
+ "::"
369
415
370
416
#: ../../tutorial/controlflow.rst:367
371
417
msgid "Several other key features of this statement:"
372
- msgstr ""
418
+ msgstr "此種陳述式的其他幾個重要特色: "
373
419
374
420
#: ../../tutorial/controlflow.rst:369
375
421
msgid ""
376
422
"Like unpacking assignments, tuple and list patterns have exactly the same "
377
423
"meaning and actually match arbitrary sequences. An important exception is "
378
424
"that they don't match iterators or strings."
379
425
msgstr ""
426
+ "與拆解賦值的情況類似,tuple(元組)和 list 型樣具有完全相同的意義,而且實際上"
427
+ "可以匹配任意的序列。一個重要的例外,是它們不能匹配疊代器 (iterator) 或字串。"
380
428
381
429
#: ../../tutorial/controlflow.rst:373
382
430
msgid ""
@@ -385,6 +433,10 @@ msgid ""
385
433
"also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two items "
386
434
"without binding the remaining items."
387
435
msgstr ""
436
+ "序列型樣 (sequence pattern) 可支援擴充拆解 (extended unpacking):\\ ``[x, y, "
437
+ "*rest]`` 與 ``(x, y, *rest)`` 的作用類似於拆解賦值。\\ ``*`` 後面的名稱也可以"
438
+ "是 ``_``,所以 ``(x, y, *_)`` 會匹配一個至少兩項的序列,且不會連結那兩項以外"
439
+ "的其餘項。"
388
440
389
441
#: ../../tutorial/controlflow.rst:378
390
442
msgid ""
@@ -393,34 +445,51 @@ msgid ""
393
445
"sequence patterns, extra keys are ignored. An unpacking like ``**rest`` is "
394
446
"also supported. (But ``**_`` would be redundant, so it is not allowed.)"
395
447
msgstr ""
448
+ "映射型樣 (mapping pattern):\\ ``{\" bandwidth\" : b, \" latency\" : l}`` 能從一"
449
+ "個 dictionary(字典)中擷取 ``\" bandwidth\" `` 及 ``\" latency\" `` 的值。與序列"
450
+ "型樣不同,額外的鍵 (key) 會被忽略。一種像是 ``**rest`` 的拆解方式,也是可被支"
451
+ "援的。(但 ``**_`` 則是多餘的做法,所以它並不被允許。)"
396
452
397
453
#: ../../tutorial/controlflow.rst:383
398
454
msgid "Subpatterns may be captured using the ``as`` keyword::"
399
455
msgstr ""
456
+ "使用關鍵字 ``as`` 可以擷取子型樣 (subpattern):\n"
457
+ "\n"
458
+ "::"
400
459
401
460
#: ../../tutorial/controlflow.rst:387
402
461
msgid ""
403
462
"will capture the second element of the input as ``p2`` (as long as the input "
404
463
"is a sequence of two points)"
405
464
msgstr ""
465
+ "將會擷取輸入的第二個元素作為 ``p2``\\ (只要該輸入是一個由兩個點所組成的序"
466
+ "列)。"
406
467
407
468
#: ../../tutorial/controlflow.rst:390
408
469
msgid ""
409
470
"Most literals are compared by equality, however the singletons ``True``, "
410
471
"``False`` and ``None`` are compared by identity."
411
472
msgstr ""
473
+ "大部分的字面值是藉由相等性 (equality) 來比較,但是單例物件 (singleton) "
474
+ "``True``\\ 、\\ ``False`` 和 ``None`` 是藉由身份 (identity) 來比較。"
412
475
413
476
#: ../../tutorial/controlflow.rst:393
414
477
msgid ""
415
478
"Patterns may use named constants. These must be dotted names to prevent "
416
479
"them from being interpreted as capture variable::"
417
480
msgstr ""
481
+ "型樣可以使用附名常數 (named constant)。這些型樣必須是點分隔名稱,以免它們被解"
482
+ "釋為擷取變數:\n"
483
+ "\n"
484
+ "::"
418
485
419
486
#: ../../tutorial/controlflow.rst:412
420
487
msgid ""
421
488
"For a more detailed explanation and additional examples, you can look into :"
422
489
"pep:`636` which is written in a tutorial format."
423
490
msgstr ""
491
+ "關於更詳細的解釋和其他範例,你可以閱讀 :pep:`636`\\ ,它是以教學的格式編寫而"
492
+ "成。"
424
493
425
494
#: ../../tutorial/controlflow.rst:418
426
495
msgid "Defining Functions"
@@ -996,10 +1065,9 @@ msgid ""
996
1065
"``*args`` parameter are 'keyword-only' arguments, meaning that they can only "
997
1066
"be used as keywords rather than positional arguments. ::"
998
1067
msgstr ""
999
- "通常,這些 *variadic*\\ (可變的)引數會出現在參數列表的最末端,這樣它們就"
1000
- "可以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的任何參"
1001
- "數必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作位置引"
1002
- "數。\n"
1068
+ "通常,這些 *variadic*\\ (可變的)引數會出現在參數列表的最末端,這樣它們就可"
1069
+ "以把所有傳遞給函式的剩餘輸入引數都撈起來。出現在 ``*args`` 參數後面的任何參數"
1070
+ "必須是「僅限關鍵字」引數,意即它們只能作為關鍵字引數,而不能用作位置引數。\n"
1003
1071
"\n"
1004
1072
"::"
1005
1073
0 commit comments