Skip to content

Complete translation of all tutorial .po files #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions tutorial/classes.po
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,28 @@ msgid ""
"scope_test()\n"
"print(\"In global scope:\", spam)"
msgstr ""
"def scope_test():\n"
" def do_local():\n"
" spam = \"local spam\"\n"
"\n"
" def do_nonlocal():\n"
" nonlocal spam\n"
" spam = \"nonlocal spam\"\n"
"\n"
" def do_global():\n"
" global spam\n"
" spam = \"global spam\"\n"
"\n"
" spam = \"test spam\"\n"
" do_local()\n"
" print(\"After local assignment:\", spam)\n"
" do_nonlocal()\n"
" print(\"After nonlocal assignment:\", spam)\n"
" do_global()\n"
" print(\"After global assignment:\", spam)\n"
"\n"
"scope_test()\n"
"print(\"In global scope:\", spam)"

#: ../../tutorial/classes.rst:191
msgid "The output of the example code is:"
Expand All @@ -387,6 +409,10 @@ msgid ""
"After global assignment: nonlocal spam\n"
"In global scope: global spam"
msgstr ""
"After local assignment: test spam\n"
"After nonlocal assignment: nonlocal spam\n"
"After global assignment: nonlocal spam\n"
"In global scope: global spam"

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

#: ../../tutorial/classes.rst:345
msgid ""
Expand Down Expand Up @@ -795,6 +822,23 @@ msgid ""
">>> e.name # unique to e\n"
"'Buddy'"
msgstr ""
"class Dog:\n"
"\n"
" kind = 'canine' # 所有實例共享的類別變數\n"
"\n"
" def __init__(self, name):\n"
" self.name = name # 每個實例獨有的實例變數\n"
"\n"
">>> d = Dog('Fido')\n"
">>> e = Dog('Buddy')\n"
">>> d.kind # 為所有 Dog 實例所共享\n"
"'canine'\n"
">>> e.kind # 為所有 Dog 實例所共享\n"
"'canine'\n"
">>> d.name # d 獨有\n"
"'Fido'\n"
">>> e.name # e 獨有\n"
"'Buddy'"

#: ../../tutorial/classes.rst:422
msgid ""
Expand Down Expand Up @@ -1363,6 +1407,24 @@ msgid ""
" for item in zip(keys, values):\n"
" self.items_list.append(item)"
msgstr ""
"class Mapping:\n"
" def __init__(self, iterable):\n"
" self.items_list = []\n"
" self.__update(iterable)\n"
"\n"
" def update(self, iterable):\n"
" for item in iterable:\n"
" self.items_list.append(item)\n"
"\n"
" __update = update # 原始 update() 方法的私有副本\n"
"\n"
"class MappingSubclass(Mapping):\n"
"\n"
" def update(self, keys, values):\n"
" # 為 update() 提供新的函式簽名\n"
" # 但不會破壞 __init__()\n"
" for item in zip(keys, values):\n"
" self.items_list.append(item)"

#: ../../tutorial/classes.rst:718
msgid ""
Expand Down Expand Up @@ -1592,6 +1654,20 @@ msgid ""
" self.index = self.index - 1\n"
" return self.data[self.index]"
msgstr ""
"class Reverse:\n"
" \"\"\"用於向後迴圈遍歷序列的疊代器。\"\"\"\n"
" def __init__(self, data):\n"
" self.data = data\n"
" self.index = len(data)\n"
"\n"
" def __iter__(self):\n"
" return self\n"
"\n"
" def __next__(self):\n"
" if self.index == 0:\n"
" raise StopIteration\n"
" self.index = self.index - 1\n"
" return self.data[self.index]"

#: ../../tutorial/classes.rst:845
msgid ""
Expand Down Expand Up @@ -1737,6 +1813,22 @@ msgid ""
">>> list(data[i] for i in range(len(data)-1, -1, -1))\n"
"['f', 'l', 'o', 'g']"
msgstr ""
">>> sum(i*i for i in range(10)) # 平方和\n"
"285\n"
"\n"
">>> xvec = [10, 20, 30]\n"
">>> yvec = [7, 5, 3]\n"
">>> sum(x*y for x,y in zip(xvec, yvec)) # 向量內積\n"
"260\n"
"\n"
">>> unique_words = set(word for line in page for word in line.split())\n"
"\n"
">>> valedictorian = max((student.gpa, student.name) for student in "
"graduates)\n"
"\n"
">>> data = 'golf'\n"
">>> list(data[i] for i in range(len(data)-1, -1, -1))\n"
"['f', 'l', 'o', 'g']"

#: ../../tutorial/classes.rst:932
msgid "Footnotes"
Expand Down
124 changes: 124 additions & 0 deletions tutorial/controlflow.po
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ msgid ""
"...\n"
"More"
msgstr ""
">>> x = int(input(\"Please enter an integer: \"))\n"
"Please enter an integer: 42\n"
">>> if x < 0:\n"
"... x = 0\n"
"... print('Negative changed to zero')\n"
"... elif x == 0:\n"
"... print('Zero')\n"
"... elif x == 1:\n"
"... print('Single')\n"
"... else:\n"
"... print('More')\n"
"...\n"
"More"

#: ../../tutorial/controlflow.rst:33
msgid ""
Expand Down Expand Up @@ -112,6 +125,14 @@ msgid ""
"window 6\n"
"defenestrate 12"
msgstr ""
">>> # 測量一些字串:\n"
">>> words = ['cat', 'window', 'defenestrate']\n"
">>> for w in words:\n"
"... print(w, len(w))\n"
"...\n"
"cat 3\n"
"window 6\n"
"defenestrate 12"

#: ../../tutorial/controlflow.rst:72
msgid ""
Expand All @@ -138,6 +159,19 @@ msgid ""
" if status == 'active':\n"
" active_users[user] = status"
msgstr ""
"# 建立一個範例集合\n"
"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n"
"\n"
"# 策略:對副本進行疊代\n"
"for user, status in users.copy().items():\n"
" if status == 'inactive':\n"
" del users[user]\n"
"\n"
"# 策略:建立一個新集合\n"
"active_users = {}\n"
"for user, status in users.items():\n"
" if status == 'active':\n"
" active_users[user] = status"

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

#: ../../tutorial/controlflow.rst:208
msgid ""
Expand Down Expand Up @@ -427,6 +464,23 @@ msgid ""
"8 equals 2 * 4\n"
"9 equals 3 * 3"
msgstr ""
">>> for n in range(2, 10):\n"
"... for x in range(2, n):\n"
"... if n % x == 0:\n"
"... print(n, 'equals', x, '*', n//x)\n"
"... break\n"
"... else:\n"
"... # 迴圈結束但沒有找到因數\n"
"... print(n, 'is a prime number')\n"
"...\n"
"2 is a prime number\n"
"3 is a prime number\n"
"4 equals 2 * 2\n"
"5 is a prime number\n"
"6 equals 2 * 3\n"
"7 is a prime number\n"
"8 equals 2 * 4\n"
"9 equals 3 * 3"

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

#: ../../tutorial/controlflow.rst:248
msgid ""
Expand Down Expand Up @@ -478,6 +535,9 @@ msgid ""
"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n"
"..."
msgstr ""
">>> while True:\n"
"... pass # 忙碌等待鍵盤中斷 (Ctrl+C)\n"
"..."

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

#: ../../tutorial/controlflow.rst:284
msgid ":keyword:`!match` Statements"
Expand Down Expand Up @@ -604,6 +667,18 @@ msgid ""
" case _:\n"
" raise ValueError(\"Not a point\")"
msgstr ""
"# point 是一個 (x, y) 元組\n"
"match point:\n"
" case (0, 0):\n"
" print(\"Origin\")\n"
" case (0, y):\n"
" print(f\"Y={y}\")\n"
" case (x, 0):\n"
" print(f\"X={x}\")\n"
" case (x, y):\n"
" print(f\"X={x}, Y={y}\")\n"
" case _:\n"
" raise ValueError(\"Not a point\")"

#: ../../tutorial/controlflow.rst:331
msgid ""
Expand Down Expand Up @@ -912,6 +987,17 @@ msgid ""
">>> fib(2000)\n"
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"
msgstr ""
">>> def fib(n): # 寫出小於 n 的費氏數列\n"
"... \"\"\"印出小於 n 的費氏數列。\"\"\"\n"
"... a, b = 0, 1\n"
"... while a < n:\n"
"... print(a, end=' ')\n"
"... a, b = b, a+b\n"
"... print()\n"
"...\n"
">>> # 現在呼叫我們剛才定義的函式:\n"
">>> fib(2000)\n"
"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597"

#: ../../tutorial/controlflow.rst:482
msgid ""
Expand Down Expand Up @@ -1045,6 +1131,18 @@ msgid ""
">>> f100 # write the result\n"
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"
msgstr ""
">>> def fib2(n): # 回傳到 n 為止的費氏數列\n"
"... \"\"\"回傳包含到 n 為止的費氏數列的串列。\"\"\"\n"
"... result = []\n"
"... a, b = 0, 1\n"
"... while a < n:\n"
"... result.append(a) # 見下方\n"
"... a, b = b, a+b\n"
"... return result\n"
"...\n"
">>> f100 = fib2(100) # 呼叫它\n"
">>> f100 # 寫出結果\n"
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]"

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

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

#: ../../tutorial/controlflow.rst:684
msgid ""
Expand Down Expand Up @@ -1877,6 +1985,11 @@ msgid ""
"list\n"
"[3, 4, 5]"
msgstr ""
">>> list(range(3, 6)) # 使用分離引數的一般呼叫\n"
"[3, 4, 5]\n"
">>> args = [3, 6]\n"
">>> list(range(*args)) # 以從串列解包而得的引數呼叫\n"
"[3, 4, 5]"

#: ../../tutorial/controlflow.rst:965
msgid ""
Expand Down Expand Up @@ -2041,6 +2154,17 @@ msgid ""
"\n"
"No, really, it doesn't do anything."
msgstr ""
">>> def my_function():\n"
"... \"\"\"不做任何事,但有文件說明。\n"
"...\n"
"... 不,真的,它什麼都不做。\n"
"... \"\"\"\n"
"... pass\n"
"...\n"
">>> print(my_function.__doc__)\n"
"Do nothing, but document it.\n"
"\n"
"No, really, it doesn't do anything."

#: ../../tutorial/controlflow.rst:1064
msgid "Function Annotations"
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy