Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork214
Update Translation oflibrary/typing.po
#854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
97 changes: 71 additions & 26 deletionslibrary/typing.po
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -7,8 +7,8 @@ msgstr "" | ||
"Project-Id-Version: Python 3.12\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-03-06 00:03+0000\n" | ||
"PO-Revision-Date:2024-03-26 11:30+0800\n" | ||
"Last-Translator:Li-Hung Wang <therockleona@gmail.com>\n" | ||
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" | ||
"tw)\n" | ||
"Language: zh_TW\n" | ||
@@ -146,8 +146,8 @@ msgstr "*引入*\\ 在定義函式之外的變數註釋語法,以及 :data:`Cl | ||
#: ../../library/typing.rst:80 | ||
msgid ":pep:`544`: Protocols: Structural subtyping (static duck typing)" | ||
msgstr "" | ||
":pep:`544`: 協定:結構子型別 (Structural Subtyping) (靜態鴨子型別,Static" | ||
"Duck Typing)" | ||
#: ../../library/typing.rst:80 | ||
msgid "" | ||
@@ -890,14 +890,16 @@ msgstr "" | ||
#: ../../library/typing.rst:767 | ||
msgid "Nominal vs structural subtyping" | ||
msgstr "標稱 (nominal) 子型別 vs 結構子型別" | ||
cschan1828 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
#: ../../library/typing.rst:769 | ||
msgid "" | ||
"Initially :pep:`484` defined the Python static type system as using *nominal " | ||
"subtyping*. This means that a class ``A`` is allowed where a class ``B`` is " | ||
"expected if and only if ``A`` is a subclass of ``B``." | ||
msgstr "" | ||
"最初 :pep:`484` 定義 Python 靜態型別系統使用\\ *標稱子型別*。這意味著只有 " | ||
"``A`` 為 ``B`` 的子類別時,``A`` 才被允許使用在預期是類別 ``B`` 出現的地方。" | ||
#: ../../library/typing.rst:773 | ||
msgid "" | ||
@@ -907,6 +909,10 @@ msgid "" | ||
"unlike what one would normally do in idiomatic dynamically typed Python " | ||
"code. For example, this conforms to :pep:`484`::" | ||
msgstr "" | ||
"這個需求之前也被運用在抽象基底類別,例如 :class:`~collections.abc.Iterable`。" | ||
"這種方式的問題在於,一個類別需要顯式的標記來支援他們,這並不符合 Python 風" | ||
"格,也不像一個常見的慣用動態型別 Python 程式碼。舉例來說,下列程式碼符合 :" | ||
"pep:`484`: ::" | ||
#: ../../library/typing.rst:786 | ||
msgid "" | ||
@@ -916,13 +922,19 @@ msgid "" | ||
"``Iterable[int]`` by static type checkers. This is known as *structural " | ||
"subtyping* (or static duck-typing)::" | ||
msgstr "" | ||
":pep:`544` 可以透過使用上方的程式碼,且在類別定義時不用顯式基底類別解決這個問" | ||
"題,讓 ``Bucket`` 被靜態型別檢查器隱性認為是 ``Sized`` 以及 " | ||
"``Iterable[int]`` 兩者的子型別。這就是眾所周知的\\ *結構子型別*\\ (或是靜態" | ||
"鴨子型別): ::" | ||
#: ../../library/typing.rst:802 | ||
msgid "" | ||
"Moreover, by subclassing a special class :class:`Protocol`, a user can " | ||
"define new custom protocols to fully enjoy structural subtyping (see " | ||
"examples below)." | ||
msgstr "" | ||
"而且,基於一個特別的型別 :class:`Protocol` 建立子型別時,使用者可以定義新的" | ||
"協定並充份發揮結構子型別的優勢(請見下方範例)。" | ||
#: ../../library/typing.rst:807 | ||
msgid "Module contents" | ||
@@ -932,54 +944,58 @@ msgstr "模組內容" | ||
msgid "" | ||
"The ``typing`` module defines the following classes, functions and " | ||
"decorators." | ||
msgstr "模組 ``typing`` 定義了下列的類別、函式以及裝飾器。" | ||
#: ../../library/typing.rst:812 | ||
msgid "Special typing primitives" | ||
msgstr "特別型別原語 (primitive)" | ||
#: ../../library/typing.rst:815 | ||
msgid "Special types" | ||
msgstr "特別型別" | ||
#: ../../library/typing.rst:817 | ||
msgid "" | ||
"These can be used as types in annotations. They do not support subscription " | ||
"using ``[]``." | ||
msgstr "這些可以在註釋中做為型別。他們並不支援 ``[]`` 的下標使用。" | ||
#: ../../library/typing.rst:822 | ||
msgid "Special type indicating an unconstrained type." | ||
msgstr "特別型別,指出一個不受約束 (unconstrained) 的型別。" | ||
#: ../../library/typing.rst:824 | ||
msgid "Every type is compatible with :data:`Any`." | ||
msgstr "所有型別皆與 :data:`Any` 相容。" | ||
#: ../../library/typing.rst:825 | ||
msgid ":data:`Any` is compatible with every type." | ||
msgstr ":data:`Any` 相容於所有型別。" | ||
#: ../../library/typing.rst:827 | ||
msgid "" | ||
":data:`Any` can now be used as a base class. This can be useful for avoiding " | ||
"type checker errors with classes that can duck type anywhere or are highly " | ||
"dynamic." | ||
msgstr "" | ||
":data:`Any` 可以作為一個基礎類別。這對於在任何地方使用鴨子型別或是高度動態的" | ||
"型別,避免型別檢查器的錯誤是非常有用的。" | ||
#: ../../library/typing.rst:834 | ||
msgid "A :ref:`constrained type variable <typing-constrained-typevar>`." | ||
msgstr "一個\\ :ref:`不受約束的型別變數 <typing-constrained-typevar>`。" | ||
#: ../../library/typing.rst:836 | ||
msgid "Definition::" | ||
msgstr "定義: ::" | ||
#: ../../library/typing.rst:840 | ||
msgid "" | ||
"``AnyStr`` is meant to be used for functions that may accept :class:`str` " | ||
"or :class:`bytes` arguments but cannot allow the two to mix." | ||
msgstr "" | ||
"``AnyStr`` 是對於函式有用的,他可以接受 :class:`str` 或 :class:`bytes` 引數但" | ||
"不可以將此兩種混合。" | ||
#: ../../library/typing.rst:843 ../../library/typing.rst:934 | ||
#: ../../library/typing.rst:953 ../../library/typing.rst:1010 | ||
@@ -997,10 +1013,13 @@ msgid "" | ||
"`Any` type, nor does it mean \"any string\". In particular, ``AnyStr`` and " | ||
"``str | bytes`` are different from each other and have different use cases::" | ||
msgstr "" | ||
"請注意,儘管他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任" | ||
"何字串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用" | ||
"情境: ::" | ||
#: ../../library/typing.rst:869 | ||
msgid "Special type that includes only literal strings." | ||
msgstr "特別型別,只包含文本字串。" | ||
#: ../../library/typing.rst:871 | ||
msgid "" | ||
@@ -1009,13 +1028,13 @@ msgid "" | ||
"created by composing ``LiteralString``-typed objects is also acceptable as a " | ||
"``LiteralString``." | ||
msgstr "" | ||
"任何文本字串都相容於 ``LiteralString``,對於另一個 ``LiteralString`` 亦是如" | ||
"此。然而,若是一個型別僅為 ``str`` 的物件則不相容。一個字串若是透過組合多個 " | ||
"``LiteralString`` 型別的物件建立,則此字串也可以視為 ``LiteralString``。" | ||
#: ../../library/typing.rst:877 ../../library/typing.rst:1957 | ||
msgid "Example:" | ||
msgstr "舉例來說: ::" | ||
#: ../../library/typing.rst:893 | ||
msgid "" | ||
@@ -1024,6 +1043,9 @@ msgid "" | ||
"that generate type checker errors could be vulnerable to an SQL injection " | ||
"attack." | ||
msgstr "" | ||
"``LiteralString`` 對於敏感的 API 來說是有用的,其中任意的使用者產生的字串可能" | ||
"會產生問題。舉例來說,上面兩個案例中產生的型別檢查器錯誤是脆弱的且容易受到 " | ||
"SQL 注入攻擊。" | ||
#: ../../library/typing.rst:898 | ||
msgid "See :pep:`675` for more details." | ||
@@ -1034,22 +1056,26 @@ msgid "" | ||
"The `bottom type <https://en.wikipedia.org/wiki/Bottom_type>`_, a type that " | ||
"has no members." | ||
msgstr "" | ||
"`底部型別 (bottom type) <https://en.wikipedia.org/wiki/Bottom_type>`_,為一個" | ||
"型別但沒有任何的成員。" | ||
#: ../../library/typing.rst:907 | ||
msgid "" | ||
"This can be used to define a function that should never be called, or a " | ||
"function that never returns::" | ||
msgstr "這可以被用來定義一個不應被呼叫的函式,或是一個不會回傳的函式: ::" | ||
#: ../../library/typing.rst:927 | ||
msgid "" | ||
"On older Python versions, :data:`NoReturn` may be used to express the same " | ||
"concept. ``Never`` was added to make the intended meaning more explicit." | ||
msgstr "" | ||
"在舊的 Python 版本當中,:data:`NoReturn` 可以用來當作一樣的概念使用。新增 " | ||
"``Never`` 之後,則讓這個含義變得更為明確。" | ||
#: ../../library/typing.rst:932 | ||
msgid "Special type indicating that a function never returns." | ||
msgstr "特別型別,指出一個永不回傳的函式。" | ||
#: ../../library/typing.rst:941 | ||
msgid "" | ||
@@ -1058,16 +1084,19 @@ msgid "" | ||
"the :data:`Never` type should be used for this concept instead. Type " | ||
"checkers should treat the two equivalently." | ||
msgstr "" | ||
"``NoReturn`` 可以用來作為一個\\ `底部型別 <https://en.wikipedia.org/wiki/" | ||
"Bottom_type>`_,一個沒有值的型別。從 Python 3.11 開始,型別 :data:`Never` 應" | ||
"該改用這個概念。型別檢查器應該將這兩種型別視為相等的。" | ||
#: ../../library/typing.rst:951 | ||
msgid "Special type to represent the current enclosed class." | ||
msgstr "特別型別,用來表示當前類別之內 (enclosed class)。" | ||
#: ../../library/typing.rst:967 | ||
msgid "" | ||
"This annotation is semantically equivalent to the following, albeit in a " | ||
"more succinct fashion::" | ||
msgstr "這個註釋在語意上相等於下列內容,且形式更為簡潔: ::" | ||
#: ../../library/typing.rst:979 | ||
msgid "" | ||
@@ -1077,26 +1106,34 @@ msgid "" | ||
"object returned from ``SubclassOfFoo.return_self`` as being of type ``Foo`` " | ||
"rather than ``SubclassOfFoo``." | ||
msgstr "" | ||
"一般來說,如果某個東西回傳 ``self`` 如上方的範例所示,你則應該使用 ``Self`` " | ||
"做為回傳值的註釋。若 ``Foo.return_self`` 被註釋為回傳 ``\"Foo\"``,則型別檢查" | ||
"器應該推論這個從 ``SubclassOfFoo.return_self`` 回傳的物件為 ``Foo`` 型別,而" | ||
"並非回傳 ``SubclassOfFoo`` 型別。" | ||
#: ../../library/typing.rst:985 | ||
msgid "Other common use cases include:" | ||
msgstr "其他常見的使用案例包含: ::" | ||
#: ../../library/typing.rst:987 | ||
msgid "" | ||
":class:`classmethod`\\s that are used as alternative constructors and return " | ||
"instances of the ``cls`` parameter." | ||
msgstr "" | ||
":class:`classmethod` 被用來作為替代的建構函式 (constructor) 並回傳 ``cls`` 參" | ||
"數的實例。" | ||
#: ../../library/typing.rst:989 | ||
msgid "Annotating an :meth:`~object.__enter__` method which returns self." | ||
msgstr "註釋一個回傳自己的 :meth:`~object.__enter__` 方法。" | ||
#: ../../library/typing.rst:991 | ||
msgid "" | ||
"You should not use ``Self`` as the return annotation if the method is not " | ||
"guaranteed to return an instance of a subclass when the class is subclassed::" | ||
msgstr "" | ||
"當類別被子類別化時,若方法不保證回傳一個子類別的實例,你不應該使用 ``Self`` " | ||
"作為回傳註釋: ::" | ||
#: ../../library/typing.rst:1002 | ||
msgid "See :pep:`673` for more details." | ||
@@ -1106,14 +1143,17 @@ msgstr "更多細節請見 :pep:`673`。" | ||
msgid "" | ||
"Special annotation for explicitly declaring a :ref:`type alias <type-" | ||
"aliases>`." | ||
msgstr "做為明確宣告一個\\ :ref:`型別別名 <type-aliases>` 的特別註釋。" | ||
#: ../../library/typing.rst:1016 | ||
msgid "" | ||
"``TypeAlias`` is particularly useful on older Python versions for annotating " | ||
"aliases that make use of forward references, as it can be hard for type " | ||
"checkers to distinguish these from normal variable assignments:" | ||
msgstr "" | ||
"``TypeAlias`` 在舊的 Python 版本中特別有用,其註釋別名可以用來進行傳遞參照 " | ||
"(forward reference),因為對於型別檢查器來說,分辨這些別名與一般的變數賦值相當" | ||
"困難: ::" | ||
#: ../../library/typing.rst:1036 | ||
msgid "See :pep:`613` for more details." | ||
@@ -1129,6 +1169,11 @@ msgid "" | ||
"`TypeAlias` is not currently planned, but users are encouraged to migrate " | ||
"to :keyword:`type` statements." | ||
msgstr "" | ||
":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建立 :class:" | ||
"`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖然 :data:" | ||
"`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名稱,他們" | ||
"是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計畫,但鼓" | ||
"勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" | ||
#: ../../library/typing.rst:1051 | ||
msgid "Special forms" | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.