Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Translation librart/typing.po rst:457 ~ rst:762 #757

Merged
merged 8 commits into from
Mar 5, 2024
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 67 additions & 14 deletions library/typing.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-09 00:04+0000\n"
"PO-Revision-Date: 2023-11-06 10:51+0800\n"
"PO-Revision-Date: 2023-12-15 14:45+0800\n"
"Last-Translator: RockLeon <[email protected]>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
Expand Down Expand Up @@ -623,7 +623,7 @@ msgstr ""

#: ../../library/typing.rst:457
msgid "The type of class objects"
msgstr ""
msgstr "類別物件的型別"

#: ../../library/typing.rst:459
msgid ""
Expand All @@ -632,86 +632,103 @@ msgid ""
"<Type>`) may accept values that are classes themselves -- specifically, it "
"will accept the *class object* of ``C``. For example::"
msgstr ""
"一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解"
"為 ``type[C]`` \\ (或 :class:`typing.Type[C] <Type>`)\\ 可以接受本身為該類"
"別的值 -- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\。舉例來說: ::"

#: ../../library/typing.rst:469
msgid "Note that ``type[C]`` is covariant::"
msgstr ""
msgstr "請記得 ``type[C]`` 是共變 (covariant) 的: ::"

#: ../../library/typing.rst:485
msgid ""
"The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:"
"`type variables <generics>`, and unions of any of these types. For example::"
msgstr ""
":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 "
"<generics>`\\ 以及這些型別任意組合成的聯集。舉例來說: ::"

#: ../../library/typing.rst:497
msgid ""
"``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :"
"ref:`metaclass hierarchy <metaclasses>`."
msgstr ""
"``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結"
"構 (hierachy) <metaclasses>`。"

#: ../../library/typing.rst:503
msgid "User-defined generic types"
msgstr ""
msgstr "使用者定義泛型型別"

#: ../../library/typing.rst:505
msgid "A user-defined class can be defined as a generic class."
msgstr ""
msgstr "一個使用者定義的類別可以被定義成一個泛型類別。"

#: ../../library/typing.rst:528
msgid ""
"This syntax indicates that the class ``LoggedVar`` is parameterised around a "
"single :ref:`type variable <typevar>` ``T`` . This also makes ``T`` valid as "
"a type within the class body."
msgstr ""
"這個語法指出類別 ``LoggedVar`` 透過一個單一的 :ref:`型別變數 <typevar>` "
"``T`` 進行參數化 (parameterised)。這使得 ``T`` 在類別中有效的成為型別。"

#: ../../library/typing.rst:532
msgid ""
"Generic classes implicitly inherit from :class:`Generic`. For compatibility "
"with Python 3.11 and lower, it is also possible to inherit explicitly from :"
"class:`Generic` to indicate a generic class::"
msgstr ""
"泛型類別隱性繼承了 :class:`Generic`。為了相容 Python 3.11 及更早版本,也可以"
"明確的繼承 :class:`Generic` 並指出是一個泛型類別: ::"

#: ../../library/typing.rst:543
msgid ""
"Generic classes have :meth:`~object.__class_getitem__` methods, meaning they "
"can be parameterised at runtime (e.g. ``LoggedVar[int]`` below)::"
msgstr ""
"泛型類別有 :meth:`~object.__class_getitem__` 方法,其意味著可以在 runtime 進"
"行參數化(如下述的 ``LoggedVar[int]``): ::"
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved

#: ../../library/typing.rst:552
msgid ""
"A generic type can have any number of type variables. All varieties of :"
"class:`TypeVar` are permissible as parameters for a generic type::"
msgstr ""
"一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為"
"泛型型別的參數: ::"

#: ../../library/typing.rst:567
msgid ""
"Each type variable argument to :class:`Generic` must be distinct. This is "
"thus invalid::"
msgstr ""
msgstr ":class:`Generic` 的每個型別變數引數必不相同。因此以下是無效的: ::"

#: ../../library/typing.rst:581
msgid "Generic classes can also inherit from other classes::"
msgstr ""
msgstr "泛型類別亦可以繼承其他類別: ::"

#: ../../library/typing.rst:588
msgid ""
"When inheriting from generic classes, some type parameters could be fixed::"
msgstr ""
msgstr "當繼承泛型類別時,部份的型別參數可固定: ::"

#: ../../library/typing.rst:595
msgid "In this case ``MyDict`` has a single parameter, ``T``."
msgstr ""
msgstr "在這種情況下 ``MyDict`` 有一個單一的參數 ``T``。"

