diff --git a/howto/argparse.po b/howto/argparse.po index cd3fbcb521..089914495b 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001-2023, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,13 +7,14 @@ # Liang-Bo Wang , 2016 # Adrian Liaw , 2018 # Phil Lin , 2022 +# Matt Wang , 2023 msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" -"PO-Revision-Date: 2022-01-31 17:33+0800\n" -"Last-Translator: Phil Lin \n" +"PO-Revision-Date: 2023-12-11 17:33+0800\n" +"Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -34,15 +34,15 @@ msgstr "作者" #: ../../howto/argparse.rst:7 msgid "Tshepang Mbambo" -msgstr "" +msgstr "Tshepang Mbambo" #: ../../howto/argparse.rst:11 msgid "" "This tutorial is intended to be a gentle introduction to :mod:`argparse`, " "the recommended command-line parsing module in the Python standard library." msgstr "" -"這個教學傾向簡介 Python 官方標準含式庫中推薦的命令列剖析模組 :mod:" -"`argparse`。" +"本教學旨在簡要介紹 :mod:`argparse` 這個 Python 標準函式庫中推薦的命令列剖析模" +"組。" #: ../../howto/argparse.rst:16 msgid "" @@ -51,9 +51,9 @@ msgid "" "`optparse`. Note also that :mod:`argparse` is based on :mod:`optparse`, and " "therefore very similar in terms of usage." msgstr "" -"另外兩個具有同樣功能的模組 :mod:`getopt` (等價於 C 語言中的 ``getopt()`` 模" -"組)以及被棄用的 :mod:`optparse`。而 :mod:`argparse` 也是根據 :mod:" -"`optparse` 為基礎發展而來,因此有非常接近的使用方式。" +"另外還有兩個模組可以完成相同的任務,即 :mod:`getopt`\\ (相當於 C 語言中的 " +"``getopt()``)和已棄用的 :mod:`optparse`。另請注意,:mod:`argparse` 是基於 :" +"mod:`optparse` 的,因此在用法上非常相似。" #: ../../howto/argparse.rst:24 msgid "Concepts" @@ -63,18 +63,20 @@ msgstr "概念" msgid "" "Let's show the sort of functionality that we are going to explore in this " "introductory tutorial by making use of the :command:`ls` command:" -msgstr "藉由命令 :command:`ls` 的使用開始這些功能的介紹:" +msgstr "" +"讓我們透過使用 :command:`ls` 指令來展示我們將在本介紹教學中探索的功能類型:" #: ../../howto/argparse.rst:48 msgid "A few concepts we can learn from the four commands:" -msgstr "我們可以從四個命令中可以學到的幾個概念:" +msgstr "我們可以從這四個命令中學到一些概念:" #: ../../howto/argparse.rst:50 msgid "" "The :command:`ls` command is useful when run without any options at all. It " "defaults to displaying the contents of the current directory." msgstr "" -"命令 :command:`ls` 在執行時不用其他參數就可以顯示出當前目錄底下的內容。" +":command:`ls` 命令即便在沒有任何選項的情況下執行仍非常有用。它預設顯示目前目" +"錄的內容。" #: ../../howto/argparse.rst:53 msgid "" @@ -87,11 +89,11 @@ msgid "" "position is *what you want copied,* and the second position is *where you " "want it copied to*." msgstr "" -"根據這樣的概念延伸後來舉個例子,如果我們想秀出一個不在目錄的資料夾 ``pypy`` " -"的內容。我們可以在命令後加上一個位置參數。會用位置參數這樣的名稱是因為程式會" -"知道輸入的參數該做的事情。這樣的概念很像另一個命令 :command:`cp`\\ ,基本的使" -"用方式是 ``cp SRC DEST``\\ 。第一個位置參數代表的是\\ *想要複製的目標*\\,第" -"二個位置的參數代表的則是\\ *想要複製到的地方*\\ 。" +"如果我們想要看到比它預設提供更多的內容,我們也需要多告訴它一點。在本例中,我" +"們希望它顯示不同的目錄 ``pypy``,我們做的是指定所謂的位置引數。之所以如此命名" +"是因為程式應該只根據該值在命令列中出現的位置來知道如何處理該值。這個概念與 :" +"command:`cp` 這樣的指令更相關,其最基本的用法是 ``cp SRC DEST``。第一個是\\ *" +"你想要複製的位置*,第二個是\\ *你想要複製過去的位置*。" #: ../../howto/argparse.rst:62 msgid "" @@ -99,8 +101,8 @@ msgid "" "display more info for each file instead of just showing the file names. The " "``-l`` in that case is known as an optional argument." msgstr "" -"現在我們想再增加一些,要顯示除了檔名之外更多的資訊。在這裡就可以選擇加上 ``-" -"l`` 這個參數。" +"現在假設我們想要改變程式的行為。在我們的範例中,我們顯示每個檔案的更多資訊," +"而不僅是顯示檔案名稱。在這種情況下,``-l`` 被稱為可選引數。" #: ../../howto/argparse.rst:66 msgid "" @@ -108,8 +110,8 @@ msgid "" "across a program you have never used before, and can figure out how it works " "simply by reading its help text." msgstr "" -"這是 help 文件的片段。對於以前從未使用過的程序來說非常有用,可以透過這些 " -"help 文件來了解這些該怎麼使用。" +"這是幫助文字的片段。它非常有用,因為當你遇到以前從未使用過的程式時,只需閱讀" +"其幫助文字即可了解它的工作原理。" #: ../../howto/argparse.rst:72 msgid "The basics" @@ -117,36 +119,31 @@ msgstr "基本用法" #: ../../howto/argparse.rst:74 msgid "Let us start with a very simple example which does (almost) nothing::" -msgstr "" -"我們以一個很簡單的例子開始下面的介紹:\n" -"\n" -"::" +msgstr "讓我們從一個非常簡單的例子開始,它(幾乎)什麼都不做: ::" #: ../../howto/argparse.rst:80 ../../howto/argparse.rst:188 #: ../../howto/argparse.rst:209 msgid "Following is a result of running the code:" -msgstr "下面是運行這些代碼的結果:" +msgstr "程式碼執行結果如下:" #: ../../howto/argparse.rst:97 ../../howto/argparse.rst:254 #: ../../howto/argparse.rst:298 msgid "Here is what is happening:" -msgstr "接者是發生的情況:" +msgstr "這是發生的事情:" #: ../../howto/argparse.rst:99 msgid "" "Running the script without any options results in nothing displayed to " "stdout. Not so useful." -msgstr "" -"運行這個腳本而沒有給與任何參數時就不會顯示任何東西至標準輸出畫面上。這裡並不" -"是這麼的有用。" +msgstr "執行不帶任何選項的腳本不會在標準輸出中顯示任何內容。不太有用。" #: ../../howto/argparse.rst:102 msgid "" "The second one starts to display the usefulness of the :mod:`argparse` " "module. We have done almost nothing, but already we get a nice help message." msgstr "" -"第二個我們呈現出了 :mod:`argparse` 模組的用處。我們幾乎沒有做什麼事情,但已經" -"得到一個很好的幫助信息。" +"第二個開始能夠顯現 :mod:`argparse` 模組的有用之處。我們幾乎什麼也沒做,但我們" +"已經收到了一個很好的幫助訊息。" #: ../../howto/argparse.rst:105 msgid "" @@ -155,28 +152,25 @@ msgid "" "else results in an error. But even then, we do get a useful usage message, " "also for free." msgstr "" -"這個 ``--help`` 選項可以簡短的表示成 ``-h`` , 這是唯一一個選項我們不用去指明" -"的(意即,沒有必要在這個參數後加上任何數值)。如果指定其他參數給他會造成錯" -"誤。也因為這樣,我們得到了一個免費的信息。" +"``--help`` 選項也可以縮寫為 ``-h``,是我們能隨意獲得的唯一選項(即無需指定" +"它)。指定任何其他內容都會導致錯誤。但即便如此,我們也還是輕鬆地獲得了有用的" +"使用資訊。" #: ../../howto/argparse.rst:112 msgid "Introducing Positional arguments" -msgstr "介紹位置參數" +msgstr "位置引數的介紹" #: ../../howto/argparse.rst:114 msgid "An example::" -msgstr "" -"例如:\n" -"\n" -"::" +msgstr "例如: ::" #: ../../howto/argparse.rst:122 msgid "And running the code:" -msgstr "運行這段代碼:" +msgstr "執行這段程式碼:" #: ../../howto/argparse.rst:140 msgid "Here is what's happening:" -msgstr "接者是發生的情況:" +msgstr "這是會發生的事情:" #: ../../howto/argparse.rst:142 msgid "" @@ -185,21 +179,20 @@ msgid "" "accept. In this case, I've named it ``echo`` so that it's in line with its " "function." msgstr "" -"我們增加了 :meth:`~ArgumentParser.add_argument` 方法,利用這個方法可以指定我" -"們的程式接受哪些命令列選項。在這種情況下,我將之命名為 ``echo`` 以便於與其功" -"能保持一致。" +"我們新增了 :meth:`~ArgumentParser.add_argument` 方法,我們用它來指定程式願意" +"接受哪些命令列選項。在本例中,我將其命名為 ``echo``,以便與其功能一致。" #: ../../howto/argparse.rst:146 msgid "Calling our program now requires us to specify an option." -msgstr "現在呼叫我們的程序時需要指定一個參數選項。" +msgstr "現在呼叫我們的程式時需要指定一個選項。" #: ../../howto/argparse.rst:148 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." msgstr "" -"在這個例子中,:meth:`~ArgumentParser.parse_args` 這個方法確實根據了 ``echo`` " -"這個選項回傳了資料。" +":meth:`~ArgumentParser.parse_args` 方法實際上從指定的選項中回傳一些資料,在本" +"例中為 ``echo``。" #: ../../howto/argparse.rst:151 msgid "" @@ -208,6 +201,8 @@ msgid "" "also notice that its name matches the string argument given to the method, " "``echo``." msgstr "" +"該變數是某種形式的「魔法」,:mod:`argparse` 可以自由執行(即無需指定該值儲存" +"在哪個變數中)。你還會注意到,它的名稱與提供給方法 ``echo`` 的字串引數相符。" #: ../../howto/argparse.rst:156 msgid "" @@ -217,11 +212,9 @@ msgid "" "than by guessing or by reading the source code. So, let's make it a bit more " "useful::" msgstr "" -"注意, 雖然 help 秀出了看起來不錯的信息, 但現在並沒有給予到實質幫助。像剛剛增" -"加的 ``echo`` 這個位置參數,除了猜測和讀原始碼之外,我們根本不曉得該怎麼使用" -"他。因此我們來做一點事讓他變得更有用:\n" -"\n" -"::" +"但請注意,儘管幫助顯示看起來不錯,但它目前還沒有發揮出應有的用處。例如,我們" +"看到 ``echo`` 作為位置引數,但除了猜測或閱讀原始程式碼之外,我們不知道它的作" +"用。那麼,我們來讓它變得更有用一點: ::" #: ../../howto/argparse.rst:167 msgid "And we get:" @@ -229,10 +222,7 @@ msgstr "然後我們得到:" #: ../../howto/argparse.rst:180 msgid "Now, how about doing something even more useful::" -msgstr "" -"現在來做一些更有用處的事情:\n" -"\n" -"::" +msgstr "現在來做一些更有用處的事情: ::" #: ../../howto/argparse.rst:198 msgid "" @@ -240,28 +230,24 @@ msgid "" "give it as strings, unless we tell it otherwise. So, let's tell :mod:" "`argparse` to treat that input as an integer::" msgstr "" -"那並沒有如預期這樣。這是因為 :mod:`argparse` 將我們給予選項的值當成字串,除然" -"我們告訴他要怎麼做。所以我們來告訴 :mod:`argparse` 將這個輸入值當成整數來使" -"用:\n" -"\n" -"::" +"進展不太順利。這是因為,除非我們另有說明,:mod:`argparse` 會將我們給它的選項" +"視為字串。因此,讓我們告訴 :mod:`argparse` 將該輸入視為整數: ::" #: ../../howto/argparse.rst:219 msgid "" "That went well. The program now even helpfully quits on bad illegal input " "before proceeding." -msgstr "" -"這樣很順利。現在程序在開始之前會因為錯誤的輸入而回報有用的訊息並結束掉。" +msgstr "順利進展。現在該程式甚至可以在繼續操作之前因錯誤的非法輸入而退出。" #: ../../howto/argparse.rst:224 msgid "Introducing Optional arguments" -msgstr "介紹選項參數" +msgstr "可選引數的介紹" #: ../../howto/argparse.rst:226 msgid "" "So far we have been playing with positional arguments. Let us have a look on " "how to add optional ones::" -msgstr "" +msgstr "到目前為止,我們一直在討論位置引數。我們來看看如何新增可選引數: ::" #: ../../howto/argparse.rst:236 ../../howto/argparse.rst:282 #: ../../howto/argparse.rst:398 ../../howto/argparse.rst:432 @@ -273,8 +259,8 @@ msgid "" "The program is written so as to display something when ``--verbosity`` is " "specified and display nothing when not." msgstr "" -"這個程式是寫成如果有指名 ``--verbosity`` 這個參數選項那才顯示些資訊,反之亦" -"然。" +"程式被編寫為在指定 ``--verbosity`` 時顯示一些內容,並在未指定時不顯示任何內" +"容。" #: ../../howto/argparse.rst:259 msgid "" @@ -284,16 +270,19 @@ msgid "" "``None`` as a value, which is the reason it fails the truth test of the :" "keyword:`if` statement." msgstr "" +"為了表示該選項實際上是可選的,沒使用它來執行程式並不會出現錯誤。請注意,預設" +"情況下,如果未使用可選引數,則相關變數(在本例中為 ``args.verbosity``)將被賦" +"予 ``None`` 作為值,這就是它未能通過 :keyword:`if` 陳述式真值測試的原因。" #: ../../howto/argparse.rst:265 msgid "The help message is a bit different." -msgstr "Help 訊息稍微有些不一樣。" +msgstr "幫助訊息有點不同。" #: ../../howto/argparse.rst:267 msgid "" "When using the ``--verbosity`` option, one must also specify some value, any " "value." -msgstr "當使用 ``--verbosity`` 參數選項時必須要指定一個數值。" +msgstr "當使用 ``--verbosity`` 選項時必須要指定一些值,任何值都可以。" #: ../../howto/argparse.rst:270 msgid "" @@ -301,10 +290,8 @@ msgid "" "for our simple program, only two values are actually useful, ``True`` or " "``False``. Let's modify the code accordingly::" msgstr "" -"在上面的例子中 ``--verbosity``,接受任意的整數,但對我們的程式來說只接受兩個" -"輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合:\n" -"\n" -"::" +"在上面的例子中,``--verbosity`` 接受任意的整數,但對我們的程式來說只接受兩個" +"輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合: ::" #: ../../howto/argparse.rst:300 msgid "" @@ -314,20 +301,24 @@ msgid "" "This means that, if the option is specified, assign the value ``True`` to " "``args.verbose``. Not specifying it implies ``False``." msgstr "" +"這個選項現在更像是一個旗標,而不是需要值的東西。我們甚至更改了選項的名稱以符" +"合這個想法。請注意,我們現在指定一個新的關鍵字 ``action``,並為其指定值 " +"``\"store_true\"``。這意味著,如果指定了該選項,則將值 ``True`` 指派給 " +"``args.verbose``。不指定它代表為 ``False``。" #: ../../howto/argparse.rst:307 msgid "" "It complains when you specify a value, in true spirit of what flags actually " "are." -msgstr "" +msgstr "當你指定一個值時,它會本著旗標的實際精神來抱怨。" #: ../../howto/argparse.rst:310 msgid "Notice the different help text." -msgstr "注意不同的 help 文件。" +msgstr "請注意不同的幫助文字。" #: ../../howto/argparse.rst:314 msgid "Short options" -msgstr "" +msgstr "短選項" #: ../../howto/argparse.rst:316 msgid "" @@ -335,29 +326,23 @@ msgid "" "yet touched on the topic of short versions of the options. It's quite " "simple::" msgstr "" -"如果你很熟悉命令列的使用的話,你將會發現我還沒講到關於短參數。其實這很簡" -"單:\n" -"\n" -"::" +"如果你熟悉命令列用法,你會注意到我尚未提及選項的簡短版本。這很簡單: ::" #: ../../howto/argparse.rst:328 msgid "And here goes:" -msgstr "" +msgstr "而這為:" #: ../../howto/argparse.rst:341 msgid "Note that the new ability is also reflected in the help text." -msgstr "注意新的表示對於幫助文件也是一樣的" +msgstr "請注意,新功能也反映在幫助文字中。" #: ../../howto/argparse.rst:345 msgid "Combining Positional and Optional arguments" -msgstr "現在結合位置與選項參數" +msgstr "組合位置引數和可選引數" #: ../../howto/argparse.rst:347 msgid "Our program keeps growing in complexity::" -msgstr "" -"我們的程式成長的越來越複雜:\n" -"\n" -"::" +msgstr "我們的程式的複雜性不斷增加: ::" #: ../../howto/argparse.rst:362 msgid "And now the output:" @@ -365,17 +350,19 @@ msgstr "然後現在的輸出結果:" #: ../../howto/argparse.rst:376 msgid "We've brought back a positional argument, hence the complaint." -msgstr "" +msgstr "我們帶回了位置引數,因而被抱怨。" #: ../../howto/argparse.rst:378 msgid "Note that the order does not matter." -msgstr "注意現在的順序對於程式來說已經不再重要了." +msgstr "請注意,順序並不重要。" #: ../../howto/argparse.rst:380 msgid "" "How about we give this program of ours back the ability to have multiple " "verbosity values, and actually get to use them::" msgstr "" +"我們讓這個程式擁有多個訊息詳細級別 (verbosity) 之值的能力,並實際使用它" +"們: ::" #: ../../howto/argparse.rst:414 msgid "" @@ -383,12 +370,14 @@ msgid "" "Let's fix it by restricting the values the ``--verbosity`` option can " "accept::" msgstr "" +"除了最後一個外都看起來正常,它透露了我們程式中的一個錯誤。我們可透過限制 ``--" +"verbosity`` 選項可以接受的值來修復它: ::" #: ../../howto/argparse.rst:450 msgid "" "Note that the change also reflects both in the error message as well as the " "help string." -msgstr "" +msgstr "請注意,更改也會反映在錯誤訊息和幫助字串中。" #: ../../howto/argparse.rst:453 msgid "" @@ -396,6 +385,8 @@ msgid "" "pretty common. It also matches the way the CPython executable handles its " "own verbosity argument (check the output of ``python --help``)::" msgstr "" +"現在,讓我們使用另一種常見方法來玩玩訊息詳細級別。它也與 CPython 執行檔處理其" +"自身訊息詳細級別引數的方式相符(請見 ``python --help`` 的輸出): ::" #: ../../howto/argparse.rst:472 msgid "" @@ -408,29 +399,30 @@ msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " "previous version of our script. That should explain the complaint." msgstr "" +"是的,現在它更像是我們上一版腳本中的旗標(類似於 " +"``action=\"store_true\"``),這應該可以解釋抱怨的原因。" #: ../../howto/argparse.rst:504 msgid "It also behaves similar to \"store_true\" action." -msgstr "" +msgstr "它的行為也類似 \"store_true\" 操作。" #: ../../howto/argparse.rst:506 msgid "" "Now here's a demonstration of what the \"count\" action gives. You've " "probably seen this sort of usage before." -msgstr "" -"現在來秀一下 \"count\" 這個動作會給予什麼。你可能之前就有見過這種用法。" +msgstr "現在這裡示範了 \"count\" 動作的作用。你可能以前見過這種用法。" #: ../../howto/argparse.rst:509 msgid "" "And if you don't specify the ``-v`` flag, that flag is considered to have " "``None`` value." -msgstr "" +msgstr "如果你不指定 ``-v`` 旗標,則該旗標被視為具有 ``None`` 值。" #: ../../howto/argparse.rst:512 msgid "" "As should be expected, specifying the long form of the flag, we should get " "the same output." -msgstr "應該要如預期那樣,就算給予長選項我們也要獲得一樣的輸出結果。" +msgstr "正如預期的那樣,指定長形式旗標,我們應該得到相同的輸出。" #: ../../howto/argparse.rst:515 msgid "" @@ -438,35 +430,36 @@ msgid "" "has acquired, but that can always be fixed by improving the documentation " "for our script (e.g. via the ``help`` keyword argument)." msgstr "" +"遺憾的是,我們的幫助輸出對於我們腳本獲得的新功能並沒有提供太多資訊,但我們都" +"可以透過改進腳本的文件來解決這個問題(例如:透過 ``help`` 關鍵字引數)。" #: ../../howto/argparse.rst:519 msgid "That last output exposes a bug in our program." -msgstr "" +msgstr "最後的輸出透露了我們程式中的一個錯誤。" #: ../../howto/argparse.rst:522 msgid "Let's fix::" -msgstr "讓我們來解決問題" +msgstr "讓我們來解決問題: ::" #: ../../howto/argparse.rst:541 msgid "And this is what it gives:" -msgstr "而這也正是它給的:" +msgstr "這就是它給出的:" #: ../../howto/argparse.rst:556 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." msgstr "" +"第一次輸出順利進行,並修復了我們之前遇到的錯誤。也就是說,我們希望任何 >= 2 " +"的值都盡可能詳細。" #: ../../howto/argparse.rst:559 msgid "Third output not so good." -msgstr "第三個輸出不是這麼的好。" +msgstr "第三個輸出不太好。" #: ../../howto/argparse.rst:561 msgid "Let's fix that bug::" -msgstr "" -"我們來修復這個錯誤:\n" -"\n" -"::" +msgstr "我們來修復這個錯誤: ::" #: ../../howto/argparse.rst:578 msgid "" @@ -476,10 +469,13 @@ msgid "" "value, and that cannot be compared to an int value (hence the :exc:" "`TypeError` exception)." msgstr "" +"我們剛剛引入了另一個關鍵字 ``default``。我們將其設為 ``0``,以便使其與其他 " +"int 值進行比較。請記住,預設情況下,如果未指定可選引數,它將獲得 ``None`` " +"值,並且不能與 int 值進行比較(因此會出現 :exc:`TypeError` 例外)。" #: ../../howto/argparse.rst:585 msgid "And:" -msgstr "而且" +msgstr "而且:" #: ../../howto/argparse.rst:592 msgid "" @@ -487,19 +483,19 @@ msgid "" "scratched the surface. The :mod:`argparse` module is very powerful, and " "we'll explore a bit more of it before we end this tutorial." msgstr "" +"僅憑我們迄今為止所學到的知識就可以做到很多事情了,不過其實這樣只有學到一點皮" +"毛而已。:mod:`argparse` 模組非常強大,在結束本教學之前我們會對它進行更多探" +"索。" #: ../../howto/argparse.rst:599 msgid "Getting a little more advanced" -msgstr "" +msgstr "更進階一點" #: ../../howto/argparse.rst:601 msgid "" "What if we wanted to expand our tiny program to perform other powers, not " "just squares::" -msgstr "" -"如果我們想要擴展我們的小程式做比範例更多的事:\n" -"\n" -"::" +msgstr "如果我們想擴充我們的小程式來執行其他次方的運算,而不僅是平方: ::" #: ../../howto/argparse.rst:618 ../../howto/argparse.rst:656 msgid "Output:" @@ -511,10 +507,12 @@ msgid "" "that gets displayed. The following example instead uses verbosity level to " "display *more* text instead::" msgstr "" +"請注意,到目前為止,我們一直在使用詳細級別來\\ *更改*\\ 顯示的文字。以下範例" +"使用詳細級別來顯示\\ *更多*\\ 文字: ::" #: ../../howto/argparse.rst:672 msgid "Specifying ambiguous arguments" -msgstr "" +msgstr "指定不明確的引數" #: ../../howto/argparse.rst:674 msgid "" @@ -522,10 +520,12 @@ msgid "" "an argument, ``--`` can be used to tell :meth:`~ArgumentParser.parse_args` " "that everything after that is a positional argument::" msgstr "" +"當決定一個引數是位置引數還是引數會有歧義,可以使用 ``--`` 來告訴 :meth:" +"`~ArgumentParser.parse_args` 之後的所有內容都是位置引數: ::" #: ../../howto/argparse.rst:699 msgid "Conflicting options" -msgstr "" +msgstr "相互衝突的選項" #: ../../howto/argparse.rst:701 msgid "" @@ -536,12 +536,18 @@ msgid "" "program so that the new functionality makes more sense: we'll introduce the " "``--quiet`` option, which will be the opposite of the ``--verbose`` one::" msgstr "" +"到目前為止,我們一直在使用 :class:`argparse.ArgumentParser` 實例的兩種方法。" +"讓我們介紹第三個,:meth:`~ArgumentParser.add_mutually_exclusive_group`,它允" +"許我們指定彼此衝突的選項。我們還可以更改程式的其餘部分,以使得新功能更有意" +"義:我們將引入 ``--quiet`` 選項,該選項與 ``--verbose`` 選項相反: ::" #: ../../howto/argparse.rst:727 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" msgstr "" +"我們的程式現在更簡單了,我們因為功能展示失去了一些功能,但無論如何,以下這是" +"輸出:" #: ../../howto/argparse.rst:745 msgid "" @@ -549,16 +555,15 @@ msgid "" "the sort of flexibility you get, i.e. mixing long form options with short " "form ones." msgstr "" +"這應該很容易理解。我新增了最後一個輸出,以便看到所獲得的靈活性,即可以混合長" +"形式與短形式選項。" #: ../../howto/argparse.rst:749 msgid "" "Before we conclude, you probably want to tell your users the main purpose of " "your program, just in case they don't know::" msgstr "" -"在我們結論之前,你可能想告訴你的用戶這個程式的主要目的,以防萬一他們不知" -"道:\n" -"\n" -"::" +"在我們結束之前,你可能想告訴使用者你的程式的主要目的,以防他們不知道: ::" #: ../../howto/argparse.rst:770 msgid "" @@ -566,10 +571,12 @@ msgid "" "tells us that we can either use ``-v`` or ``-q``, but not both at the same " "time:" msgstr "" +"請注意用法文字中的細微差別。注意 ``[-v | -q]``,它告訴我們可以使用 ``-v`` 或 " +"``-q``,但不能同時使用:" #: ../../howto/argparse.rst:792 msgid "How to translate the argparse output" -msgstr "" +msgstr "如何翻譯 argparse 輸出" #: ../../howto/argparse.rst:794 msgid "" @@ -578,16 +585,21 @@ msgid "" "allows applications to easily localize messages produced by :mod:`argparse`. " "See also :ref:`i18n-howto`." msgstr "" +":mod:`argparse` 模組的輸出,例如幫助文字和錯誤訊息,都可以透過使用 :mod:" +"`gettext` 模組進行翻譯。這允許應用程式能輕鬆本地化 :mod:`argparse` 生成的訊" +"息。另請參閱 :ref:`i18n-howto`。" #: ../../howto/argparse.rst:799 msgid "For instance, in this :mod:`argparse` output:" -msgstr "" +msgstr "例如,在此 :mod:`argparse` 輸出中:" #: ../../howto/argparse.rst:817 msgid "" "The strings ``usage:``, ``positional arguments:``, ``options:`` and ``show " "this help message and exit`` are all translatable." msgstr "" +"字串 ``usage:``、``positional arguments:``、``options:`` 和 ``show this help " +"message and exit`` 都是可被翻譯的。" #: ../../howto/argparse.rst:820 msgid "" @@ -595,6 +607,8 @@ msgid "" "po`` file. For example, using `Babel `__, run this " "command:" msgstr "" +"為了翻譯這些字串,必須先將它們提取到 ``.po`` 檔案中。例如,使用 `Babel " +"`__ 並執行下列命令:" #: ../../howto/argparse.rst:828 msgid "" @@ -602,12 +616,14 @@ msgid "" "module and output them into a file named ``messages.po``. This command " "assumes that your Python installation is in ``/usr/lib``." msgstr "" +"此命令將從 :mod:`argparse` 模組中提取出所有可翻譯的字串,並將它們輸出到名為 " +"``messages.po`` 的檔案中。這個指令假設你的 Python 是安裝在 ``/usr/lib`` 中。" #: ../../howto/argparse.rst:832 msgid "" "You can find out the location of the :mod:`argparse` module on your system " "using this script::" -msgstr "" +msgstr "你可以使用以下腳本找到 :mod:`argparse` 模組在系統上的位置: ::" #: ../../howto/argparse.rst:838 msgid "" @@ -615,12 +631,14 @@ msgid "" "are installed using :mod:`gettext`, :mod:`argparse` will be able to display " "the translated messages." msgstr "" +"一旦翻譯了 ``.po`` 檔案中的訊息並使用 :mod:`gettext` 安裝了翻譯,:mod:" +"`argparse` 將能夠顯示翻譯後的訊息。" #: ../../howto/argparse.rst:842 msgid "" "To translate your own strings in the :mod:`argparse` output, use :mod:" "`gettext`." -msgstr "" +msgstr "若要在 :mod:`argparse` 輸出中翻譯你自己的字串,請使用 :mod:`gettext`。" #: ../../howto/argparse.rst:845 msgid "Conclusion" @@ -632,8 +650,5 @@ msgid "" "quite detailed and thorough, and full of examples. Having gone through this " "tutorial, you should easily digest them without feeling overwhelmed." msgstr "" -":mod:`argparse` 模組提供了比這裡展示更多的功能。它的文件是非常全面詳細且充滿" -"了例子。通過本教學,你應該比較容易消化它們了。" - -#~ msgid "Tshepang Lekhonkhobe" -#~ msgstr "Tshepang Lekhonkhobe" +":mod:`argparse` 模組提供的功能比此篇內容的要多得多。它的文件非常詳細與透徹並" +"有很多範例。讀完本教學後,你應該可以輕鬆消化它們,而不會感到不知所措。"