Skip to content

Commit fc9f3ef

Browse files
Copilotmattwang44
andcommitted
Complete translation of tutorial/introduction.po and tutorial/controlflow.po
Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com>
1 parent f6e0119 commit fc9f3ef

File tree

4 files changed

+257
-8
lines changed

4 files changed

+257
-8
lines changed

tutorial/controlflow.po

Lines changed: 129 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+
">>> # Measure some strings:\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+
"# Create a sample collection\n"
163+
"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n"
164+
"\n"
165+
"# Strategy: Iterate over a copy\n"
166+
"for user, status in users.copy().items():\n"
167+
" if status == 'inactive':\n"
168+
" del users[user]\n"
169+
"\n"
170+
"# Strategy: Create a new collection\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+
"... # loop fell through without finding a factor\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 # Busy-wait for keyboard interrupt (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 # Remember to implement this!\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 is an (x, y) tuple\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): # write Fibonacci series less than n\n"
991+
"... \"\"\"Print a Fibonacci series less than 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+
">>> # Now call the function we just defined:\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): # return Fibonacci series up to n\n"
1135+
"... \"\"\"Return a list containing the Fibonacci series up to n.\"\"\"\n"
1136+
"... result = []\n"
1137+
"... a, b = 0, 1\n"
1138+
"... while a < n:\n"
1139+
"... result.append(a) # see below\n"
1140+
"... a, b = b, a+b\n"
1141+
"... return result\n"
1142+
"...\n"
1143+
">>> f100 = fib2(100) # call it\n"
1144+
">>> f100 # write the result\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,15 @@ msgid ""
13011399
"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 "
13021400
"keyword"
13031401
msgstr ""
1402+
"parrot(1000) # 1 positional "
1403+
"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"
1407+
"parrot('a million', 'bereft of life', 'jump') # 3 positional "
1408+
"arguments\n"
1409+
"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 "
1410+
"keyword"
13041411

13051412
#: ../../tutorial/controlflow.rst:677
13061413
msgid "but all the following calls would be invalid::"
@@ -1314,6 +1421,11 @@ msgid ""
13141421
"parrot(110, voltage=220) # duplicate value for the same argument\n"
13151422
"parrot(actor='John Cleese') # unknown keyword argument"
13161423
msgstr ""
1424+
"parrot() # required argument missing\n"
1425+
"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword "
1426+
"argument\n"
1427+
"parrot(110, voltage=220) # duplicate value for the same argument\n"
1428+
"parrot(actor='John Cleese') # unknown keyword argument"
13171429

13181430
#: ../../tutorial/controlflow.rst:684
13191431
msgid ""
@@ -1877,6 +1989,12 @@ msgid ""
18771989
"list\n"
18781990
"[3, 4, 5]"
18791991
msgstr ""
1992+
">>> list(range(3, 6)) # normal call with separate arguments\n"
1993+
"[3, 4, 5]\n"
1994+
">>> args = [3, 6]\n"
1995+
">>> list(range(*args)) # call with arguments unpacked from a "
1996+
"list\n"
1997+
"[3, 4, 5]"
18801998

18811999
#: ../../tutorial/controlflow.rst:965
18822000
msgid ""
@@ -2041,6 +2159,17 @@ msgid ""
20412159
"\n"
20422160
"No, really, it doesn't do anything."
20432161
msgstr ""
2162+
">>> def my_function():\n"
2163+
"... \"\"\"Do nothing, but document it.\n"
2164+
"...\n"
2165+
"... No, really, it doesn't do anything.\n"
2166+
"... \"\"\"\n"
2167+
"... pass\n"
2168+
"...\n"
2169+
">>> print(my_function.__doc__)\n"
2170+
"Do nothing, but document it.\n"
2171+
"\n"
2172+
"No, really, it doesn't do anything."
20442173

20452174
#: ../../tutorial/controlflow.rst:1064
20462175
msgid "Function Annotations"

tutorial/index.po

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,16 @@ msgstr ""
7070
"作為其擴充用介面語言 (extension language)。"
7171

7272
#: ../../tutorial/index.rst:27
73-
#, fuzzy
7473
msgid ""
7574
"This tutorial introduces the reader informally to the basic concepts and "
7675
"features of the Python language and system. Be aware that it expects you to "
7776
"have a basic understanding of programming in general. It helps to have a "
7877
"Python interpreter handy for hands-on experience, but all examples are self-"
7978
"contained, so the tutorial can be read off-line as well."
8079
msgstr ""
81-
"這份教學將簡介 Python 語言與系統的基本概念及功能。除了閱讀之外、實際用 "
82-
"Python 直譯器寫程式跑範例,將有助於學習。但如果只用讀的,也是可行的學習方式,"
83-
"因為所有範例的內容皆獨立且完整。"
80+
"這份教學將非正式地介紹 Python 語言與系統的基本概念及功能。請注意,它預期你對程式"
81+
"設計有基本的了解。實際用 Python 直譯器進行實際操作將有助於學習,但所有範例都是"
82+
"獨立完整的,所以這份教學也可以離線閱讀。"
8483

8584
#: ../../tutorial/index.rst:33
8685
msgid ""

tutorial/interpreter.po

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ msgstr ""
5555
"python` 是個很常見的另類存放路徑。)"
5656

5757
#: ../../tutorial/interpreter.rst:26
58-
#, fuzzy
5958
msgid ""
6059
"On Windows machines where you have installed Python from the :ref:`Microsoft "
6160
"Store <windows-store>`, the |python_x_dot_y_literal| command will be "
@@ -64,9 +63,9 @@ msgid ""
6463
"launch Python."
6564
msgstr ""
6665
"Windows 系統中,從 :ref:`Microsoft Store <windows-store>` 安裝 Python 後,就"
67-
"可以使用 :file:`python3.12` 命令了。如果安裝了 :ref:`py.exe launcher "
68-
"<launcher>` ,則可以使用 :file:`py` 命令。請參閱附錄::ref:`setting-"
69-
"envvars`了解其他啟動 Python 的方式。"
66+
"可以使用 |python_x_dot_y_literal| 命令了。如果安裝了 :ref:`py.exe launcher "
67+
"<launcher>` ,則可以使用 :file:`py` 命令。請參閱 :ref:`setting-"
68+
"envvars` 了解其他啟動 Python 的方式。"
7069

7170
#: ../../tutorial/interpreter.rst:31
7271
msgid ""

0 commit comments

Comments
 (0)