#: ../../library/typing.rst:597
msgid ""
"Using a generic class without specifying type parameters assumes :data:`Any` "
"for each position. In the following example, ``MyIterable`` is not generic "
"but implicitly inherits from ``Iterable[Any]``:"
msgstr ""
"若使用泛型類別卻沒有特指型別參數,則會將每個位置視為 :data:`Any`。在下列的範"
"例中 ``MyIterable`` 不是泛型,但隱性繼承了 ``Iterable[Any]``: ::"

#: ../../library/typing.rst:608
msgid "User-defined generic type aliases are also supported. Examples::"
msgstr ""
msgstr "使用者定義的泛型型別別名也有支援。例如: ::"

#: ../../library/typing.rst:623
msgid ""
Expand All @@ -721,14 +738,16 @@ msgstr "為了向後相容性,泛型型別別名可以透過簡單的賦值來

#: ../../library/typing.rst:632
msgid ":class:`Generic` no longer has a custom metaclass."
msgstr ""
msgstr ":class:`Generic` 不再是一個自訂的 metaclass。"

#: ../../library/typing.rst:635
msgid ""
"Syntactic support for generics and type aliases is new in version 3.12. "
"Previously, generic classes had to explicitly inherit from :class:`Generic` "
"or contain a type variable in one of their bases."
msgstr ""
"在版本 3.12 新增了泛型及型別別名的語法支援。在之前的版本中,泛型類別必須顯性"
"繼承 :class:`Generic` 或是包含一個型別變數在基底類別 (base) 當中。"

#: ../../library/typing.rst:640
msgid ""
Expand All @@ -739,12 +758,18 @@ msgid ""
"The one exception to this is that a list of types can be used to substitute "
"a :class:`ParamSpec`::"
msgstr ""
"使用者定義的參數運算式 (parameter expression) 泛型一樣有支援,透過 ``[**P]`` "
"格式的參數規格變數來進行表示。對於上述作為參數規格變數的型別變數,將持續被型"
"別模組視為一個特定的型別變數。對此,其中一個例外是一個型別列表可以替代 :"
"class:`ParamSpec`: ::"

#: ../../library/typing.rst:651
msgid ""
"Classes generic over a :class:`ParamSpec` can also be created using explicit "
"inheritance from :class:`Generic`. In this case, ``**`` is not used::"
msgstr ""
"具有 :class:`ParamSpec` 的泛型類別可以透過顯性繼承 :class:`Generic` 進行建"
"立。在這種情況下,不需要使用 ``**``: ::"

#: ../../library/typing.rst:661
msgid ""
Expand All @@ -754,19 +779,27 @@ msgid ""
"Type2, ...]`` for aesthetic reasons. Internally, the latter is converted to "
"the former, so the following are equivalent::"
msgstr ""
"另外一個 :class:`TypeVar` 以及 :class:`ParamSpec` 之間的差異是,基於美觀因"
"素,只有一個參數規格變數的泛型可以接受如 ``X[[Type1, Type2, ...]]`` 以及 "
"``X[Type1, Type2, ...]`` 的參數列表。在內部中,後者會被轉換為前者,所以在下方"
"的範例中為相等的: ::"

#: ../../library/typing.rst:674
msgid ""
"Note that generics with :class:`ParamSpec` may not have correct "
"``__parameters__`` after substitution in some cases because they are "
"intended primarily for static type checking."
msgstr ""
"請記得,具有 :class:`ParamSpec` 的泛型在某些情況下替換之後可能不會有正確的 "
"``__parameters__``,因為參數規格主要還是用於靜態型別檢查。"

#: ../../library/typing.rst:678
msgid ""
":class:`Generic` can now be parameterized over parameter expressions. See :"
"class:`ParamSpec` and :pep:`612` for more details."
msgstr ""
":class:`Generic` 現在可以透過參數運算式來進行參數化。詳細內容請見 :class:"
"`ParamSpec` 以及 :pep:`612`。"

#: ../../library/typing.rst:682
msgid ""
Expand All @@ -775,6 +808,9 @@ msgid ""
"parameterizing generics is cached, and most types in the typing module are :"
"term:`hashable` and comparable for equality."
msgstr ""
"一個使用者定義的泛型類別可以將 ABC 作為他們的基底類別,且不會有 metaclass 衝"
"突。泛型的 metaclass 則不支援。參數化泛型的輸出將被存為快取,而在型別模組中多"
"數的型別皆為 :term:`hashable` 且可以比較相等性。"

#: ../../library/typing.rst:689
msgid "The :data:`Any` type"
Expand All @@ -786,12 +822,16 @@ msgid ""
"every type as being compatible with :data:`Any` and :data:`Any` as being "
"compatible with every type."
msgstr ""
":data:`Any` 是一種特別的型別。一個靜態型別檢查器會將每個型別視為可相容於 :"
"data:`Any` 且 :data:`Any` 也可以相容於每個型別。"

#: ../../library/typing.rst:695
msgid ""
"This means that it is possible to perform any operation or method call on a "
"value of type :data:`Any` and assign it to any variable::"
msgstr ""
"這意味著如果在一個為 :data:`Any` 的值上執行任何操作或呼叫方法是可行的,且可以"
"賦值給任意變數: ::"

#: ../../library/typing.rst:713
msgid ""
Expand All @@ -801,18 +841,23 @@ msgid ""
"declared to be of type :class:`str` and receives an :class:`int` value at "
"runtime!"
msgstr ""
"請注意,當賦予型別為 :data:`Any` 的值更精確的型別時,將不會執行任何型別檢查。"
"舉例來說,靜態型別檢查器不會在 runtime 中,將 ``a`` 賦值給 ``s`` 的情況下回報"
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved
"錯誤,儘管 ``s`` 是被宣告為型別 :class:`str` 卻接收到 :class:`int` 的值!"

#: ../../library/typing.rst:719
msgid ""
"Furthermore, all functions without a return type or parameter types will "
"implicitly default to using :data:`Any`::"
msgstr ""
msgstr "另外,所有缺少回傳型別或參數型別的函式將會隱性預設為 :data:`Any`: ::"

#: ../../library/typing.rst:732
msgid ""
"This behavior allows :data:`Any` to be used as an *escape hatch* when you "
"need to mix dynamically and statically typed code."
msgstr ""
"當你需要混和動態及靜態的型別程式碼,這個行為允許 :data:`Any` 被當作一個\\ *緊"
"急出口 (escape hatch)*\\使用。"

#: ../../library/typing.rst:735
msgid ""
Expand All @@ -821,6 +866,9 @@ msgid ""
"unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a "
"subtype of every other type."
msgstr ""
":data:`Any` 的行為對比 :class:`object` 的行為。與 :data:`Any` 相似,所有的型"
"別會作為 :class:`object` 的子型別。然而,不像 :data:`Any`,反之不亦然::"
"class:`object` 並\\ *不是*\\一個其他型別的子型別。"

#: ../../library/typing.rst:740
msgid ""
Expand All @@ -829,12 +877,17 @@ msgid ""
"it as a return value) of a more specialized type is a type error. For "
"example::"
msgstr ""
"這意味著當一個值的型別為 :class:`object` 時,型別檢查器會拒絕幾乎所有的操作,"
"並將賦予這個值到一個特定型別變數(或是當作回傳值使用)視為一個型別錯誤。舉例"
"來說: ::"

#: ../../library/typing.rst:762
msgid ""
"Use :class:`object` to indicate that a value could be any type in a typesafe "
"manner. Use :data:`Any` to indicate that a value is dynamically typed."
msgstr ""
"使用 :class:`object` ,將指出在型別安全 (typesafe) 的習慣之下一個值可以為任意"
"型別。使用 :data:`Any`,將指出這個值是個動態型別。"

#: ../../library/typing.rst:767
msgid "Nominal vs structural subtyping"
Expand Down Expand Up @@ -1197,7 +1250,7 @@ msgstr ""

#: ../../library/typing.rst:1166
msgid ":class:`ParamSpec`"
msgstr ":class:`ParamSpec`"
msgstr ":class:`ParamSpec`"

#: ../../library/typing.rst:1167 ../../library/typing.rst:1929
msgid ":ref:`annotating-callables`"
Expand Down Expand Up @@ -3612,7 +3665,7 @@ msgstr ":gh:`92332`"

#: ../../library/typing.rst:3684
msgid ":class:`typing.Hashable` and :class:`typing.Sized`"
msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`"
msgstr ":class:`typing.Hashable` 和 :class:`typing.Sized`"

#: ../../library/typing.rst:3685 ../../library/typing.rst:3689
msgid "3.12"
Expand Down