@@ -17,39 +17,41 @@ msgstr ""
17
17
"Content-Transfer-Encoding : 8bit\n "
18
18
19
19
#: ../../howto/argparse-optparse.rst:8
20
- #, fuzzy
21
20
msgid "Migrating ``optparse`` code to ``argparse``"
22
- msgstr "升級 optparse 程式碼 "
21
+ msgstr "將 `` optparse`` 程式碼遷移到 ``argparse`` "
23
22
24
23
#: ../../howto/argparse-optparse.rst:10
25
24
msgid ""
26
25
"The :mod:`argparse` module offers several higher level features not natively "
27
26
"provided by the :mod:`optparse` module, including:"
28
27
msgstr ""
28
+ ":mod:`argparse` 模組提供了一些高階功能,這些功能在 :mod:`optparse` 模組中並未"
29
+ "原生提供,包括:"
29
30
30
31
#: ../../howto/argparse-optparse.rst:13
31
32
msgid "Handling positional arguments."
32
- msgstr ""
33
+ msgstr "處理位置引數。 "
33
34
34
35
#: ../../howto/argparse-optparse.rst:14
35
36
msgid "Supporting subcommands."
36
- msgstr ""
37
+ msgstr "支援子命令。 "
37
38
38
39
#: ../../howto/argparse-optparse.rst:15
39
40
msgid "Allowing alternative option prefixes like ``+`` and ``/``."
40
- msgstr ""
41
+ msgstr "允許替代選項前綴,如 ``+`` 和 ``/``。 "
41
42
42
43
#: ../../howto/argparse-optparse.rst:16
43
44
msgid "Handling zero-or-more and one-or-more style arguments."
44
45
msgstr ""
46
+ "處理零或多個 (zero-or-more) 和一個或多個 (and one-or-more) 樣式的引數。"
45
47
46
48
#: ../../howto/argparse-optparse.rst:17
47
49
msgid "Producing more informative usage messages."
48
- msgstr ""
50
+ msgstr "產生更多資訊的使用訊息。 "
49
51
50
52
#: ../../howto/argparse-optparse.rst:18
51
53
msgid "Providing a much simpler interface for custom ``type`` and ``action``."
52
- msgstr ""
54
+ msgstr "為自訂 ``type`` 和 ``action`` 提供了一個更簡單的介面。 "
53
55
54
56
#: ../../howto/argparse-optparse.rst:20
55
57
msgid ""
@@ -60,32 +62,44 @@ msgid ""
60
62
"named options and positional arguments in the declarative interface mean "
61
63
"that the API has diverged from that of ``optparse`` over time."
62
64
msgstr ""
65
+ "最初 :mod:`argparse` 模組試圖保持與 :mod:`optparse` 的相容性,但在基礎設計上"
66
+ "的存在差異 -- 支援宣告式 (declarative) 命令列選項處理 (同時將位置引數處理留給"
67
+ "應用程式的程式碼) 和在宣告式介面中支援命名選項 (named options) 和位置引數 -- "
68
+ "代表 API 隨著時間的推移已經與 ``optparse`` API 分歧。"
63
69
64
70
#: ../../howto/argparse-optparse.rst:27
65
71
msgid ""
66
72
"As described in :ref:`choosing-an-argument-parser`, applications that are "
67
73
"currently using :mod:`optparse` and are happy with the way it works can just "
68
74
"continue to use ``optparse``."
69
75
msgstr ""
76
+ "如 :ref:`choosing-an-argument-parser` 中所述,目前使用 :mod:`optparse` 並對其"
77
+ "運作方式滿意的應用程式可以繼續使用 ``optparse``。"
70
78
71
79
#: ../../howto/argparse-optparse.rst:31
72
80
msgid ""
73
81
"Application developers that are considering migrating should also review the "
74
82
"list of intrinsic behavioural differences described in that section before "
75
83
"deciding whether or not migration is desirable."
76
84
msgstr ""
85
+ "在決定是否遷移之前,應用程式開發人員應該先檢閱該段落中描述的內在行為差異清"
86
+ "單,來決定是否值得遷移。"
77
87
78
88
#: ../../howto/argparse-optparse.rst:35
79
89
msgid ""
80
90
"For applications that do choose to migrate from :mod:`optparse` to :mod:"
81
91
"`argparse`, the following suggestions should be helpful:"
82
92
msgstr ""
93
+ "對於選擇從 :mod:`optparse` 遷移到 :mod:`argparse` 的應用程式,以下建議應會有"
94
+ "所幫助:"
83
95
84
96
#: ../../howto/argparse-optparse.rst:38
85
97
msgid ""
86
98
"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:"
87
99
"`ArgumentParser.add_argument` calls."
88
100
msgstr ""
101
+ "將所有 :meth:`optparse.OptionParser.add_option` 呼叫替換為 :meth:"
102
+ "`ArgumentParser.add_argument` 呼叫。"
89
103
90
104
#: ../../howto/argparse-optparse.rst:41
91
105
msgid ""
@@ -94,42 +108,59 @@ msgid ""
94
108
"for the positional arguments. Keep in mind that what was previously called "
95
109
"``options``, now in the :mod:`argparse` context is called ``args``."
96
110
msgstr ""
111
+ "將 ``(options, args) = parser.parse_args()`` 替換為 ``args = parser."
112
+ "parse_args()``,並為位置引數新增額外的 :meth:`ArgumentParser.add_argument` 呼"
113
+ "叫。請記住,以前稱為 ``options`` 的東西,在 :mod:`argparse` 情境中現在稱為 "
114
+ "``args``。"
97
115
98
116
#: ../../howto/argparse-optparse.rst:46
99
117
msgid ""
100
118
"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :"
101
119
"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:"
102
120
"`~ArgumentParser.parse_args`."
103
121
msgstr ""
122
+ "使用 :meth:`~ArgumentParser.parse_intermixed_args` 來替換掉 :meth:`optparse."
123
+ "OptionParser.disable_interspersed_args`,而不是使用 :meth:`~ArgumentParser."
124
+ "parse_args`。"
104
125
105
126
#: ../../howto/argparse-optparse.rst:50
106
127
msgid ""
107
128
"Replace callback actions and the ``callback_*`` keyword arguments with "
108
129
"``type`` or ``action`` arguments."
109
130
msgstr ""
131
+ "將回呼動作和 ``callback_*`` 關鍵字引數替換為 ``type`` 或 ``action`` 引數。"
110
132
111
133
#: ../../howto/argparse-optparse.rst:53
112
134
msgid ""
113
135
"Replace string names for ``type`` keyword arguments with the corresponding "
114
136
"type objects (e.g. int, float, complex, etc)."
115
137
msgstr ""
138
+ "將 ``type`` 關鍵字引數的字串名稱替換為相應的類型物件 (例如 int、float、"
139
+ "complex 等)。"
116
140
117
141
#: ../../howto/argparse-optparse.rst:56
118
142
msgid ""
119
143
"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse."
120
144
"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`."
121
145
msgstr ""
146
+ "將 :class:`optparse.Values` 替換為 :class:`Namespace`,並將 :exc:`optparse."
147
+ "OptionError` 和 :exc:`optparse.OptionValueError` 替換為 :exc:"
148
+ "`ArgumentError`。"
122
149
123
150
#: ../../howto/argparse-optparse.rst:60
124
151
msgid ""
125
152
"Replace strings with implicit arguments such as ``%default`` or ``%prog`` "
126
153
"with the standard Python syntax to use dictionaries to format strings, that "
127
154
"is, ``%(default)s`` and ``%(prog)s``."
128
155
msgstr ""
156
+ "將隱式引數的字串,如 ``%default`` 或 ``%prog`` 替換為使用字典來格式化字串的標"
157
+ "準 Python 語法,即 ``%(default)s`` 和 ``%(prog)s``。"
129
158
130
159
#: ../../howto/argparse-optparse.rst:64
131
160
msgid ""
132
161
"Replace the OptionParser constructor ``version`` argument with a call to "
133
162
"``parser.add_argument('--version', action='version', version='<the "
134
163
"version>')``."
135
164
msgstr ""
165
+ "將 OptionParser 建構函式的 ``version`` 引數替換為呼叫 ``parser."
166
+ "add_argument('--version', action='version', version='<the version>')``。"
0 commit comments