Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a5b23f

Browse files
Complete translation of all tutorial .po files (#1114)
Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com>Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>Co-authored-by: W. H. Wang <mattwang44@gmail.com>
1 parent75e9a91 commit0a5b23f

File tree

9 files changed

+510
-10
lines changed

9 files changed

+510
-10
lines changed

‎tutorial/classes.po

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,28 @@ msgid ""
375375
"scope_test()\n"
376376
"print(\"In global scope:\", spam)"
377377
msgstr""
378+
"def scope_test():\n"
379+
" def do_local():\n"
380+
" spam =\"local spam\"\n"
381+
"\n"
382+
" def do_nonlocal():\n"
383+
" nonlocal spam\n"
384+
" spam =\"nonlocal spam\"\n"
385+
"\n"
386+
" def do_global():\n"
387+
" global spam\n"
388+
" spam =\"global spam\"\n"
389+
"\n"
390+
" spam =\"test spam\"\n"
391+
" do_local()\n"
392+
" print(\"After local assignment:\", spam)\n"
393+
" do_nonlocal()\n"
394+
" print(\"After nonlocal assignment:\", spam)\n"
395+
" do_global()\n"
396+
" print(\"After global assignment:\", spam)\n"
397+
"\n"
398+
"scope_test()\n"
399+
"print(\"In global scope:\", spam)"
378400

379401
#:../../tutorial/classes.rst:191
380402
msgid"The output of the example code is:"
@@ -387,6 +409,10 @@ msgid ""
387409
"After global assignment: nonlocal spam\n"
388410
"In global scope: global spam"
389411
msgstr""
412+
"After local assignment: test spam\n"
413+
"After nonlocal assignment: nonlocal spam\n"
414+
"After global assignment: nonlocal spam\n"
415+
"In global scope: global spam"
390416

391417
#:../../tutorial/classes.rst:200
392418
msgid""
@@ -665,6 +691,7 @@ msgid ""
665691
"The other kind of instance attribute reference is a *method*. A method is a "
666692
"function that\"belongs to\" an object."
667693
msgstr""
694+
"另一種執行個體屬性參考是 *方法* (method)。方法是\"屬於\"一個物件的函式。"
668695

669696
#:../../tutorial/classes.rst:345
670697
msgid""
@@ -795,6 +822,23 @@ msgid ""
795822
">>> e.name # unique to e\n"
796823
"'Buddy'"
797824
msgstr""
825+
"class Dog:\n"
826+
"\n"
827+
" kind = 'canine' # 所有實例共享的類別變數\n"
828+
"\n"
829+
" def __init__(self, name):\n"
830+
" self.name = name # 每個實例獨有的實例變數\n"
831+
"\n"
832+
">>> d = Dog('Fido')\n"
833+
">>> e = Dog('Buddy')\n"
834+
">>> d.kind # 為所有 Dog 實例所共享\n"
835+
"'canine'\n"
836+
">>> e.kind # 為所有 Dog 實例所共享\n"
837+
"'canine'\n"
838+
">>> d.name # d 獨有\n"
839+
"'Fido'\n"
840+
">>> e.name # e 獨有\n"
841+
"'Buddy'"
798842

799843
#:../../tutorial/classes.rst:422
800844
msgid""
@@ -1363,6 +1407,24 @@ msgid ""
13631407
" for item in zip(keys, values):\n"
13641408
" self.items_list.append(item)"
13651409
msgstr""
1410+
"class Mapping:\n"
1411+
" def __init__(self, iterable):\n"
1412+
" self.items_list = []\n"
1413+
" self.__update(iterable)\n"
1414+
"\n"
1415+
" def update(self, iterable):\n"
1416+
" for item in iterable:\n"
1417+
" self.items_list.append(item)\n"
1418+
"\n"
1419+
" __update = update # 原始 update() 方法的私有副本\n"
1420+
"\n"
1421+
"class MappingSubclass(Mapping):\n"
1422+
"\n"
1423+
" def update(self, keys, values):\n"
1424+
" # 為 update() 提供新的函式簽名\n"
1425+
" # 但不會破壞 __init__()\n"
1426+
" for item in zip(keys, values):\n"
1427+
" self.items_list.append(item)"
13661428

13671429
#:../../tutorial/classes.rst:718
13681430
msgid""
@@ -1592,6 +1654,20 @@ msgid ""
15921654
" self.index = self.index - 1\n"
15931655
" return self.data[self.index]"
15941656
msgstr""
1657+
"class Reverse:\n"
1658+
"\"\"\"用於向後迴圈遍歷序列的疊代器。\"\"\"\n"
1659+
" def __init__(self, data):\n"
1660+
" self.data = data\n"
1661+
" self.index = len(data)\n"
1662+
"\n"
1663+
" def __iter__(self):\n"
1664+
" return self\n"
1665+
"\n"
1666+
" def __next__(self):\n"
1667+
" if self.index == 0:\n"
1668+
" raise StopIteration\n"
1669+
" self.index = self.index - 1\n"
1670+
" return self.data[self.index]"
15951671

15961672
#:../../tutorial/classes.rst:845
15971673
msgid""
@@ -1737,6 +1813,22 @@ msgid ""
17371813
">>> list(data[i] for i in range(len(data)-1, -1, -1))\n"
17381814
"['f', 'l', 'o', 'g']"
17391815
msgstr""
1816+
">>> sum(i*i for i in range(10)) # 平方和\n"
1817+
"285\n"
1818+
"\n"
1819+
">>> xvec = [10, 20, 30]\n"
1820+
">>> yvec = [7, 5, 3]\n"
1821+
">>> sum(x*y for x,y in zip(xvec, yvec)) # 向量內積\n"
1822+
"260\n"
1823+
"\n"
1824+
">>> unique_words = set(word for line in page for word in line.split())\n"
1825+
"\n"
1826+
">>> valedictorian = max((student.gpa, student.name) for student in "
1827+
"graduates)\n"
1828+
"\n"
1829+
">>> data = 'golf'\n"
1830+
">>> list(data[i] for i in range(len(data)-1, -1, -1))\n"
1831+
"['f', 'l', 'o', 'g']"
17401832

17411833
#:../../tutorial/classes.rst:932
17421834
msgid"Footnotes"

‎tutorial/controlflow.po

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ msgid ""
5959
"...\n"
6060
"More"
6161
msgstr""
62+
">>> x = int(input(\"Please enter an integer:\"))\n"
63+
"Please enter an integer: 42\n"
64+
">>> if x < 0:\n"
65+
"... x = 0\n"
66+
"... print('Negative changed to zero')\n"
67+
"... elif x == 0:\n"
68+
"... print('Zero')\n"
69+
"... elif x == 1:\n"
70+
"... print('Single')\n"
71+
"... else:\n"
72+
"... print('More')\n"
73+
"...\n"
74+
"More"
6275

6376
#:../../tutorial/controlflow.rst:33
6477
msgid""
@@ -112,6 +125,14 @@ msgid ""
112125
"window 6\n"
113126
"defenestrate 12"
114127
msgstr""
128+
">>> # 測量一些字串:\n"
129+
">>> words = ['cat', 'window', 'defenestrate']\n"
130+
">>> for w in words:\n"
131+
"... print(w, len(w))\n"
132+
"...\n"
133+
"cat 3\n"
134+
"window 6\n"
135+
"defenestrate 12"
115136

116137
#:../../tutorial/controlflow.rst:72
117138
msgid""
@@ -138,6 +159,19 @@ msgid ""
138159
" if status == 'active':\n"
139160
" active_users[user] = status"
140161
msgstr""
162+
"# 建立一個範例集合\n"
163+
"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n"
164+
"\n"
165+
"# 策略:對副本進行疊代\n"
166+
"for user, status in users.copy().items():\n"
167+
" if status == 'inactive':\n"
168+
" del users[user]\n"
169+
"\n"
170+
"# 策略:建立一個新集合\n"
171+
"active_users = {}\n"
172+
"for user, status in users.items():\n"
173+
" if status == 'active':\n"
174+
" active_users[user] = status"
141175

142176
#:../../tutorial/controlflow.rst:94
143177
msgid"The :func:`range` Function"
@@ -376,6 +410,9 @@ msgid ""
376410
"finishes without executing the :keyword:`!break`, the :keyword:`!else` "
377411
"clause executes."
378412
msgstr""
413+
"在 :keyword:`!for` 或 :keyword:`!while` 迴圈中,:keyword:`!break` "
414+
"陳述句可能與 :keyword:`!else` 子句配對。如果迴圈完成而沒有執行 "
415+
":keyword:`!break`,:keyword:`!else` 子句會被執行。"
379416

380417
#:../../tutorial/controlflow.rst:208
381418
msgid""
@@ -427,6 +464,23 @@ msgid ""
427464
"8 equals 2 * 4\n"
428465
"9 equals 3 * 3"
429466
msgstr""
467+
">>> for n in range(2, 10):\n"
468+
"... for x in range(2, n):\n"
469+
"... if n % x == 0:\n"
470+
"... print(n, 'equals', x, '*', n//x)\n"
471+
"... break\n"
472+
"... else:\n"
473+
"... # 迴圈結束但沒有找到因數\n"
474+
"... print(n, 'is a prime number')\n"
475+
"...\n"
476+
"2 is a prime number\n"
477+
"3 is a prime number\n"
478+
"4 equals 2 * 2\n"
479+
"5 is a prime number\n"
480+
"6 equals 2 * 3\n"
481+
"7 is a prime number\n"
482+
"8 equals 2 * 4\n"
483+
"9 equals 3 * 3"
430484

431485
#:../../tutorial/controlflow.rst:239
432486
msgid""
@@ -444,6 +498,9 @@ msgid ""
444498
"condition is ever true, a ``break`` will happen. If the condition is never "
445499
"true, the ``else`` clause outside the loop will execute."
446500
msgstr""
501+
"理解 else 子句的一個方法是將它想像成與迴圈內的 ``if`` 配對。當迴圈執行時,它會"
502+
"運行如 if/if/if/else 的序列。``if`` 在迴圈內,會遇到多次。如果條件曾經為真,"
503+
"``break`` 就會發生。如果條件從未為真,迴圈外的 ``else`` 子句就會執行。"
447504

448505
#:../../tutorial/controlflow.rst:248
449506
msgid""
@@ -478,6 +535,9 @@ msgid ""
478535
"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n"
479536
"..."
480537
msgstr""
538+
">>> while True:\n"
539+
"... pass # 忙碌等待鍵盤中斷 (Ctrl+C)\n"
540+
"..."
481541

482542
#:../../tutorial/controlflow.rst:266
483543
msgid"This is commonly used for creating minimal classes::"
@@ -509,6 +569,9 @@ msgid ""
509569
"... pass # Remember to implement this!\n"
510570
"..."
511571
msgstr""
572+
">>> def initlog(*args):\n"
573+
"... pass # 記得要實作這個!\n"
574+
"..."
512575

513576
#:../../tutorial/controlflow.rst:284
514577
msgid":keyword:`!match` Statements"
@@ -604,6 +667,18 @@ msgid ""
604667
" case _:\n"
605668
" raise ValueError(\"Not a point\")"
606669
msgstr""
670+
"# point 是一個 (x, y) 元組\n"
671+
"match point:\n"
672+
" case (0, 0):\n"
673+
" print(\"Origin\")\n"
674+
" case (0, y):\n"
675+
" print(f\"Y={y}\")\n"
676+
" case (x, 0):\n"
677+
" print(f\"X={x}\")\n"
678+
" case (x, y):\n"
679+
" print(f\"X={x}, Y={y}\")\n"
680+
" case _:\n"
681+
" raise ValueError(\"Not a point\")"
607682

608683
#:../../tutorial/controlflow.rst:331
609684
msgid""
@@ -912,6 +987,17 @@ msgid ""
912987
">>> fib(2000)\n"
913988
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"
914989
msgstr""
990+
">>> def fib(n): # 寫出小於 n 的費氏數列\n"
991+
"...\"\"\"印出小於 n 的費氏數列。\"\"\"\n"
992+
"... a, b = 0, 1\n"
993+
"... while a < n:\n"
994+
"... print(a, end=' ')\n"
995+
"... a, b = b, a+b\n"
996+
"... print()\n"
997+
"...\n"
998+
">>> # 現在呼叫我們剛才定義的函式:\n"
999+
">>> fib(2000)\n"
1000+
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"
9151001

9161002
#:../../tutorial/controlflow.rst:482
9171003
msgid""
@@ -1045,6 +1131,18 @@ msgid ""
10451131
">>> f100 # write the result\n"
10461132
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"
10471133
msgstr""
1134+
">>> def fib2(n): # 回傳到 n 為止的費氏數列\n"
1135+
"...\"\"\"回傳包含到 n 為止的費氏數列的串列。\"\"\"\n"
1136+
"... result = []\n"
1137+
"... a, b = 0, 1\n"
1138+
"... while a < n:\n"
1139+
"... result.append(a) # 見下方\n"
1140+
"... a, b = b, a+b\n"
1141+
"... return result\n"
1142+
"...\n"
1143+
">>> f100 = fib2(100) # 呼叫它\n"
1144+
">>> f100 # 寫出結果\n"
1145+
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"
10481146

10491147
#:../../tutorial/controlflow.rst:550
10501148
msgid"This example, as usual, demonstrates some new Python features:"
@@ -1301,6 +1399,12 @@ msgid ""
13011399
"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 "
13021400
"keyword"
13031401
msgstr""
1402+
"parrot(1000) # 1 個位置引數\n"
1403+
"parrot(voltage=1000) # 1 個關鍵字引數\n"
1404+
"parrot(voltage=1000000, action='VOOOOOM') # 2 個關鍵字引數\n"
1405+
"parrot(action='VOOOOOM', voltage=1000000) # 2 個關鍵字引數\n"
1406+
"parrot('a million', 'bereft of life', 'jump') # 3 個位置引數\n"
1407+
"parrot('a thousand', state='pushing up the daisies') # 1 個位置引數、1 個關鍵字引數\n"
13041408

13051409
#:../../tutorial/controlflow.rst:677
13061410
msgid"but all the following calls would be invalid::"
@@ -1314,6 +1418,10 @@ msgid ""
13141418
"parrot(110, voltage=220) # duplicate value for the same argument\n"
13151419
"parrot(actor='John Cleese') # unknown keyword argument"
13161420
msgstr""
1421+
"parrot() # 缺少必要引數\n"
1422+
"parrot(voltage=5.0, 'dead') # 關鍵字引數後面的非關鍵字引數\n"
1423+
"parrot(110, voltage=220) # 同一個引數有重複值\n"
1424+
"parrot(actor='John Cleese') # 未知的關鍵字引數"
13171425

13181426
#:../../tutorial/controlflow.rst:684
13191427
msgid""
@@ -1877,6 +1985,11 @@ msgid ""
18771985
"list\n"
18781986
"[3, 4, 5]"
18791987
msgstr""
1988+
">>> list(range(3, 6)) # 使用分離引數的一般呼叫\n"
1989+
"[3, 4, 5]\n"
1990+
">>> args = [3, 6]\n"
1991+
">>> list(range(*args)) # 以從串列解包而得的引數呼叫\n"
1992+
"[3, 4, 5]"
18801993

18811994
#:../../tutorial/controlflow.rst:965
18821995
msgid""
@@ -2041,6 +2154,17 @@ msgid ""
20412154
"\n"
20422155
"No, really, it doesn't do anything."
20432156
msgstr""
2157+
">>> def my_function():\n"
2158+
"...\"\"\"不做任何事,但有文件說明。\n"
2159+
"...\n"
2160+
"... 不,真的,它什麼都不做。\n"
2161+
"...\"\"\"\n"
2162+
"... pass\n"
2163+
"...\n"
2164+
">>> print(my_function.__doc__)\n"
2165+
"Do nothing, but document it.\n"
2166+
"\n"
2167+
"No, really, it doesn't do anything."
20442168

20452169
#:../../tutorial/controlflow.rst:1064
20462170
msgid"Function Annotations"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp