From f6e01197e0113bf51fa1c8cd4ca143cd143a1c4b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 03:55:46 +0000 Subject: [PATCH 1/8] Initial plan From fc9f3ef4186d13a576d6a531a5a5aa3782b43c79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 04:07:33 +0000 Subject: [PATCH 2/8] Complete translation of tutorial/introduction.po and tutorial/controlflow.po Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/controlflow.po | 129 +++++++++++++++++++++++++++++++++++++++ tutorial/index.po | 7 +-- tutorial/interpreter.po | 7 +-- tutorial/introduction.po | 122 ++++++++++++++++++++++++++++++++++++ 4 files changed, 257 insertions(+), 8 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index fd2ee89755..321995254e 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -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 "" @@ -112,6 +125,14 @@ msgid "" "window 6\n" "defenestrate 12" msgstr "" +">>> # Measure some strings:\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 "" @@ -138,6 +159,19 @@ msgid "" " if status == 'active':\n" " active_users[user] = status" msgstr "" +"# Create a sample collection\n" +"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n" +"\n" +"# Strategy: Iterate over a copy\n" +"for user, status in users.copy().items():\n" +" if status == 'inactive':\n" +" del users[user]\n" +"\n" +"# Strategy: Create a new collection\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" @@ -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 "" @@ -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" +"... # loop fell through without finding a factor\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 "" @@ -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 "" @@ -478,6 +535,9 @@ msgid "" "... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n" "..." msgstr "" +">>> while True:\n" +"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n" +"..." #: ../../tutorial/controlflow.rst:266 msgid "This is commonly used for creating minimal classes::" @@ -509,6 +569,9 @@ msgid "" "... pass # Remember to implement this!\n" "..." msgstr "" +">>> def initlog(*args):\n" +"... pass # Remember to implement this!\n" +"..." #: ../../tutorial/controlflow.rst:284 msgid ":keyword:`!match` Statements" @@ -604,6 +667,18 @@ msgid "" " case _:\n" " raise ValueError(\"Not a point\")" msgstr "" +"# point is an (x, y) tuple\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 "" @@ -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): # write Fibonacci series less than n\n" +"... \"\"\"Print a Fibonacci series less than n.\"\"\"\n" +"... a, b = 0, 1\n" +"... while a < n:\n" +"... print(a, end=' ')\n" +"... a, b = b, a+b\n" +"... print()\n" +"...\n" +">>> # Now call the function we just defined:\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 "" @@ -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): # return Fibonacci series up to n\n" +"... \"\"\"Return a list containing the Fibonacci series up to n.\"\"\"\n" +"... result = []\n" +"... a, b = 0, 1\n" +"... while a < n:\n" +"... result.append(a) # see below\n" +"... a, b = b, a+b\n" +"... return result\n" +"...\n" +">>> f100 = fib2(100) # call it\n" +">>> f100 # write the result\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:" @@ -1301,6 +1399,15 @@ msgid "" "parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " "keyword" msgstr "" +"parrot(1000) # 1 positional " +"argument\n" +"parrot(voltage=1000) # 1 keyword argument\n" +"parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments\n" +"parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments\n" +"parrot('a million', 'bereft of life', 'jump') # 3 positional " +"arguments\n" +"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " +"keyword" #: ../../tutorial/controlflow.rst:677 msgid "but all the following calls would be invalid::" @@ -1314,6 +1421,11 @@ msgid "" "parrot(110, voltage=220) # duplicate value for the same argument\n" "parrot(actor='John Cleese') # unknown keyword argument" msgstr "" +"parrot() # required argument missing\n" +"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword " +"argument\n" +"parrot(110, voltage=220) # duplicate value for the same argument\n" +"parrot(actor='John Cleese') # unknown keyword argument" #: ../../tutorial/controlflow.rst:684 msgid "" @@ -1877,6 +1989,12 @@ msgid "" "list\n" "[3, 4, 5]" msgstr "" +">>> list(range(3, 6)) # normal call with separate arguments\n" +"[3, 4, 5]\n" +">>> args = [3, 6]\n" +">>> list(range(*args)) # call with arguments unpacked from a " +"list\n" +"[3, 4, 5]" #: ../../tutorial/controlflow.rst:965 msgid "" @@ -2041,6 +2159,17 @@ msgid "" "\n" "No, really, it doesn't do anything." msgstr "" +">>> def my_function():\n" +"... \"\"\"Do nothing, but document it.\n" +"...\n" +"... No, really, it doesn't do anything.\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" diff --git a/tutorial/index.po b/tutorial/index.po index 151c6493a9..b9a9a6bf14 100644 --- a/tutorial/index.po +++ b/tutorial/index.po @@ -70,7 +70,6 @@ msgstr "" "作為其擴充用介面語言 (extension language)。" #: ../../tutorial/index.rst:27 -#, fuzzy msgid "" "This tutorial introduces the reader informally to the basic concepts and " "features of the Python language and system. Be aware that it expects you to " @@ -78,9 +77,9 @@ msgid "" "Python interpreter handy for hands-on experience, but all examples are self-" "contained, so the tutorial can be read off-line as well." msgstr "" -"這份教學將簡介 Python 語言與系統的基本概念及功能。除了閱讀之外、實際用 " -"Python 直譯器寫程式跑範例,將有助於學習。但如果只用讀的,也是可行的學習方式," -"因為所有範例的內容皆獨立且完整。" +"這份教學將非正式地介紹 Python 語言與系統的基本概念及功能。請注意,它預期你對程式" +"設計有基本的了解。實際用 Python 直譯器進行實際操作將有助於學習,但所有範例都是" +"獨立完整的,所以這份教學也可以離線閱讀。" #: ../../tutorial/index.rst:33 msgid "" diff --git a/tutorial/interpreter.po b/tutorial/interpreter.po index 5f3f9461b1..19491986f5 100644 --- a/tutorial/interpreter.po +++ b/tutorial/interpreter.po @@ -55,7 +55,6 @@ msgstr "" "python` 是個很常見的另類存放路徑。)" #: ../../tutorial/interpreter.rst:26 -#, fuzzy msgid "" "On Windows machines where you have installed Python from the :ref:`Microsoft " "Store `, the |python_x_dot_y_literal| command will be " @@ -64,9 +63,9 @@ msgid "" "launch Python." msgstr "" "Windows 系統中,從 :ref:`Microsoft Store ` 安裝 Python 後,就" -"可以使用 :file:`python3.12` 命令了。如果安裝了 :ref:`py.exe launcher " -"` ,則可以使用 :file:`py` 命令。請參閱附錄::ref:`setting-" -"envvars`,了解其他啟動 Python 的方式。" +"可以使用 |python_x_dot_y_literal| 命令了。如果安裝了 :ref:`py.exe launcher " +"` ,則可以使用 :file:`py` 命令。請參閱 :ref:`setting-" +"envvars` 了解其他啟動 Python 的方式。" #: ../../tutorial/interpreter.rst:31 msgid "" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index 08a3720e9a..3dd340120e 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -45,6 +45,8 @@ msgid "" "hovering over or tapping a code example), which strips prompts and omits " "output, to copy and paste the input lines into your interpreter." msgstr "" +"你可以使用\"複製\"按鈕(當游標移至程式碼範例上方或點選程式碼範例時,它會出現在右上角)," +"這會去除提示字元並略過輸出,讓你可以複製貼上輸入行到你的直譯器。" #: ../../tutorial/introduction.rst:22 msgid "" @@ -73,6 +75,10 @@ msgid "" " # ... and now a third!\n" "text = \"# This is not a comment because it's inside quotes.\"" msgstr "" +"# this is the first comment\n" +"spam = 1 # and this is the second comment\n" +" # ... and now a third!\n" +"text = \"# This is not a comment because it's inside quotes.\"" #: ../../tutorial/introduction.rst:41 msgid "Using Python as a Calculator" @@ -112,6 +118,14 @@ msgid "" ">>> 8 / 5 # division always returns a floating-point number\n" "1.6" msgstr "" +">>> 2 + 2\n" +"4\n" +">>> 50 - 5*6\n" +"20\n" +">>> (50 - 5*6) / 4\n" +"5.0\n" +">>> 8 / 5 # division always returns a floating-point number\n" +"1.6" #: ../../tutorial/introduction.rst:67 msgid "" @@ -144,6 +158,15 @@ msgid "" ">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n" "17" msgstr "" +">>> 17 / 3 # classic division returns a float\n" +"5.666666666666667\n" +">>>\n" +">>> 17 // 3 # floor division discards the fractional part\n" +"5\n" +">>> 17 % 3 # the % operator returns the remainder of the division\n" +"2\n" +">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n" +"17" #: ../../tutorial/introduction.rst:85 msgid "" @@ -158,6 +181,10 @@ msgid "" ">>> 2 ** 7 # 2 to the power of 7\n" "128" msgstr "" +">>> 5 ** 2 # 5 squared\n" +"25\n" +">>> 2 ** 7 # 2 to the power of 7\n" +"128" #: ../../tutorial/introduction.rst:92 msgid "" @@ -194,6 +221,10 @@ msgid "" " File \"\", line 1, in \n" "NameError: name 'n' is not defined" msgstr "" +">>> n # try to access an undefined variable\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"NameError: name 'n' is not defined" #: ../../tutorial/introduction.rst:108 msgid "" @@ -288,6 +319,12 @@ msgid "" ">>> '1975' # digits and numerals enclosed in quotes are also strings\n" "'1975'" msgstr "" +">>> 'spam eggs' # single quotes\n" +"'spam eggs'\n" +">>> \"Paris rabbit got your back :)! Yay!\" # double quotes\n" +"'Paris rabbit got your back :)! Yay!'\n" +">>> '1975' # digits and numerals enclosed in quotes are also strings\n" +"'1975'" #: ../../tutorial/introduction.rst:158 msgid "" @@ -310,6 +347,16 @@ msgid "" ">>> '\"Isn\\'t,\" they said.'\n" "'\"Isn\\'t,\" they said.'" msgstr "" +">>> 'doesn\\'t' # use \\' to escape the single quote...\n" +"\"doesn't\"\n" +">>> \"doesn't\" # ...or use double quotes instead\n" +"\"doesn't\"\n" +">>> '\"Yes,\" they said.'\n" +"'\"Yes,\" they said.'\n" +">>> \"\\\"Yes,\\\" they said.\"\n" +"'\"Yes,\" they said.'\n" +">>> '\"Isn\\'t,\" they said.'\n" +"'\"Isn\\'t,\" they said.'" #: ../../tutorial/introduction.rst:172 msgid "" @@ -331,6 +378,13 @@ msgid "" "First line.\n" "Second line." msgstr "" +">>> s = 'First line.\\nSecond line.' # \\n means newline\n" +">>> s # without print(), special characters are included in the string\n" +"'First line.\\nSecond line.'\n" +">>> print(s) # with print(), special characters are interpreted, so \\n " +"produces new line\n" +"First line.\n" +"Second line." #: ../../tutorial/introduction.rst:183 msgid "" @@ -349,6 +403,11 @@ msgid "" ">>> print(r'C:\\some\\name') # note the r before the quote\n" "C:\\some\\name" msgstr "" +">>> print('C:\\some\\name') # here \\n means newline!\n" +"C:\\some\n" +"ame\n" +">>> print(r'C:\\some\\name') # note the r before the quote\n" +"C:\\some\\name" #: ../../tutorial/introduction.rst:193 msgid "" @@ -409,6 +468,9 @@ msgid "" ">>> 3 * 'un' + 'ium'\n" "'unununium'" msgstr "" +">>> # 3 times 'un', followed by 'ium'\n" +">>> 3 * 'un' + 'ium'\n" +"'unununium'" #: ../../tutorial/introduction.rst:222 msgid "" @@ -439,6 +501,10 @@ msgid "" ">>> text\n" "'Put several strings within parentheses to have them joined together.'" msgstr "" +">>> text = ('Put several strings within parentheses '\n" +"... 'to have them joined together.')\n" +">>> text\n" +"'Put several strings within parentheses to have them joined together.'" #: ../../tutorial/introduction.rst:235 msgid "" @@ -459,6 +525,17 @@ msgid "" " ^^^^^\n" "SyntaxError: invalid syntax" msgstr "" +">>> prefix = 'Py'\n" +">>> prefix 'thon' # can't concatenate a variable and a string literal\n" +" File \"\", line 1\n" +" prefix 'thon'\n" +" ^^^^^^\n" +"SyntaxError: invalid syntax\n" +">>> ('un' * 3) 'ium'\n" +" File \"\", line 1\n" +" ('un' * 3) 'ium'\n" +" ^^^^^\n" +"SyntaxError: invalid syntax" #: ../../tutorial/introduction.rst:249 msgid "" @@ -490,6 +567,11 @@ msgid "" ">>> word[5] # character in position 5\n" "'n'" msgstr "" +">>> word = 'Python'\n" +">>> word[0] # character in position 0\n" +"'P'\n" +">>> word[5] # character in position 5\n" +"'n'" #: ../../tutorial/introduction.rst:264 msgid "" @@ -505,6 +587,12 @@ msgid "" ">>> word[-6]\n" "'P'" msgstr "" +">>> word[-1] # last character\n" +"'n'\n" +">>> word[-2] # second-last character\n" +"'o'\n" +">>> word[-6]\n" +"'P'" #: ../../tutorial/introduction.rst:273 msgid "Note that since -0 is the same as 0, negative indices start from -1." @@ -526,6 +614,10 @@ msgid "" ">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" "'tho'" msgstr "" +">>> word[0:2] # characters from position 0 (included) to 2 (excluded)\n" +"'Py'\n" +">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" +"'tho'" #: ../../tutorial/introduction.rst:283 msgid "" @@ -544,6 +636,12 @@ msgid "" ">>> word[-2:] # characters from the second-last (included) to the end\n" "'on'" msgstr "" +">>> word[:2] # character from the beginning to position 2 (excluded)\n" +"'Py'\n" +">>> word[4:] # characters from position 4 (included) to the end\n" +"'on'\n" +">>> word[-2:] # characters from the second-last (included) to the end\n" +"'on'" #: ../../tutorial/introduction.rst:293 msgid "" @@ -662,6 +760,14 @@ msgid "" " File \"\", line 1, in \n" "TypeError: 'str' object does not support item assignment" msgstr "" +">>> word[0] = 'J'\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: 'str' object does not support item assignment\n" +">>> word[2:] = 'py'\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: 'str' object does not support item assignment" #: ../../tutorial/introduction.rst:348 msgid "If you need a different string, you should create a new one::" @@ -783,6 +889,12 @@ msgid "" ">>> squares[-3:] # slicing returns a new list\n" "[9, 16, 25]" msgstr "" +">>> squares[0] # indexing returns the item\n" +"1\n" +">>> squares[-1]\n" +"25\n" +">>> squares[-3:] # slicing returns a new list\n" +"[9, 16, 25]" #: ../../tutorial/introduction.rst:407 msgid "Lists also support operations like concatenation::" @@ -813,6 +925,12 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125]" msgstr "" +">>> cubes = [1, 8, 27, 65, 125] # something's wrong here\n" +">>> 4 ** 3 # the cube of 4 is 64, not 65!\n" +"64\n" +">>> cubes[3] = 64 # replace the wrong value\n" +">>> cubes\n" +"[1, 8, 27, 64, 125]" #: ../../tutorial/introduction.rst:422 msgid "" @@ -829,6 +947,10 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125, 216, 343]" msgstr "" +">>> cubes.append(216) # add the cube of 6\n" +">>> cubes.append(7 ** 3) # and the cube of 7\n" +">>> cubes\n" +"[1, 8, 27, 64, 125, 216, 343]" #: ../../tutorial/introduction.rst:430 msgid "" From 3449ca8464d1b97838ee4faa5413b194c48959f1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 04:14:16 +0000 Subject: [PATCH 3/8] Complete translation of all tutorial .po files - 57 entries translated and 2 fuzzy entries fixed Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/classes.po | 92 ++++++++++++++++++++++++++++++++++++++ tutorial/datastructures.po | 50 +++++++++++++++++++++ tutorial/floatingpoint.po | 25 +++++++++++ tutorial/interpreter.po | 7 ++- tutorial/modules.po | 31 +++++++++++++ tutorial/stdlib2.po | 56 +++++++++++++++++++++++ 6 files changed, 260 insertions(+), 1 deletion(-) diff --git a/tutorial/classes.po b/tutorial/classes.po index 1a71fad46f..9aa4e7481f 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -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:" @@ -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 "" @@ -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 "" @@ -795,6 +822,23 @@ msgid "" ">>> e.name # unique to e\n" "'Buddy'" msgstr "" +"class Dog:\n" +"\n" +" kind = 'canine' # class variable shared by all instances\n" +"\n" +" def __init__(self, name):\n" +" self.name = name # instance variable unique to each instance\n" +"\n" +">>> d = Dog('Fido')\n" +">>> e = Dog('Buddy')\n" +">>> d.kind # shared by all dogs\n" +"'canine'\n" +">>> e.kind # shared by all dogs\n" +"'canine'\n" +">>> d.name # unique to d\n" +"'Fido'\n" +">>> e.name # unique to e\n" +"'Buddy'" #: ../../tutorial/classes.rst:422 msgid "" @@ -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 # private copy of original update() method\n" +"\n" +"class MappingSubclass(Mapping):\n" +"\n" +" def update(self, keys, values):\n" +" # provides new signature for update()\n" +" # but does not break __init__()\n" +" for item in zip(keys, values):\n" +" self.items_list.append(item)" #: ../../tutorial/classes.rst:718 msgid "" @@ -1592,6 +1654,20 @@ msgid "" " self.index = self.index - 1\n" " return self.data[self.index]" msgstr "" +"class Reverse:\n" +" \"\"\"Iterator for looping over a sequence backwards.\"\"\"\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 "" @@ -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)) # sum of squares\n" +"285\n" +"\n" +">>> xvec = [10, 20, 30]\n" +">>> yvec = [7, 5, 3]\n" +">>> sum(x*y for x,y in zip(xvec, yvec)) # dot product\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" diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index d466df73d1..0f7b43f4aa 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -457,6 +457,33 @@ msgid "" ">>> [num for elem in vec for num in elem]\n" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" +">>> vec = [-4, -2, 0, 2, 4]\n" +">>> # create a new list with the values doubled\n" +">>> [x*2 for x in vec]\n" +"[-8, -4, 0, 4, 8]\n" +">>> # filter the list to exclude negative numbers\n" +">>> [x for x in vec if x >= 0]\n" +"[0, 2, 4]\n" +">>> # apply a function to all the elements\n" +">>> [abs(x) for x in vec]\n" +"[4, 2, 0, 2, 4]\n" +">>> # call a method on each element\n" +">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n" +">>> [weapon.strip() for weapon in freshfruit]\n" +"['banana', 'loganberry', 'passion fruit']\n" +">>> # create a list of 2-tuples like (number, square)\n" +">>> [(x, x**2) for x in range(6)]\n" +"[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n" +">>> # the tuple must be parenthesized, otherwise an error is raised\n" +">>> [x, x**2 for x in range(6)]\n" +" File \"\", line 1\n" +" [x, x**2 for x in range(6)]\n" +" ^^^^^^^\n" +"SyntaxError: did you forget parentheses around the comprehension target?\n" +">>> # flatten a list using a listcomp with two 'for'\n" +">>> vec = [[1,2,3], [4,5,6], [7,8,9]]\n" +">>> [num for elem in vec for num in elem]\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9]" #: ../../tutorial/datastructures.rst:279 msgid "" @@ -856,6 +883,29 @@ msgid "" ">>> a ^ b # letters in a or b but not both\n" "{'r', 'd', 'b', 'm', 'z', 'l'}" msgstr "" +">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" +">>> print(basket) # show that duplicates have been " +"removed\n" +"{'orange', 'banana', 'pear', 'apple'}\n" +">>> 'orange' in basket # fast membership testing\n" +"True\n" +">>> 'crabgrass' in basket\n" +"False\n" +"\n" +">>> # Demonstrate set operations on unique letters from two words\n" +">>>\n" +">>> a = set('abracadabra')\n" +">>> b = set('alacazam')\n" +">>> a # unique letters in a\n" +"{'a', 'r', 'b', 'c', 'd'}\n" +">>> a - b # letters in a but not in b\n" +"{'r', 'd', 'b'}\n" +">>> a | b # letters in a or b or both\n" +"{'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}\n" +">>> a & b # letters in both a and b\n" +"{'a', 'c'}\n" +">>> a ^ b # letters in a or b but not both\n" +"{'r', 'd', 'b', 'm', 'z', 'l'}" #: ../../tutorial/datastructures.rst:482 msgid "" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index dc13c64d29..03bdd9a514 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -215,6 +215,14 @@ msgid "" ">>> repr(math.pi)\n" "'3.141592653589793'" msgstr "" +">>> format(math.pi, '.12g') # give 12 significant digits\n" +"'3.14159265359'\n" +"\n" +">>> format(math.pi, '.2f') # give 2 digits after the point\n" +"'3.14'\n" +"\n" +">>> repr(math.pi)\n" +"'3.141592653589793'" #: ../../tutorial/floatingpoint.rst:111 msgid "" @@ -492,6 +500,23 @@ msgid "" "digits!\n" "-0.0051575902860057365" msgstr "" +">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,\n" +"... -143401161400469.7, 266262841.31058735, -0.003244936839808227]\n" +">>> float(sum(map(Fraction, arr))) # Exact summation with single rounding\n" +"8.042173697819788e-13\n" +">>> math.fsum(arr) # Single rounding\n" +"8.042173697819788e-13\n" +">>> sum(arr) # Multiple roundings in extended " +"precision\n" +"8.042178034628478e-13\n" +">>> total = 0.0\n" +">>> for x in arr:\n" +"... total += x # Multiple roundings in standard " +"precision\n" +"...\n" +">>> total # Straight addition has no correct " +"digits!\n" +"-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260 msgid "Representation Error" diff --git a/tutorial/interpreter.po b/tutorial/interpreter.po index 19491986f5..3df92a2a1e 100644 --- a/tutorial/interpreter.po +++ b/tutorial/interpreter.po @@ -221,6 +221,11 @@ msgid "" "...\n" "Be careful not to fall off!" msgstr "" +">>> the_world_is_flat = True\n" +">>> if the_world_is_flat:\n" +"... print(\"Be careful not to fall off!\")\n" +"...\n" +"Be careful not to fall off!" #: ../../tutorial/interpreter.rst:118 msgid "For more on interactive mode, see :ref:`tut-interac`." @@ -274,7 +279,7 @@ msgstr "比如,聲明使用 Windows-1252 編碼,源碼檔案要寫成: ::" #: ../../tutorial/interpreter.rst:150 msgid "# -*- coding: cp1252 -*-" -msgstr "" +msgstr "# -*- coding: cp1252 -*-" #: ../../tutorial/interpreter.rst:152 msgid "" diff --git a/tutorial/modules.po b/tutorial/modules.po index 10ae8543c9..f3c2c2029e 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -861,6 +861,29 @@ msgid "" " karaoke.py\n" " ..." msgstr "" +"sound/ Top-level package\n" +" __init__.py Initialize the sound package\n" +" formats/ Subpackage for file format conversions\n" +" __init__.py\n" +" wavread.py\n" +" wavwrite.py\n" +" aiffread.py\n" +" aiffwrite.py\n" +" auread.py\n" +" auwrite.py\n" +" ...\n" +" effects/ Subpackage for sound effects\n" +" __init__.py\n" +" echo.py\n" +" surround.py\n" +" reverse.py\n" +" ...\n" +" filters/ Subpackage for filters\n" +" __init__.py\n" +" equalizer.py\n" +" vocoder.py\n" +" karaoke.py\n" +" ..." #: ../../tutorial/modules.rst:438 msgid "" @@ -1046,6 +1069,14 @@ msgid "" "def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" " return msg[::-1] # in the case of a 'from sound.effects import *'" msgstr "" +"__all__ = [\n" +" \"echo\", # refers to the 'echo.py' file\n" +" \"surround\", # refers to the 'surround.py' file\n" +" \"reverse\", # !!! refers to the 'reverse' function now !!!\n" +"]\n" +"\n" +"def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" +" return msg[::-1] # in the case of a 'from sound.effects import *'" #: ../../tutorial/modules.rst:534 msgid "" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index deded95c48..ed5399b03b 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -145,6 +145,16 @@ msgid "" "... conv['frac_digits'], x), grouping=True)\n" "'$1,234,567.80'" msgstr "" +">>> import locale\n" +">>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')\n" +"'English_United States.1252'\n" +">>> conv = locale.localeconv() # get a mapping of conventions\n" +">>> x = 1234567.8\n" +">>> locale.format_string(\"%d\", x, grouping=True)\n" +"'1,234,567'\n" +">>> locale.format_string(\"%s%.*f\", (conv['currency_symbol'],\n" +"... conv['frac_digits'], x), grouping=True)\n" +"'$1,234,567.80'" #: ../../tutorial/stdlib2.rst:72 msgid "Templating" @@ -321,6 +331,24 @@ msgid "" "\n" " start += extra_size + comp_size # skip to the next header" msgstr "" +"import struct\n" +"\n" +"with open('myfile.zip', 'rb') as f:\n" +" data = f.read()\n" +"\n" +"start = 0\n" +"for i in range(3): # show the first 3 file headers\n" +" start += 14\n" +" fields = struct.unpack('>> import weakref, gc\n" +">>> class A:\n" +"... def __init__(self, value):\n" +"... self.value = value\n" +"... def __repr__(self):\n" +"... return str(self.value)\n" +"...\n" +">>> a = A(10) # create a reference\n" +">>> d = weakref.WeakValueDictionary()\n" +">>> d['primary'] = a # does not create a reference\n" +">>> d['primary'] # fetch the object if it is still alive\n" +"10\n" +">>> del a # remove the one reference\n" +">>> gc.collect() # run garbage collection right away\n" +"0\n" +">>> d['primary'] # entry was automatically removed\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" d['primary'] # entry was automatically removed\n" +" File \"C:/python313/lib/weakref.py\", line 46, in __getitem__\n" +" o = self.data[key]()\n" +"KeyError: 'primary'" #: ../../tutorial/stdlib2.rst:290 msgid "Tools for Working with Lists" @@ -673,6 +723,12 @@ msgid "" ">>> [heappop(data) for i in range(3)] # fetch the three smallest entries\n" "[-5, 0, 1]" msgstr "" +">>> from heapq import heapify, heappop, heappush\n" +">>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]\n" +">>> heapify(data) # rearrange the list into heap order\n" +">>> heappush(data, -5) # add a new entry\n" +">>> [heappop(data) for i in range(3)] # fetch the three smallest entries\n" +"[-5, 0, 1]" #: ../../tutorial/stdlib2.rst:356 msgid "Decimal Floating-Point Arithmetic" From a553961a973754c90a1f78a8beff604c2902e318 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 05:51:25 +0000 Subject: [PATCH 4/8] Translate code comments and docstrings, apply review suggestions Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/classes.po | 14 +++++++------- tutorial/controlflow.po | 6 +++--- tutorial/index.po | 2 +- tutorial/introduction.po | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tutorial/classes.po b/tutorial/classes.po index 9aa4e7481f..04fdf46889 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -824,20 +824,20 @@ msgid "" msgstr "" "class Dog:\n" "\n" -" kind = 'canine' # class variable shared by all instances\n" +" kind = 'canine' # 所有實例共享的類別變數\n" "\n" " def __init__(self, name):\n" -" self.name = name # instance variable unique to each instance\n" +" self.name = name # 每個實例獨有的實例變數\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" -">>> d.kind # shared by all dogs\n" +">>> d.kind # 所有狗共享\n" "'canine'\n" -">>> e.kind # shared by all dogs\n" +">>> e.kind # 所有狗共享\n" "'canine'\n" -">>> d.name # unique to d\n" +">>> d.name # d 獨有\n" "'Fido'\n" -">>> e.name # unique to e\n" +">>> e.name # e 獨有\n" "'Buddy'" #: ../../tutorial/classes.rst:422 @@ -1655,7 +1655,7 @@ msgid "" " return self.data[self.index]" msgstr "" "class Reverse:\n" -" \"\"\"Iterator for looping over a sequence backwards.\"\"\"\n" +" \"\"\"用於向後迴圈遍歷序列的迭代器。\"\"\"\n" " def __init__(self, data):\n" " self.data = data\n" " self.index = len(data)\n" diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 321995254e..f1ca43a013 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -159,15 +159,15 @@ msgid "" " if status == 'active':\n" " active_users[user] = status" msgstr "" -"# Create a sample collection\n" +"# 建立一個範例集合\n" "users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n" "\n" -"# Strategy: Iterate over a copy\n" +"# 策略:對副本進行迭代\n" "for user, status in users.copy().items():\n" " if status == 'inactive':\n" " del users[user]\n" "\n" -"# Strategy: Create a new collection\n" +"# 策略:建立一個新集合\n" "active_users = {}\n" "for user, status in users.items():\n" " if status == 'active':\n" diff --git a/tutorial/index.po b/tutorial/index.po index b9a9a6bf14..7203f4c06c 100644 --- a/tutorial/index.po +++ b/tutorial/index.po @@ -77,7 +77,7 @@ msgid "" "Python interpreter handy for hands-on experience, but all examples are self-" "contained, so the tutorial can be read off-line as well." msgstr "" -"這份教學將非正式地介紹 Python 語言與系統的基本概念及功能。請注意,它預期你對程式" +"這份教學將非常規地介紹 Python 語言與系統的基本概念及功能。請注意,它預期你對程式" "設計有基本的了解。實際用 Python 直譯器進行實際操作將有助於學習,但所有範例都是" "獨立完整的,所以這份教學也可以離線閱讀。" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index 3dd340120e..7116cfb556 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -45,7 +45,7 @@ msgid "" "hovering over or tapping a code example), which strips prompts and omits " "output, to copy and paste the input lines into your interpreter." msgstr "" -"你可以使用\"複製\"按鈕(當游標移至程式碼範例上方或點選程式碼範例時,它會出現在右上角)," +"你可以使用 \"Copy\" 按鈕(當游標移至程式碼範例上方或點選程式碼範例時,它會出現在右上角)," "這會去除提示字元並略過輸出,讓你可以複製貼上輸入行到你的直譯器。" #: ../../tutorial/introduction.rst:22 From 969797e34e35c7d3642a4a22152d72dbf656feb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 06:16:19 +0000 Subject: [PATCH 5/8] Translate code comments and docstrings (batch 1) Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/classes.po | 18 +++++++-------- tutorial/controlflow.po | 46 +++++++++++++++++++------------------- tutorial/datastructures.po | 26 ++++++++++----------- tutorial/floatingpoint.po | 8 +++---- tutorial/introduction.po | 22 +++++++++--------- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/tutorial/classes.po b/tutorial/classes.po index 04fdf46889..5a92b8fa7a 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -831,9 +831,9 @@ msgstr "" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" -">>> d.kind # 所有狗共享\n" +">>> d.kind # 為所有 Dog 實例所共享\n" "'canine'\n" -">>> e.kind # 所有狗共享\n" +">>> e.kind # 為所有 Dog 實例所共享\n" "'canine'\n" ">>> d.name # d 獨有\n" "'Fido'\n" @@ -1397,7 +1397,7 @@ msgid "" " for item in iterable:\n" " self.items_list.append(item)\n" "\n" -" __update = update # private copy of original update() method\n" +" __update = update # 原始 update() 方法的私有副本\n" "\n" "class MappingSubclass(Mapping):\n" "\n" @@ -1416,13 +1416,13 @@ msgstr "" " for item in iterable:\n" " self.items_list.append(item)\n" "\n" -" __update = update # private copy of original update() method\n" +" __update = update # 原始 update() 方法的私有副本\n" "\n" "class MappingSubclass(Mapping):\n" "\n" " def update(self, keys, values):\n" -" # provides new signature for update()\n" -" # but does not break __init__()\n" +" # 為 update() 提供新的函式簽名\n" +" # 但不會破壞 __init__()\n" " for item in zip(keys, values):\n" " self.items_list.append(item)" @@ -1655,7 +1655,7 @@ msgid "" " return self.data[self.index]" msgstr "" "class Reverse:\n" -" \"\"\"用於向後迴圈遍歷序列的迭代器。\"\"\"\n" +" \"\"\"用於向後迴圈遍歷序列的疊代器。\"\"\"\n" " def __init__(self, data):\n" " self.data = data\n" " self.index = len(data)\n" @@ -1813,12 +1813,12 @@ 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)) # sum of squares\n" +">>> 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)) # dot product\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" diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index f1ca43a013..18eb9c9f0a 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -125,7 +125,7 @@ msgid "" "window 6\n" "defenestrate 12" msgstr "" -">>> # Measure some strings:\n" +">>> # 測量一些字串:\n" ">>> words = ['cat', 'window', 'defenestrate']\n" ">>> for w in words:\n" "... print(w, len(w))\n" @@ -162,7 +162,7 @@ msgstr "" "# 建立一個範例集合\n" "users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n" "\n" -"# 策略:對副本進行迭代\n" +"# 策略:對副本進行疊代\n" "for user, status in users.copy().items():\n" " if status == 'inactive':\n" " del users[user]\n" @@ -470,7 +470,7 @@ msgstr "" "... print(n, 'equals', x, '*', n//x)\n" "... break\n" "... else:\n" -"... # loop fell through without finding a factor\n" +"... # 迴圈結束但沒有找到因數\n" "... print(n, 'is a prime number')\n" "...\n" "2 is a prime number\n" @@ -536,7 +536,7 @@ msgid "" "..." msgstr "" ">>> while True:\n" -"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n" +"... pass # 忙碌等待鍵盤中斷 (Ctrl+C)\n" "..." #: ../../tutorial/controlflow.rst:266 @@ -570,7 +570,7 @@ msgid "" "..." msgstr "" ">>> def initlog(*args):\n" -"... pass # Remember to implement this!\n" +"... pass # 記得要實作這個!\n" "..." #: ../../tutorial/controlflow.rst:284 @@ -667,7 +667,7 @@ msgid "" " case _:\n" " raise ValueError(\"Not a point\")" msgstr "" -"# point is an (x, y) tuple\n" +"# point 是一個 (x, y) 元組\n" "match point:\n" " case (0, 0):\n" " print(\"Origin\")\n" @@ -987,15 +987,15 @@ 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): # write Fibonacci series less than n\n" -"... \"\"\"Print a Fibonacci series less than n.\"\"\"\n" +">>> 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" -">>> # Now call the function we just defined:\n" +">>> # 現在呼叫我們剛才定義的函式:\n" ">>> fib(2000)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597" @@ -1131,17 +1131,17 @@ msgid "" ">>> f100 # write the result\n" "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]" msgstr "" -">>> def fib2(n): # return Fibonacci series up to n\n" -"... \"\"\"Return a list containing the Fibonacci series up to n.\"\"\"\n" +">>> def fib2(n): # 回傳到 n 為止的費氏數列\n" +"... \"\"\"回傳包含到 n 為止的費氏數列的列表。\"\"\"\n" "... result = []\n" "... a, b = 0, 1\n" "... while a < n:\n" -"... result.append(a) # see below\n" +"... result.append(a) # 見下方\n" "... a, b = b, a+b\n" "... return result\n" "...\n" -">>> f100 = fib2(100) # call it\n" -">>> f100 # write the result\n" +">>> f100 = fib2(100) # 呼叫它\n" +">>> f100 # 寫出結果\n" "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]" #: ../../tutorial/controlflow.rst:550 @@ -1401,9 +1401,9 @@ msgid "" msgstr "" "parrot(1000) # 1 positional " "argument\n" -"parrot(voltage=1000) # 1 keyword argument\n" -"parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments\n" -"parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments\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 positional " "arguments\n" "parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " @@ -1421,11 +1421,11 @@ msgid "" "parrot(110, voltage=220) # duplicate value for the same argument\n" "parrot(actor='John Cleese') # unknown keyword argument" msgstr "" -"parrot() # required argument missing\n" +"parrot() # 缺少必要引數\n" "parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword " "argument\n" -"parrot(110, voltage=220) # duplicate value for the same argument\n" -"parrot(actor='John Cleese') # unknown keyword argument" +"parrot(110, voltage=220) # 同一個引數有重複值\n" +"parrot(actor='John Cleese') # 未知的關鍵字引數" #: ../../tutorial/controlflow.rst:684 msgid "" @@ -1989,7 +1989,7 @@ msgid "" "list\n" "[3, 4, 5]" msgstr "" -">>> list(range(3, 6)) # normal call with separate arguments\n" +">>> list(range(3, 6)) # 使用分離引數的一般呼叫\n" "[3, 4, 5]\n" ">>> args = [3, 6]\n" ">>> list(range(*args)) # call with arguments unpacked from a " @@ -2160,9 +2160,9 @@ msgid "" "No, really, it doesn't do anything." msgstr "" ">>> def my_function():\n" -"... \"\"\"Do nothing, but document it.\n" +"... \"\"\"不做任何事,但有文件說明。\n" "...\n" -"... No, really, it doesn't do anything.\n" +"... 不,真的,它什麼都不做。\n" "... \"\"\"\n" "... pass\n" "...\n" diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 0f7b43f4aa..ea5a0effba 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -458,23 +458,23 @@ msgid "" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" ">>> vec = [-4, -2, 0, 2, 4]\n" -">>> # create a new list with the values doubled\n" +">>> # 建立一個值加倍的新列表\n" ">>> [x*2 for x in vec]\n" "[-8, -4, 0, 4, 8]\n" -">>> # filter the list to exclude negative numbers\n" +">>> # 過濾列表以排除負數\n" ">>> [x for x in vec if x >= 0]\n" "[0, 2, 4]\n" -">>> # apply a function to all the elements\n" +">>> # 對所有元素套用函式\n" ">>> [abs(x) for x in vec]\n" "[4, 2, 0, 2, 4]\n" -">>> # call a method on each element\n" +">>> # 對每個元素呼叫方法\n" ">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n" ">>> [weapon.strip() for weapon in freshfruit]\n" "['banana', 'loganberry', 'passion fruit']\n" -">>> # create a list of 2-tuples like (number, square)\n" +">>> # 建立像 (數字, 平方) 的 2-元組列表\n" ">>> [(x, x**2) for x in range(6)]\n" "[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n" -">>> # the tuple must be parenthesized, otherwise an error is raised\n" +">>> # 元組必須加上括號,否則會產生錯誤\n" ">>> [x, x**2 for x in range(6)]\n" " File \"\", line 1\n" " [x, x**2 for x in range(6)]\n" @@ -887,24 +887,24 @@ msgstr "" ">>> print(basket) # show that duplicates have been " "removed\n" "{'orange', 'banana', 'pear', 'apple'}\n" -">>> 'orange' in basket # fast membership testing\n" +">>> 'orange' in basket # 快速成員測試\n" "True\n" ">>> 'crabgrass' in basket\n" "False\n" "\n" -">>> # Demonstrate set operations on unique letters from two words\n" +">>> # 示範對兩個字的唯一字母進行集合運算\n" ">>>\n" ">>> a = set('abracadabra')\n" ">>> b = set('alacazam')\n" -">>> a # unique letters in a\n" +">>> a # a 中的唯一字母\n" "{'a', 'r', 'b', 'c', 'd'}\n" -">>> a - b # letters in a but not in b\n" +">>> a - b # 在 a 中但不在 b 中的字母\n" "{'r', 'd', 'b'}\n" -">>> a | b # letters in a or b or both\n" +">>> a | b # 在 a 或 b 或兩者中的字母\n" "{'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}\n" -">>> a & b # letters in both a and b\n" +">>> a & b # 同時在 a 和 b 中的字母\n" "{'a', 'c'}\n" -">>> a ^ b # letters in a or b but not both\n" +">>> a ^ b # 在 a 或 b 中但不在兩者中的字母\n" "{'r', 'd', 'b', 'm', 'z', 'l'}" #: ../../tutorial/datastructures.rst:482 diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 03bdd9a514..29fc6fff18 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -215,10 +215,10 @@ msgid "" ">>> repr(math.pi)\n" "'3.141592653589793'" msgstr "" -">>> format(math.pi, '.12g') # give 12 significant digits\n" +">>> format(math.pi, '.12g') # 給出 12 個有效位數\n" "'3.14159265359'\n" "\n" -">>> format(math.pi, '.2f') # give 2 digits after the point\n" +">>> format(math.pi, '.2f') # 小數點後給出 2 位數字\n" "'3.14'\n" "\n" ">>> repr(math.pi)\n" @@ -502,9 +502,9 @@ msgid "" msgstr "" ">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,\n" "... -143401161400469.7, 266262841.31058735, -0.003244936839808227]\n" -">>> float(sum(map(Fraction, arr))) # Exact summation with single rounding\n" +">>> float(sum(map(Fraction, arr))) # 單次四捨五入的精確加總\n" "8.042173697819788e-13\n" -">>> math.fsum(arr) # Single rounding\n" +">>> math.fsum(arr) # 單次四捨五入\n" "8.042173697819788e-13\n" ">>> sum(arr) # Multiple roundings in extended " "precision\n" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index 7116cfb556..e399fde9b4 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -75,10 +75,10 @@ msgid "" " # ... and now a third!\n" "text = \"# This is not a comment because it's inside quotes.\"" msgstr "" -"# this is the first comment\n" -"spam = 1 # and this is the second comment\n" -" # ... and now a third!\n" -"text = \"# This is not a comment because it's inside quotes.\"" +"# 這是第一個註解\n" +"spam = 1 # 這是第二個註解\n" +" # ... 現在是第三個!\n" +"text = \"# 這不是註解,因為它在引號內。\"" #: ../../tutorial/introduction.rst:41 msgid "Using Python as a Calculator" @@ -124,7 +124,7 @@ msgstr "" "20\n" ">>> (50 - 5*6) / 4\n" "5.0\n" -">>> 8 / 5 # division always returns a floating-point number\n" +">>> 8 / 5 # 除法總是回傳浮點數\n" "1.6" #: ../../tutorial/introduction.rst:67 @@ -158,14 +158,14 @@ msgid "" ">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n" "17" msgstr "" -">>> 17 / 3 # classic division returns a float\n" +">>> 17 / 3 # 傳統除法回傳浮點數\n" "5.666666666666667\n" ">>>\n" -">>> 17 // 3 # floor division discards the fractional part\n" +">>> 17 // 3 # 下取整除法捨棄小數部分\n" "5\n" -">>> 17 % 3 # the % operator returns the remainder of the division\n" +">>> 17 % 3 # % 運算子回傳除法的餘數\n" "2\n" -">>> 5 * 3 + 2 # floored quotient * divisor + remainder\n" +">>> 5 * 3 + 2 # 下取整商 * 除數 + 餘數\n" "17" #: ../../tutorial/introduction.rst:85 @@ -181,9 +181,9 @@ msgid "" ">>> 2 ** 7 # 2 to the power of 7\n" "128" msgstr "" -">>> 5 ** 2 # 5 squared\n" +">>> 5 ** 2 # 5 的平方\n" "25\n" -">>> 2 ** 7 # 2 to the power of 7\n" +">>> 2 ** 7 # 2 的 7 次方\n" "128" #: ../../tutorial/introduction.rst:92 From 06b87f4b268a4bece7740e7e6297f7d7800d7cb1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 06:30:12 +0000 Subject: [PATCH 6/8] Complete translation of all code comments and docstrings Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/introduction.po | 54 ++++++++++++++++++++-------------------- tutorial/modules.po | 10 ++++---- tutorial/stdlib2.po | 26 +++++++++---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tutorial/introduction.po b/tutorial/introduction.po index e399fde9b4..6efc27d043 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -221,7 +221,7 @@ msgid "" " File \"\", line 1, in \n" "NameError: name 'n' is not defined" msgstr "" -">>> n # try to access an undefined variable\n" +">>> n # 嘗試存取未定義的變數\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "NameError: name 'n' is not defined" @@ -319,11 +319,11 @@ msgid "" ">>> '1975' # digits and numerals enclosed in quotes are also strings\n" "'1975'" msgstr "" -">>> 'spam eggs' # single quotes\n" +">>> 'spam eggs' # 單引號\n" "'spam eggs'\n" -">>> \"Paris rabbit got your back :)! Yay!\" # double quotes\n" +">>> \"Paris rabbit got your back :)! Yay!\" # 雙引號\n" "'Paris rabbit got your back :)! Yay!'\n" -">>> '1975' # digits and numerals enclosed in quotes are also strings\n" +">>> '1975' # 以引號包含的數字和數值也是字串\n" "'1975'" #: ../../tutorial/introduction.rst:158 @@ -349,7 +349,7 @@ msgid "" msgstr "" ">>> 'doesn\\'t' # use \\' to escape the single quote...\n" "\"doesn't\"\n" -">>> \"doesn't\" # ...or use double quotes instead\n" +">>> \"doesn't\" # ...或改用雙引號\n" "\"doesn't\"\n" ">>> '\"Yes,\" they said.'\n" "'\"Yes,\" they said.'\n" @@ -378,8 +378,8 @@ msgid "" "First line.\n" "Second line." msgstr "" -">>> s = 'First line.\\nSecond line.' # \\n means newline\n" -">>> s # without print(), special characters are included in the string\n" +">>> s = 'First line.\\nSecond line.' # \\n 表示換行\n" +">>> s # 沒有 print(),特殊字元會包含在字串中\n" "'First line.\\nSecond line.'\n" ">>> print(s) # with print(), special characters are interpreted, so \\n " "produces new line\n" @@ -403,10 +403,10 @@ msgid "" ">>> print(r'C:\\some\\name') # note the r before the quote\n" "C:\\some\\name" msgstr "" -">>> print('C:\\some\\name') # here \\n means newline!\n" +">>> print('C:\\some\\name') # 這裡 \\n 表示換行!\n" "C:\\some\n" "ame\n" -">>> print(r'C:\\some\\name') # note the r before the quote\n" +">>> print(r'C:\\some\\name') # 注意引號前的 r\n" "C:\\some\\name" #: ../../tutorial/introduction.rst:193 @@ -468,7 +468,7 @@ msgid "" ">>> 3 * 'un' + 'ium'\n" "'unununium'" msgstr "" -">>> # 3 times 'un', followed by 'ium'\n" +">>> # 3 次 'un',接著是 'ium'\n" ">>> 3 * 'un' + 'ium'\n" "'unununium'" @@ -526,7 +526,7 @@ msgid "" "SyntaxError: invalid syntax" msgstr "" ">>> prefix = 'Py'\n" -">>> prefix 'thon' # can't concatenate a variable and a string literal\n" +">>> prefix 'thon' # 無法串接變數和字串字面值\n" " File \"\", line 1\n" " prefix 'thon'\n" " ^^^^^^\n" @@ -568,9 +568,9 @@ msgid "" "'n'" msgstr "" ">>> word = 'Python'\n" -">>> word[0] # character in position 0\n" +">>> word[0] # 位置 0 的字元\n" "'P'\n" -">>> word[5] # character in position 5\n" +">>> word[5] # 位置 5 的字元\n" "'n'" #: ../../tutorial/introduction.rst:264 @@ -587,9 +587,9 @@ msgid "" ">>> word[-6]\n" "'P'" msgstr "" -">>> word[-1] # last character\n" +">>> word[-1] # 最後一個字元\n" "'n'\n" -">>> word[-2] # second-last character\n" +">>> word[-2] # 倒數第二個字元\n" "'o'\n" ">>> word[-6]\n" "'P'" @@ -614,9 +614,9 @@ msgid "" ">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" "'tho'" msgstr "" -">>> word[0:2] # characters from position 0 (included) to 2 (excluded)\n" +">>> word[0:2] # 從位置 0 (包含) 到 2 (不包含) 的字元\n" "'Py'\n" -">>> word[2:5] # characters from position 2 (included) to 5 (excluded)\n" +">>> word[2:5] # 從位置 2 (包含) 到 5 (不包含) 的字元\n" "'tho'" #: ../../tutorial/introduction.rst:283 @@ -636,11 +636,11 @@ msgid "" ">>> word[-2:] # characters from the second-last (included) to the end\n" "'on'" msgstr "" -">>> word[:2] # character from the beginning to position 2 (excluded)\n" +">>> word[:2] # 從開頭到位置 2 (不包含) 的字元\n" "'Py'\n" -">>> word[4:] # characters from position 4 (included) to the end\n" +">>> word[4:] # 從位置 4 (包含) 到結尾的字元\n" "'on'\n" -">>> word[-2:] # characters from the second-last (included) to the end\n" +">>> word[-2:] # 從倒數第二個 (包含) 到結尾的字元\n" "'on'" #: ../../tutorial/introduction.rst:293 @@ -889,11 +889,11 @@ msgid "" ">>> squares[-3:] # slicing returns a new list\n" "[9, 16, 25]" msgstr "" -">>> squares[0] # indexing returns the item\n" +">>> squares[0] # 索引回傳項目\n" "1\n" ">>> squares[-1]\n" "25\n" -">>> squares[-3:] # slicing returns a new list\n" +">>> squares[-3:] # 切片回傳新列表\n" "[9, 16, 25]" #: ../../tutorial/introduction.rst:407 @@ -925,10 +925,10 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125]" msgstr "" -">>> cubes = [1, 8, 27, 65, 125] # something's wrong here\n" -">>> 4 ** 3 # the cube of 4 is 64, not 65!\n" +">>> cubes = [1, 8, 27, 65, 125] # 這裡有問題\n" +">>> 4 ** 3 # 4 的立方是 64,不是 65!\n" "64\n" -">>> cubes[3] = 64 # replace the wrong value\n" +">>> cubes[3] = 64 # 替換錯誤的值\n" ">>> cubes\n" "[1, 8, 27, 64, 125]" @@ -947,8 +947,8 @@ msgid "" ">>> cubes\n" "[1, 8, 27, 64, 125, 216, 343]" msgstr "" -">>> cubes.append(216) # add the cube of 6\n" -">>> cubes.append(7 ** 3) # and the cube of 7\n" +">>> cubes.append(216) # 加入 6 的立方\n" +">>> cubes.append(7 ** 3) # 以及 7 的立方\n" ">>> cubes\n" "[1, 8, 27, 64, 125, 216, 343]" diff --git a/tutorial/modules.po b/tutorial/modules.po index f3c2c2029e..1a8b043bb8 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -1070,13 +1070,13 @@ msgid "" " return msg[::-1] # in the case of a 'from sound.effects import *'" msgstr "" "__all__ = [\n" -" \"echo\", # refers to the 'echo.py' file\n" -" \"surround\", # refers to the 'surround.py' file\n" -" \"reverse\", # !!! refers to the 'reverse' function now !!!\n" +" \"echo\", # 指向 'echo.py' 檔案\n" +" \"surround\", # 指向 'surround.py' 檔案\n" +" \"reverse\", # !!! 現在指向 'reverse' 函式 !!!\n" "]\n" "\n" -"def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" -" return msg[::-1] # in the case of a 'from sound.effects import *'" +"def reverse(msg: str): # <-- 這個名稱遮蔽了 'reverse.py' 子模組\n" +" return msg[::-1] # 在 'from sound.effects import *' 的情況下" #: ../../tutorial/modules.rst:534 msgid "" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index ed5399b03b..2fd49374a5 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -148,7 +148,7 @@ msgstr "" ">>> import locale\n" ">>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')\n" "'English_United States.1252'\n" -">>> conv = locale.localeconv() # get a mapping of conventions\n" +">>> conv = locale.localeconv() # 取得慣例的對映\n" ">>> x = 1234567.8\n" ">>> locale.format_string(\"%d\", x, grouping=True)\n" "'1,234,567'\n" @@ -337,7 +337,7 @@ msgstr "" " data = f.read()\n" "\n" "start = 0\n" -"for i in range(3): # show the first 3 file headers\n" +"for i in range(3): # 顯示前 3 個檔案標頭\n" " start += 14\n" " fields = struct.unpack('>> a = A(10) # create a reference\n" +">>> a = A(10) # 建立一個參考\n" ">>> d = weakref.WeakValueDictionary()\n" -">>> d['primary'] = a # does not create a reference\n" -">>> d['primary'] # fetch the object if it is still alive\n" +">>> d['primary'] = a # 不會建立參考\n" +">>> d['primary'] # 如果物件仍然存在則取得它\n" "10\n" -">>> del a # remove the one reference\n" -">>> gc.collect() # run garbage collection right away\n" +">>> del a # 移除一個參考\n" +">>> gc.collect() # 立即執行垃圾回收\n" "0\n" -">>> d['primary'] # entry was automatically removed\n" +">>> d['primary'] # 項目被自動移除\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" -" d['primary'] # entry was automatically removed\n" +" d['primary'] # 項目被自動移除\n" " File \"C:/python313/lib/weakref.py\", line 46, in __getitem__\n" " o = self.data[key]()\n" "KeyError: 'primary'" @@ -725,9 +725,9 @@ msgid "" msgstr "" ">>> from heapq import heapify, heappop, heappush\n" ">>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]\n" -">>> heapify(data) # rearrange the list into heap order\n" -">>> heappush(data, -5) # add a new entry\n" -">>> [heappop(data) for i in range(3)] # fetch the three smallest entries\n" +">>> heapify(data) # 將列表重新排列為堆積順序\n" +">>> heappush(data, -5) # 加入新項目\n" +">>> [heappop(data) for i in range(3)] # 取得三個最小的項目\n" "[-5, 0, 1]" #: ../../tutorial/stdlib2.rst:356 From 73c5cfc0eb6f2e5c42d738549b4aa981e0b6155f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Jul 2025 07:04:00 +0000 Subject: [PATCH 7/8] Apply all review suggestions and fix msgid translations Co-authored-by: mattwang44 <24987826+mattwang44@users.noreply.github.com> --- tutorial/classes.po | 2 +- tutorial/controlflow.po | 23 +++++++++-------------- tutorial/datastructures.po | 9 ++++----- tutorial/floatingpoint.po | 11 +++++------ tutorial/introduction.po | 6 +++--- tutorial/modules.po | 4 ++-- tutorial/stdlib2.po | 8 ++++---- 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/tutorial/classes.po b/tutorial/classes.po index 5a92b8fa7a..c1284d3f93 100644 --- a/tutorial/classes.po +++ b/tutorial/classes.po @@ -1397,7 +1397,7 @@ msgid "" " for item in iterable:\n" " self.items_list.append(item)\n" "\n" -" __update = update # 原始 update() 方法的私有副本\n" +" __update = update # private copy of original update() method\n" "\n" "class MappingSubclass(Mapping):\n" "\n" diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 18eb9c9f0a..0075e51699 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -1132,7 +1132,7 @@ msgid "" "[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]" msgstr "" ">>> def fib2(n): # 回傳到 n 為止的費氏數列\n" -"... \"\"\"回傳包含到 n 為止的費氏數列的列表。\"\"\"\n" +"... \"\"\"回傳包含到 n 為止的費氏數列的串列。\"\"\"\n" "... result = []\n" "... a, b = 0, 1\n" "... while a < n:\n" @@ -1399,15 +1399,12 @@ msgid "" "parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " "keyword" msgstr "" -"parrot(1000) # 1 positional " -"argument\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 positional " -"arguments\n" -"parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " -"keyword" +"parrot(1000) # 1 個位置引數 +parrot(voltage=1000) # 1 個關鍵字引數 +parrot(voltage=1000000, action='VOOOOOM') # 2 個關鍵字引數 +parrot(action='VOOOOOM', voltage=1000000) # 2 個關鍵字引數 +parrot('a million', 'bereft of life', 'jump') # 3 個位置引數 +parrot('a thousand', state='pushing up the daisies') # 1 個位置引數、1 個關鍵字引數" #: ../../tutorial/controlflow.rst:677 msgid "but all the following calls would be invalid::" @@ -1422,8 +1419,7 @@ msgid "" "parrot(actor='John Cleese') # unknown keyword argument" msgstr "" "parrot() # 缺少必要引數\n" -"parrot(voltage=5.0, 'dead') # non-keyword argument after a keyword " -"argument\n" +"parrot(voltage=5.0, 'dead') # 關鍵字引數後面的非關鍵字引數\n" "parrot(110, voltage=220) # 同一個引數有重複值\n" "parrot(actor='John Cleese') # 未知的關鍵字引數" @@ -1992,8 +1988,7 @@ msgstr "" ">>> list(range(3, 6)) # 使用分離引數的一般呼叫\n" "[3, 4, 5]\n" ">>> args = [3, 6]\n" -">>> list(range(*args)) # call with arguments unpacked from a " -"list\n" +">>> list(range(*args)) # 以從串列解包而得的引數呼叫\n" "[3, 4, 5]" #: ../../tutorial/controlflow.rst:965 diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index ea5a0effba..beab2d6a70 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -458,10 +458,10 @@ msgid "" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" ">>> vec = [-4, -2, 0, 2, 4]\n" -">>> # 建立一個值加倍的新列表\n" +">>> # 建立一個值加倍的新串列\n" ">>> [x*2 for x in vec]\n" "[-8, -4, 0, 4, 8]\n" -">>> # 過濾列表以排除負數\n" +">>> # 過濾串列以排除負數\n" ">>> [x for x in vec if x >= 0]\n" "[0, 2, 4]\n" ">>> # 對所有元素套用函式\n" @@ -471,7 +471,7 @@ msgstr "" ">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n" ">>> [weapon.strip() for weapon in freshfruit]\n" "['banana', 'loganberry', 'passion fruit']\n" -">>> # 建立像 (數字, 平方) 的 2-元組列表\n" +">>> # 建立像 (數字, 平方) 的 2-元組串列\n" ">>> [(x, x**2) for x in range(6)]\n" "[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n" ">>> # 元組必須加上括號,否則會產生錯誤\n" @@ -884,8 +884,7 @@ msgid "" "{'r', 'd', 'b', 'm', 'z', 'l'}" msgstr "" ">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" -">>> print(basket) # show that duplicates have been " -"removed\n" +">>> print(basket) # 確認重複值已被移除\n" "{'orange', 'banana', 'pear', 'apple'}\n" ">>> 'orange' in basket # 快速成員測試\n" "True\n" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 29fc6fff18..1492e25182 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -506,16 +506,15 @@ msgstr "" "8.042173697819788e-13\n" ">>> math.fsum(arr) # 單次四捨五入\n" "8.042173697819788e-13\n" -">>> sum(arr) # Multiple roundings in extended " -"precision\n" +">>> sum(arr) # 在擴展精度中進行多次捨入\n" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" -"... total += x # Multiple roundings in standard " -"precision\n" +"... total += x # 在標準精度中進行多次捨入 " +"\n" "...\n" -">>> total # Straight addition has no correct " -"digits!\n" +">>> total # 直接相加沒有正確的數字 " +"\n" "-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260 diff --git a/tutorial/introduction.po b/tutorial/introduction.po index 6efc27d043..b2a44056c6 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -336,7 +336,7 @@ msgstr "" #: ../../tutorial/introduction.rst:161 msgid "" -">>> 'doesn\\'t' # use \\' to escape the single quote...\n" +">>> 'doesn\\'t' # 用 \\' 來跳脫單引號...\n" "\"doesn't\"\n" ">>> \"doesn't\" # ...or use double quotes instead\n" "\"doesn't\"\n" @@ -347,7 +347,7 @@ msgid "" ">>> '\"Isn\\'t,\" they said.'\n" "'\"Isn\\'t,\" they said.'" msgstr "" -">>> 'doesn\\'t' # use \\' to escape the single quote...\n" +">>> 'doesn\\'t' # 用 \\' 來跳脫單引號...\n" "\"doesn't\"\n" ">>> \"doesn't\" # ...或改用雙引號\n" "\"doesn't\"\n" @@ -893,7 +893,7 @@ msgstr "" "1\n" ">>> squares[-1]\n" "25\n" -">>> squares[-3:] # 切片回傳新列表\n" +">>> squares[-3:] # 切片回傳新串列\n" "[9, 16, 25]" #: ../../tutorial/introduction.rst:407 diff --git a/tutorial/modules.po b/tutorial/modules.po index 1a8b043bb8..96ac2156e3 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -1075,8 +1075,8 @@ msgstr "" " \"reverse\", # !!! 現在指向 'reverse' 函式 !!!\n" "]\n" "\n" -"def reverse(msg: str): # <-- 這個名稱遮蔽了 'reverse.py' 子模組\n" -" return msg[::-1] # 在 'from sound.effects import *' 的情況下" +"def reverse(msg: str): # 在 'from sound.effects import *' 的情況下\n" +" return msg[::-1] # 這個名稱遮蔽了 'reverse.py' 子模組" #: ../../tutorial/modules.rst:534 msgid "" diff --git a/tutorial/stdlib2.po b/tutorial/stdlib2.po index 2fd49374a5..90dd24f60f 100644 --- a/tutorial/stdlib2.po +++ b/tutorial/stdlib2.po @@ -578,12 +578,12 @@ msgstr "" "... def __repr__(self):\n" "... return str(self.value)\n" "...\n" -">>> a = A(10) # 建立一個參考\n" +">>> a = A(10) # 建立一個參照\n" ">>> d = weakref.WeakValueDictionary()\n" -">>> d['primary'] = a # 不會建立參考\n" +">>> d['primary'] = a # 不會建立參照\n" ">>> d['primary'] # 如果物件仍然存在則取得它\n" "10\n" -">>> del a # 移除一個參考\n" +">>> del a # 移除一個參照\n" ">>> gc.collect() # 立即執行垃圾回收\n" "0\n" ">>> d['primary'] # 項目被自動移除\n" @@ -725,7 +725,7 @@ msgid "" msgstr "" ">>> from heapq import heapify, heappop, heappush\n" ">>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]\n" -">>> heapify(data) # 將列表重新排列為堆積順序\n" +">>> heapify(data) # 將串列重新排列為堆積順序\n" ">>> heappush(data, -5) # 加入新項目\n" ">>> [heappop(data) for i in range(3)] # 取得三個最小的項目\n" "[-5, 0, 1]" From c1bb3feaa43d678a037f509c88c5a095688af260 Mon Sep 17 00:00:00 2001 From: "W. H. Wang" Date: Mon, 14 Jul 2025 15:30:53 +0800 Subject: [PATCH 8/8] Apply suggestions from code review --- tutorial/controlflow.po | 12 ++++++------ tutorial/introduction.po | 3 +-- tutorial/modules.po | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tutorial/controlflow.po b/tutorial/controlflow.po index 0075e51699..5f29a00603 100644 --- a/tutorial/controlflow.po +++ b/tutorial/controlflow.po @@ -1399,12 +1399,12 @@ msgid "" "parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 " "keyword" msgstr "" -"parrot(1000) # 1 個位置引數 -parrot(voltage=1000) # 1 個關鍵字引數 -parrot(voltage=1000000, action='VOOOOOM') # 2 個關鍵字引數 -parrot(action='VOOOOOM', voltage=1000000) # 2 個關鍵字引數 -parrot('a million', 'bereft of life', 'jump') # 3 個位置引數 -parrot('a thousand', state='pushing up the daisies') # 1 個位置引數、1 個關鍵字引數" +"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::" diff --git a/tutorial/introduction.po b/tutorial/introduction.po index b2a44056c6..fb045519ef 100644 --- a/tutorial/introduction.po +++ b/tutorial/introduction.po @@ -381,8 +381,7 @@ msgstr "" ">>> s = 'First line.\\nSecond line.' # \\n 表示換行\n" ">>> s # 沒有 print(),特殊字元會包含在字串中\n" "'First line.\\nSecond line.'\n" -">>> print(s) # with print(), special characters are interpreted, so \\n " -"produces new line\n" +">>> print(s) # 有 print(),特殊字元會被直譯,所以 \\n 會產生新的一行\n" "First line.\n" "Second line." diff --git a/tutorial/modules.po b/tutorial/modules.po index 96ac2156e3..83ea14a296 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -1075,7 +1075,7 @@ msgstr "" " \"reverse\", # !!! 現在指向 'reverse' 函式 !!!\n" "]\n" "\n" -"def reverse(msg: str): # 在 'from sound.effects import *' 的情況下\n" +"def reverse(msg: str): # <-- 在 'from sound.effects import *' 的情況下\n" " return msg[::-1] # 這個名稱遮蔽了 'reverse.py' 子模組" #: ../../tutorial/modules.rst:534