Skip to content

Commit 969797e

Browse files
Copilotmattwang44
andcommitted
Translate code comments and docstrings (batch 1)
Co-authored-by: mattwang44 <[email protected]>
1 parent a553961 commit 969797e

File tree

5 files changed

+60
-60
lines changed

5 files changed

+60
-60
lines changed

tutorial/classes.po

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,9 @@ msgstr ""
831831
"\n"
832832
">>> d = Dog('Fido')\n"
833833
">>> e = Dog('Buddy')\n"
834-
">>> d.kind # 所有狗共享\n"
834+
">>> d.kind # 為所有 Dog 實例所共享\n"
835835
"'canine'\n"
836-
">>> e.kind # 所有狗共享\n"
836+
">>> e.kind # 為所有 Dog 實例所共享\n"
837837
"'canine'\n"
838838
">>> d.name # d 獨有\n"
839839
"'Fido'\n"
@@ -1397,7 +1397,7 @@ msgid ""
13971397
" for item in iterable:\n"
13981398
" self.items_list.append(item)\n"
13991399
"\n"
1400-
" __update = update # private copy of original update() method\n"
1400+
" __update = update # 原始 update() 方法的私有副本\n"
14011401
"\n"
14021402
"class MappingSubclass(Mapping):\n"
14031403
"\n"
@@ -1416,13 +1416,13 @@ msgstr ""
14161416
" for item in iterable:\n"
14171417
" self.items_list.append(item)\n"
14181418
"\n"
1419-
" __update = update # private copy of original update() method\n"
1419+
" __update = update # 原始 update() 方法的私有副本\n"
14201420
"\n"
14211421
"class MappingSubclass(Mapping):\n"
14221422
"\n"
14231423
" def update(self, keys, values):\n"
1424-
" # provides new signature for update()\n"
1425-
" # but does not break __init__()\n"
1424+
" # update() 提供新的函式簽名\n"
1425+
" # 但不會破壞 __init__()\n"
14261426
" for item in zip(keys, values):\n"
14271427
" self.items_list.append(item)"
14281428

@@ -1655,7 +1655,7 @@ msgid ""
16551655
" return self.data[self.index]"
16561656
msgstr ""
16571657
"class Reverse:\n"
1658-
" \"\"\"用於向後迴圈遍歷序列的迭代器\"\"\"\n"
1658+
" \"\"\"用於向後迴圈遍歷序列的疊代器\"\"\"\n"
16591659
" def __init__(self, data):\n"
16601660
" self.data = data\n"
16611661
" self.index = len(data)\n"
@@ -1813,12 +1813,12 @@ msgid ""
18131813
">>> list(data[i] for i in range(len(data)-1, -1, -1))\n"
18141814
"['f', 'l', 'o', 'g']"
18151815
msgstr ""
1816-
">>> sum(i*i for i in range(10)) # sum of squares\n"
1816+
">>> sum(i*i for i in range(10)) # 平方和\n"
18171817
"285\n"
18181818
"\n"
18191819
">>> xvec = [10, 20, 30]\n"
18201820
">>> yvec = [7, 5, 3]\n"
1821-
">>> sum(x*y for x,y in zip(xvec, yvec)) # dot product\n"
1821+
">>> sum(x*y for x,y in zip(xvec, yvec)) # 向量內積\n"
18221822
"260\n"
18231823
"\n"
18241824
">>> unique_words = set(word for line in page for word in line.split())\n"

tutorial/controlflow.po

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ msgid ""
125125
"window 6\n"
126126
"defenestrate 12"
127127
msgstr ""
128-
">>> # Measure some strings:\n"
128+
">>> # 測量一些字串:\n"
129129
">>> words = ['cat', 'window', 'defenestrate']\n"
130130
">>> for w in words:\n"
131131
"... print(w, len(w))\n"
@@ -162,7 +162,7 @@ msgstr ""
162162
"# 建立一個範例集合\n"
163163
"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n"
164164
"\n"
165-
"# 策略:對副本進行迭代\n"
165+
"# 策略:對副本進行疊代\n"
166166
"for user, status in users.copy().items():\n"
167167
" if status == 'inactive':\n"
168168
" del users[user]\n"
@@ -470,7 +470,7 @@ msgstr ""
470470
"... print(n, 'equals', x, '*', n//x)\n"
471471
"... break\n"
472472
"... else:\n"
473-
"... # loop fell through without finding a factor\n"
473+
"... # 迴圈結束但沒有找到因數\n"
474474
"... print(n, 'is a prime number')\n"
475475
"...\n"
476476
"2 is a prime number\n"
@@ -536,7 +536,7 @@ msgid ""
536536
"..."
537537
msgstr ""
538538
">>> while True:\n"
539-
"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n"
539+
"... pass # 忙碌等待鍵盤中斷 (Ctrl+C)\n"
540540
"..."
541541

542542
#: ../../tutorial/controlflow.rst:266
@@ -570,7 +570,7 @@ msgid ""
570570
"..."
571571
msgstr ""
572572
">>> def initlog(*args):\n"
573-
"... pass # Remember to implement this!\n"
573+
"... pass # 記得要實作這個!\n"
574574
"..."
575575

576576
#: ../../tutorial/controlflow.rst:284
@@ -667,7 +667,7 @@ msgid ""
667667
" case _:\n"
668668
" raise ValueError(\"Not a point\")"
669669
msgstr ""
670-
"# point is an (x, y) tuple\n"
670+
"# point 是一個 (x, y) 元組\n"
671671
"match point:\n"
672672
" case (0, 0):\n"
673673
" print(\"Origin\")\n"
@@ -987,15 +987,15 @@ msgid ""
987987
">>> fib(2000)\n"
988988
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"
989989
msgstr ""
990-
">>> def fib(n): # write Fibonacci series less than n\n"
991-
"... \"\"\"Print a Fibonacci series less than n.\"\"\"\n"
990+
">>> def fib(n): # 寫出小於 n 的費氏數列\n"
991+
"... \"\"\"印出小於 n 的費氏數列。\"\"\"\n"
992992
"... a, b = 0, 1\n"
993993
"... while a < n:\n"
994994
"... print(a, end=' ')\n"
995995
"... a, b = b, a+b\n"
996996
"... print()\n"
997997
"...\n"
998-
">>> # Now call the function we just defined:\n"
998+
">>> # 現在呼叫我們剛才定義的函式:\n"
999999
">>> fib(2000)\n"
10001000
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"
10011001

@@ -1131,17 +1131,17 @@ msgid ""
11311131
">>> f100 # write the result\n"
11321132
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"
11331133
msgstr ""
1134-
">>> def fib2(n): # return Fibonacci series up to n\n"
1135-
"... \"\"\"Return a list containing the Fibonacci series up to n.\"\"\"\n"
1134+
">>> def fib2(n): # 回傳到 n 為止的費氏數列\n"
1135+
"... \"\"\"回傳包含到 n 為止的費氏數列的列表。\"\"\"\n"
11361136
"... result = []\n"
11371137
"... a, b = 0, 1\n"
11381138
"... while a < n:\n"
1139-
"... result.append(a) # see below\n"
1139+
"... result.append(a) # 見下方\n"
11401140
"... a, b = b, a+b\n"
11411141
"... return result\n"
11421142
"...\n"
1143-
">>> f100 = fib2(100) # call it\n"
1144-
">>> f100 # write the result\n"
1143+
">>> f100 = fib2(100) # 呼叫它\n"
1144+
">>> f100 # 寫出結果\n"
11451145
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"
11461146

11471147
#: ../../tutorial/controlflow.rst:550
@@ -1401,9 +1401,9 @@ msgid ""
14011401
msgstr ""
14021402
"parrot(1000) # 1 positional "
14031403
"argument\n"
1404-
"parrot(voltage=1000) # 1 keyword argument\n"
1405-
"parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments\n"
1406-
"parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments\n"
1404+
"parrot(voltage=1000) # 1 個關鍵字引數\n"
1405+
"parrot(voltage=1000000, action='VOOOOOM') # 2 個關鍵字引數\n"
1406+
"parrot(action='VOOOOOM', voltage=1000000) # 2 個關鍵字引數\n"
14071407
"parrot('a million', 'bereft of life', 'jump') # 3 positional "
14081408
"arguments\n"
14091409
"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 "
@@ -1421,11 +1421,11 @@ msgid ""
14211421
"parrot(110, voltage=220) # duplicate value for the same argument\n"
14221422
"parrot(actor='John Cleese') # unknown keyword argument"
14231423
msgstr ""
1424-
"parrot() # required argument missing\n"
1424+
"parrot() # 缺少必要引數\n"
14251425
"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword "
14261426
"argument\n"
1427-
"parrot(110, voltage=220) # duplicate value for the same argument\n"
1428-
"parrot(actor='John Cleese') # unknown keyword argument"
1427+
"parrot(110, voltage=220) # 同一個引數有重複值\n"
1428+
"parrot(actor='John Cleese') # 未知的關鍵字引數"
14291429

14301430
#: ../../tutorial/controlflow.rst:684
14311431
msgid ""
@@ -1989,7 +1989,7 @@ msgid ""
19891989
"list\n"
19901990
"[3, 4, 5]"
19911991
msgstr ""
1992-
">>> list(range(3, 6)) # normal call with separate arguments\n"
1992+
">>> list(range(3, 6)) # 使用分離引數的一般呼叫\n"
19931993
"[3, 4, 5]\n"
19941994
">>> args = [3, 6]\n"
19951995
">>> list(range(*args)) # call with arguments unpacked from a "
@@ -2160,9 +2160,9 @@ msgid ""
21602160
"No, really, it doesn't do anything."
21612161
msgstr ""
21622162
">>> def my_function():\n"
2163-
"... \"\"\"Do nothing, but document it.\n"
2163+
"... \"\"\"不做任何事,但有文件說明。\n"
21642164
"...\n"
2165-
"... No, really, it doesn't do anything.\n"
2165+
"... 不,真的,它什麼都不做。\n"
21662166
"... \"\"\"\n"
21672167
"... pass\n"
21682168
"...\n"

tutorial/datastructures.po

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,23 @@ msgid ""
458458
"[1, 2, 3, 4, 5, 6, 7, 8, 9]"
459459
msgstr ""
460460
">>> vec = [-4, -2, 0, 2, 4]\n"
461-
">>> # create a new list with the values doubled\n"
461+
">>> # 建立一個值加倍的新列表\n"
462462
">>> [x*2 for x in vec]\n"
463463
"[-8, -4, 0, 4, 8]\n"
464-
">>> # filter the list to exclude negative numbers\n"
464+
">>> # 過濾列表以排除負數\n"
465465
">>> [x for x in vec if x >= 0]\n"
466466
"[0, 2, 4]\n"
467-
">>> # apply a function to all the elements\n"
467+
">>> # 對所有元素套用函式\n"
468468
">>> [abs(x) for x in vec]\n"
469469
"[4, 2, 0, 2, 4]\n"
470-
">>> # call a method on each element\n"
470+
">>> # 對每個元素呼叫方法\n"
471471
">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n"
472472
">>> [weapon.strip() for weapon in freshfruit]\n"
473473
"['banana', 'loganberry', 'passion fruit']\n"
474-
">>> # create a list of 2-tuples like (number, square)\n"
474+
">>> # 建立像 (數字, 平方) 的 2-元組列表\n"
475475
">>> [(x, x**2) for x in range(6)]\n"
476476
"[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n"
477-
">>> # the tuple must be parenthesized, otherwise an error is raised\n"
477+
">>> # 元組必須加上括號,否則會產生錯誤\n"
478478
">>> [x, x**2 for x in range(6)]\n"
479479
" File \"<stdin>\", line 1\n"
480480
" [x, x**2 for x in range(6)]\n"
@@ -887,24 +887,24 @@ msgstr ""
887887
">>> print(basket) # show that duplicates have been "
888888
"removed\n"
889889
"{'orange', 'banana', 'pear', 'apple'}\n"
890-
">>> 'orange' in basket # fast membership testing\n"
890+
">>> 'orange' in basket # 快速成員測試\n"
891891
"True\n"
892892
">>> 'crabgrass' in basket\n"
893893
"False\n"
894894
"\n"
895-
">>> # Demonstrate set operations on unique letters from two words\n"
895+
">>> # 示範對兩個字的唯一字母進行集合運算\n"
896896
">>>\n"
897897
">>> a = set('abracadabra')\n"
898898
">>> b = set('alacazam')\n"
899-
">>> a # unique letters in a\n"
899+
">>> a # a 中的唯一字母\n"
900900
"{'a', 'r', 'b', 'c', 'd'}\n"
901-
">>> a - b # letters in a but not in b\n"
901+
">>> a - b # 在 a 中但不在 b 中的字母\n"
902902
"{'r', 'd', 'b'}\n"
903-
">>> a | b # letters in a or b or both\n"
903+
">>> a | b # 在 a 或 b 或兩者中的字母\n"
904904
"{'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}\n"
905-
">>> a & b # letters in both a and b\n"
905+
">>> a & b # 同時在 a 和 b 中的字母\n"
906906
"{'a', 'c'}\n"
907-
">>> a ^ b # letters in a or b but not both\n"
907+
">>> a ^ b # 在 a 或 b 中但不在兩者中的字母\n"
908908
"{'r', 'd', 'b', 'm', 'z', 'l'}"
909909

910910
#: ../../tutorial/datastructures.rst:482

tutorial/floatingpoint.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ msgid ""
215215
">>> repr(math.pi)\n"
216216
"'3.141592653589793'"
217217
msgstr ""
218-
">>> format(math.pi, '.12g') # give 12 significant digits\n"
218+
">>> format(math.pi, '.12g') # 給出 12 個有效位數\n"
219219
"'3.14159265359'\n"
220220
"\n"
221-
">>> format(math.pi, '.2f') # give 2 digits after the point\n"
221+
">>> format(math.pi, '.2f') # 小數點後給出 2 位數字\n"
222222
"'3.14'\n"
223223
"\n"
224224
">>> repr(math.pi)\n"
@@ -502,9 +502,9 @@ msgid ""
502502
msgstr ""
503503
">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,\n"
504504
"... -143401161400469.7, 266262841.31058735, -0.003244936839808227]\n"
505-
">>> float(sum(map(Fraction, arr))) # Exact summation with single rounding\n"
505+
">>> float(sum(map(Fraction, arr))) # 單次四捨五入的精確加總\n"
506506
"8.042173697819788e-13\n"
507-
">>> math.fsum(arr) # Single rounding\n"
507+
">>> math.fsum(arr) # 單次四捨五入\n"
508508
"8.042173697819788e-13\n"
509509
">>> sum(arr) # Multiple roundings in extended "
510510
"precision\n"

tutorial/introduction.po

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ msgid ""
7575
" # ... and now a third!\n"
7676
"text = \"# This is not a comment because it's inside quotes.\""
7777
msgstr ""
78-
"# this is the first comment\n"
79-
"spam = 1 # and this is the second comment\n"
80-
" # ... and now a third!\n"
81-
"text = \"# This is not a comment because it's inside quotes.\""
78+
"# 這是第一個註解\n"
79+
"spam = 1 # 這是第二個註解\n"
80+
" # ... 現在是第三個!\n"
81+
"text = \"# 這不是註解,因為它在引號內。\""
8282

8383
#: ../../tutorial/introduction.rst:41
8484
msgid "Using Python as a Calculator"
@@ -124,7 +124,7 @@ msgstr ""
124124
"20\n"
125125
">>> (50 - 5*6) / 4\n"
126126
"5.0\n"
127-
">>> 8 / 5 # division always returns a floating-point number\n"
127+
">>> 8 / 5 # 除法總是回傳浮點數\n"
128128
"1.6"
129129

130130
#: ../../tutorial/introduction.rst:67
@@ -158,14 +158,14 @@ msgid ""
158158
">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n"
159159
"17"
160160
msgstr ""
161-
">>> 17 / 3 # classic division returns a float\n"
161+
">>> 17 / 3 # 傳統除法回傳浮點數\n"
162162
"5.666666666666667\n"
163163
">>>\n"
164-
">>> 17 // 3 # floor division discards the fractional part\n"
164+
">>> 17 // 3 # 下取整除法捨棄小數部分\n"
165165
"5\n"
166-
">>> 17 % 3 # the % operator returns the remainder of the division\n"
166+
">>> 17 % 3 # % 運算子回傳除法的餘數\n"
167167
"2\n"
168-
">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n"
168+
">>> 5 * 3 + 2 # 下取整商 * 除數 + 餘數\n"
169169
"17"
170170

171171
#: ../../tutorial/introduction.rst:85
@@ -181,9 +181,9 @@ msgid ""
181181
">>> 2 ** 7 # 2 to the power of 7\n"
182182
"128"
183183
msgstr ""
184-
">>> 5 ** 2 # 5 squared\n"
184+
">>> 5 ** 2 # 5 的平方\n"
185185
"25\n"
186-
">>> 2 ** 7 # 2 to the power of 7\n"
186+
">>> 2 ** 7 # 2 的 7 次方\n"
187187
"128"
188188

189189
#: ../../tutorial/introduction.rst:92

0 commit comments

Comments
 (0)