Skip to content

Commit 35e9e8f

Browse files
committed
Working on howto/annotations.po
1 parent f996730 commit 35e9e8f

1 file changed

Lines changed: 87 additions & 67 deletions

File tree

howto/annotations.po

Lines changed: 87 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ msgstr ""
77
"Project-Id-Version: Python 3.14\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2026-01-22 16:55+0000\n"
10-
"PO-Revision-Date: 2023-11-08 23:11+0800\n"
11-
"Last-Translator: rockleon <therockleona@gmail.com>\n"
10+
"PO-Revision-Date: 2026-09-12 20:49+0800\n"
11+
"Last-Translator: dy1012 <dylanpong@gmail.com>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
1414
"Language: zh_TW\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=UTF-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
18-
"X-Generator: Poedit 3.4.1\n"
18+
"X-Generator: Poedit 3.4.4\n"
1919

2020
#: ../../howto/annotations.rst:5
2121
msgid "Annotations Best Practices"
@@ -60,8 +60,8 @@ msgstr ""
6060
msgid ""
6161
"Note that this document is specifically about working with "
6262
"``__annotations__``, not uses *for* annotations. If you're looking for "
63-
"information on how to use \"type hints\" in your code, please see the :mod:"
64-
"`typing` module."
63+
"information on how to use \"type hints\" in your code, please see "
64+
"the :mod:`typing` module."
6565
msgstr ""
6666
"請注意,本文件是特別說明 ``__annotations__`` 的使用,而非\\ *如何使用*\\ 註"
6767
"釋。如果你正在尋找如何在你的程式碼中使用「型別提示 (type hint)」的資訊,請查"
@@ -73,11 +73,11 @@ msgstr "在 Python 3.10 及更高版本中存取物件的註釋字典"
7373

7474
#: ../../howto/annotations.rst:35
7575
msgid ""
76-
"Python 3.10 adds a new function to the standard library: :func:`inspect."
77-
"get_annotations`. In Python versions 3.10 through 3.13, calling this "
78-
"function is the best practice for accessing the annotations dict of any "
79-
"object that supports annotations. This function can also \"un-stringize\" "
80-
"stringized annotations for you."
76+
"Python 3.10 adds a new function to the standard "
77+
"library: :func:`inspect.get_annotations`. In Python versions 3.10 through "
78+
"3.13, calling this function is the best practice for accessing the "
79+
"annotations dict of any object that supports annotations. This function can "
80+
"also \"un-stringize\" stringized annotations for you."
8181
msgstr ""
8282
"Python 3.10 在標準函式庫中新增了一個新函式::func:`inspect.get_annotations`。"
8383
"在 Python 3.10 到 3.13,呼叫此函式是存取任何支援註釋的物件的註釋字典的最佳實"
@@ -86,17 +86,20 @@ msgstr ""
8686
#: ../../howto/annotations.rst:42
8787
msgid ""
8888
"In Python 3.14, there is a new :mod:`annotationlib` module with "
89-
"functionality for working with annotations. This includes a :func:"
90-
"`annotationlib.get_annotations` function, which supersedes :func:`inspect."
91-
"get_annotations`."
89+
"functionality for working with annotations. This includes "
90+
"a :func:`annotationlib.get_annotations` function, which "
91+
"supersedes :func:`inspect.get_annotations`."
9292
msgstr ""
93+
"在 Python 3.14 中,新增了一個名為 :mod:`annotationlib` 的模組,具備處理註釋的"
94+
"功能。其中包含一個名為 :func:`annotationlib.get_annotations` 的函式,該函式已"
95+
"取代 :func:`inspect.get_annotations`。"
9396

9497
#: ../../howto/annotations.rst:47
9598
msgid ""
9699
"If for some reason :func:`inspect.get_annotations` isn't viable for your use "
97100
"case, you may access the ``__annotations__`` data member manually. Best "
98-
"practice for this changed in Python 3.10 as well: as of Python 3.10, ``o."
99-
"__annotations__`` is guaranteed to *always* work on Python functions, "
101+
"practice for this changed in Python 3.10 as well: as of Python 3.10, "
102+
"``o.__annotations__`` is guaranteed to *always* work on Python functions, "
100103
"classes, and modules. If you're certain the object you're examining is one "
101104
"of these three *specific* objects, you may simply use ``o.__annotations__`` "
102105
"to get at the object's annotations dict."
@@ -109,11 +112,12 @@ msgstr ""
109112

110113
#: ../../howto/annotations.rst:57
111114
msgid ""
112-
"However, other types of callables--for example, callables created by :func:"
113-
"`functools.partial`--may not have an ``__annotations__`` attribute defined. "
114-
"When accessing the ``__annotations__`` of a possibly unknown object, best "
115-
"practice in Python versions 3.10 and newer is to call :func:`getattr` with "
116-
"three arguments, for example ``getattr(o, '__annotations__', None)``."
115+
"However, other types of callables--for example, callables created "
116+
"by :func:`functools.partial`--may not have an ``__annotations__`` attribute "
117+
"defined. When accessing the ``__annotations__`` of a possibly unknown "
118+
"object, best practice in Python versions 3.10 and newer is to "
119+
"call :func:`getattr` with three arguments, for example ``getattr(o, "
120+
"'__annotations__', None)``."
117121
msgstr ""
118122
"但是,其他型別的 callable(可呼叫物件)(例如,由 :func:`functools.partial` "
119123
"建立的 callable)可能沒有定義 ``__annotations__`` 屬性 (attribute)。當存取可"
@@ -205,9 +209,9 @@ msgid ""
205209
msgstr ""
206210
"如果你正在檢查的物件是一個類別 (``isinstance(o, type)``),你的程式碼將必須有"
207211
"一個單獨的程式碼路徑。在這種情況下,最佳實踐依賴 Python 3.9 及之前版本的實作"
208-
"細節 (implementation detail):如果一個類別定義了註釋,它們將儲存在該類別的 :"
209-
"attr:`~type.__dict__` 字典中。由於類別可能定義了註釋,也可能沒有定義,因此最"
210-
"佳實踐是在類別字典上呼叫 :meth:`~dict.get` 方法。"
212+
"細節 (implementation detail):如果一個類別定義了註釋,它們將儲存在該類別"
213+
"的 :attr:`~type.__dict__` 字典中。由於類別可能定義了註釋,也可能沒有定義,"
214+
"此最佳實踐是在類別字典上呼叫 :meth:`~dict.get` 方法。"
211215

212216
#: ../../howto/annotations.rst:114
213217
msgid ""
@@ -233,21 +237,21 @@ msgstr ""
233237
#: ../../howto/annotations.rst:123
234238
msgid ""
235239
"After running this code, ``ann`` should be either a dictionary or ``None``. "
236-
"You're encouraged to double-check the type of ``ann`` using :func:"
237-
"`isinstance` before further examination."
240+
"You're encouraged to double-check the type of ``ann`` "
241+
"using :func:`isinstance` before further examination."
238242
msgstr ""
239243
"運行此程式碼後,``ann`` 應該是字典或 ``None``。我們鼓勵你在進一步檢查之前使"
240244
"用 :func:`isinstance` 仔細檢查 ``ann`` 的型別。"
241245

242246
#: ../../howto/annotations.rst:128
243247
msgid ""
244-
"Note that some exotic or malformed type objects may not have a :attr:`~type."
245-
"__dict__` attribute, so for extra safety you may also wish to use :func:"
246-
"`getattr` to access :attr:`!__dict__`."
248+
"Note that some exotic or malformed type objects may not have "
249+
"a :attr:`~type.__dict__` attribute, so for extra safety you may also wish to "
250+
"use :func:`getattr` to access :attr:`!__dict__`."
247251
msgstr ""
248-
"請注意,某些外來 (exotic) 或格式錯誤 (malform) 的型別物件可能沒有 :attr:"
249-
"`~type.__dict__` 屬性,因此為了額外的安全,你可能還希望使用 :func:`getattr` "
250-
"來存取 :attr:`!__dict__`。"
252+
"請注意,某些外來 (exotic) 或格式錯誤 (malform) 的型別物件可能沒"
253+
"有 :attr:`~type.__dict__` 屬性,因此為了額外的安全,你可能還希望使"
254+
"用 :func:`getattr` 來存取 :attr:`!__dict__`。"
251255

252256
#: ../../howto/annotations.rst:134
253257
msgid "Manually Un-Stringizing Stringized Annotations"
@@ -265,14 +269,15 @@ msgstr ""
265269

266270
#: ../../howto/annotations.rst:142
267271
msgid ""
268-
"If you're using Python 3.9 or older, or if for some reason you can't use :"
269-
"func:`inspect.get_annotations`, you'll need to duplicate its logic. You're "
270-
"encouraged to examine the implementation of :func:`inspect.get_annotations` "
271-
"in the current Python version and follow a similar approach."
272+
"If you're using Python 3.9 or older, or if for some reason you can't "
273+
"use :func:`inspect.get_annotations`, you'll need to duplicate its logic. "
274+
"You're encouraged to examine the implementation "
275+
"of :func:`inspect.get_annotations` in the current Python version and follow "
276+
"a similar approach."
272277
msgstr ""
273-
"如果你使用的是 Python 3.9 或更早版本,或者由於某種原因你無法使用 :func:"
274-
"`inspect.get_annotations`,則需要複製其邏輯。我們鼓勵你檢查目前 Python 版本"
275-
" :func:`inspect.get_annotations` 的實作並遵循類似的方法。"
278+
"如果你使用的是 Python 3.9 或更早版本,或者由於某種原因你無法使"
279+
"用 :func:`inspect.get_annotations`,則需要複製其邏輯。我們鼓勵你檢查目前 "
280+
"Python 版本中 :func:`inspect.get_annotations` 的實作並遵循類似的方法。"
276281

277282
#: ../../howto/annotations.rst:148
278283
msgid ""
@@ -282,40 +287,41 @@ msgstr "簡而言之,如果你希望評估任意物件 ``o`` 上的字串化
282287

283288
#: ../../howto/annotations.rst:151
284289
msgid ""
285-
"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
286-
"func:`eval`."
290+
"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when "
291+
"calling :func:`eval`."
287292
msgstr ""
288293
"如果 ``o`` 是一個模組,則在呼叫 :func:`eval` 時使用 ``o.__dict__`` 作為\\ ``"
289294
"全域變數``。"
290295

291296
#: ../../howto/annotations.rst:153
292297
msgid ""
293298
"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
294-
"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
295-
"`eval`."
299+
"``globals``, and ``dict(vars(o))`` as the ``locals``, when "
300+
"calling :func:`eval`."
296301
msgstr ""
297-
"如果 ``o`` 是一個類別,當呼叫 :func:`eval` 時,則使用 ``sys.modules[o."
298-
"__module__].__dict__`` 作為\\ ``全域變數``,使用 ``dict(vars(o))`` 作為\\ ``"
299-
"區域變數``。"
302+
"如果 ``o`` 是一個類別,當呼叫 :func:`eval` 時,則使用 "
303+
"``sys.modules[o.__module__].__dict__`` 作為\\ ``全域變數``,使用 "
304+
"``dict(vars(o))`` 作為\\ ``區域變數``。"
300305

301306
#: ../../howto/annotations.rst:156
302307
msgid ""
303-
"If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:"
304-
"`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by "
305-
"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you "
306-
"have found the root unwrapped function."
308+
"If ``o`` is a wrapped callable "
309+
"using :func:`functools.update_wrapper`, :deco:`functools.wraps`, "
310+
"or :func:`functools.partial`, iteratively unwrap it by accessing either "
311+
"``o.__wrapped__`` or ``o.func`` as appropriate, until you have found the "
312+
"root unwrapped function."
307313
msgstr ""
308314
"如果 ``o`` 是使用 :func:`functools.update_wrapper`、:func:`functools.wraps` "
309-
"或 :func:`functools.partial` 包裝的 callable ,請依據需求,透過存取 ``o."
310-
"__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。"
315+
"或 :func:`functools.partial` 包裝的 callable ,請依據需求,透過存取 "
316+
"``o.__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。"
311317

312318
#: ../../howto/annotations.rst:160
313319
msgid ""
314-
"If ``o`` is a callable (but not a class), use :attr:`o.__globals__ <function."
315-
"__globals__>` as the globals when calling :func:`eval`."
320+
"If ``o`` is a callable (but not a class), use :attr:`o.__globals__ "
321+
"<function.__globals__>` as the globals when calling :func:`eval`."
316322
msgstr ""
317-
"如果 ``o`` 是 callable(但不是類別),則在呼叫 :func:`eval` 時使用 :attr:`o."
318-
"__globals__ <function.__globals__>` 作為全域變數。"
323+
"如果 ``o`` 是 callable(但不是類別),則在呼叫 :func:`eval` 時使"
324+
"用 :attr:`o.__globals__ <function.__globals__>` 作為全域變數。"
319325

320326
#: ../../howto/annotations.rst:164
321327
msgid ""
@@ -338,8 +344,8 @@ msgstr ""
338344

339345
#: ../../howto/annotations.rst:173
340346
msgid ""
341-
"Definitions that aren't needed at runtime, only imported when :const:`typing."
342-
"TYPE_CHECKING` is true."
347+
"Definitions that aren't needed at runtime, only imported "
348+
"when :const:`typing.TYPE_CHECKING` is true."
343349
msgstr ""
344350
"Runtime 中不需要的定義,僅在 :const:`typing.TYPE_CHECKING` 為 true 時匯入。"
345351

@@ -376,9 +382,12 @@ msgstr ""
376382
#: ../../howto/annotations.rst:192
377383
msgid ""
378384
"You should avoid accessing ``__annotations__`` directly on any object. "
379-
"Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) or :func:"
380-
"`inspect.get_annotations` (Python 3.10+)."
385+
"Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) "
386+
"or :func:`inspect.get_annotations` (Python 3.10+)."
381387
msgstr ""
388+
"你應該避免直接存取物件的 ``__annotations__`` 。請改"
389+
"用 :func:`annotationlib.get_annotations` (Python 3.14+) "
390+
"或 :func:`inspect.get_annotations` (Python 3.10+)."
382391

383392
#: ../../howto/annotations.rst:196
384393
msgid ""
@@ -477,18 +486,29 @@ msgstr ""
477486
msgid ""
478487
"If you use a class with a custom metaclass and access ``__annotations__`` on "
479488
"the class, you may observe unexpected behavior; see :pep:`749 <749#pep749-"
480-
"metaclasses>` for some examples. You can avoid these quirks by using :func:"
481-
"`annotationlib.get_annotations` on Python 3.14+ or :func:`inspect."
482-
"get_annotations` on Python 3.10+. On earlier versions of Python, you can "
483-
"avoid these bugs by accessing the annotations from the class's :attr:`~type."
484-
"__dict__` (for example, ``cls.__dict__.get('__annotations__', None)``)."
485-
msgstr ""
489+
"metaclasses>` for some examples. You can avoid these quirks by "
490+
"using :func:`annotationlib.get_annotations` on Python 3.14+ "
491+
"or :func:`inspect.get_annotations` on Python 3.10+. On earlier versions of "
492+
"Python, you can avoid these bugs by accessing the annotations from the "
493+
"class's :attr:`~type.__dict__` (for example, "
494+
"``cls.__dict__.get('__annotations__', None)``)."
495+
msgstr ""
496+
"如果你使用的類別具有自訂的元類別,並存取該類別的 ``__annotations__`` ,你可能"
497+
"會觀察到出乎意料的行為;請查閱 :pep:`749 <749#pep749-metaclasses>` 的例子。你"
498+
"可以在Python 3.14+ 使用 :func:`annotationlib.get_annotations` 或者在 Python "
499+
"3.10+ 使用 :func:`inspect.get_annotations` 來避免這些問題。在更早期的版本,你"
500+
"可以存取類別的 :attr:`~type.__dict__` 來避免這些問題。(例如:"
501+
"``cls.__dict__.get(‘__annotations__’, None)`` )"
486502

487503
#: ../../howto/annotations.rst:253
488504
msgid ""
489505
"In some versions of Python, instances of classes may have an "
490506
"``__annotations__`` attribute. However, this is not supported functionality. "
491507
"If you need the annotations of an instance, you can use :func:`type` to "
492-
"access its class (for example, ``annotationlib."
493-
"get_annotations(type(myinstance))`` on Python 3.14+)."
508+
"access its class (for example, "
509+
"``annotationlib.get_annotations(type(myinstance))`` on Python 3.14+)."
494510
msgstr ""
511+
"在某些 Python 版本中,類別實例可能會帶有 ``__annotations__`` 的屬性,但這並非"
512+
"受支援的功能。如果你需要取得實例的註釋,可以用 :func:`type` 來存取實例的類別"
513+
"(例如在 Python 3.14+ 中使用 "
514+
"``annotationlib.get_annotations(type(myinstance))`` )."

0 commit comments

Comments
 (0)