From e9d85e0de6751fa83618d3992e0c29729b6b443d Mon Sep 17 00:00:00 2001 From: rockleona Date: Thu, 14 Dec 2023 20:18:44 +0800 Subject: [PATCH 1/7] Translate Part 1 --- library/typing.po | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/library/typing.po b/library/typing.po index 3f530c1190..305d0d7ee4 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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-14 20:17+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -623,7 +623,7 @@ msgstr "" #: ../../library/typing.rst:457 msgid "The type of class objects" -msgstr "" +msgstr "類別物件的型別" #: ../../library/typing.rst:459 msgid "" @@ -632,30 +632,37 @@ msgid "" "`) 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] `)可以接受本身為該類別的值 " +"-- 具體來說,他可能會接受 ``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 `, and unions of any of these types. For example::" msgstr "" +":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 `以" +"及這些型別任意組合成的交集。舉例來說: ::" #: ../../library/typing.rst:497 msgid "" "``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :" "ref:`metaclass hierarchy `." msgstr "" +"``type[Any]`` 以及 :class:`type` 是相等的,其為 Python :ref:`metaclass 階層結" +"構 (hierachy) `。" #: ../../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 "" @@ -663,6 +670,8 @@ msgid "" "single :ref:`type variable ` ``T`` . This also makes ``T`` valid as " "a type within the class body." msgstr "" +"這個語法指出類別 ``LoggedVar`` 透過一個單一的 :ref:`型別變數 ` " +"``T`` 進行參數化 (parameterised)。這使得 ``T`` 在類別中有效的成為型別。" #: ../../library/typing.rst:532 msgid "" @@ -670,6 +679,8 @@ msgid "" "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 "" @@ -1197,7 +1208,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`" @@ -3612,7 +3623,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" From 807763788f9d7ec566b053d1ba3ad2f525c8258f Mon Sep 17 00:00:00 2001 From: rockleona Date: Fri, 15 Dec 2023 10:38:15 +0800 Subject: [PATCH 2/7] Translate Part 2 --- library/typing.po | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/typing.po b/library/typing.po index 305d0d7ee4..a41ca21b33 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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-12-14 20:17+0800\n" +"PO-Revision-Date: 2023-12-15 10:37+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -687,31 +687,35 @@ 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]``): ::" #: ../../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 "" From c884c8237d89319c42fe270d601599d7c360e08e Mon Sep 17 00:00:00 2001 From: rockleona Date: Fri, 15 Dec 2023 14:20:32 +0800 Subject: [PATCH 3/7] Finish Translate Sections --- library/typing.po | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/library/typing.po b/library/typing.po index a41ca21b33..bfdf129e6d 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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-12-15 10:37+0800\n" +"PO-Revision-Date: 2023-12-15 14:19+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -723,10 +723,12 @@ msgid "" "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 "" @@ -736,7 +738,7 @@ msgstr "為了向後相容性,泛型型別別名可以透過簡單的賦值來 #: ../../library/typing.rst:632 msgid ":class:`Generic` no longer has a custom metaclass." -msgstr "" +msgstr ":class:`Generic` 不再是一個自訂的 metaclass。" #: ../../library/typing.rst:635 msgid "" @@ -744,6 +746,8 @@ msgid "" "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 "" @@ -754,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 "" @@ -769,6 +779,10 @@ 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 "" @@ -776,12 +790,16 @@ msgid "" "``__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 "" @@ -790,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" @@ -801,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 "" @@ -816,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`` 的情況下回報" +"錯誤,儘管 ``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 "" @@ -836,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 "" @@ -844,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" From fcfdaa67a139cef33e00128fc0d8aeaeeacffddd Mon Sep 17 00:00:00 2001 From: rockleona Date: Fri, 15 Dec 2023 14:40:14 +0800 Subject: [PATCH 4/7] Fix reST Syntax --- library/typing.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/typing.po b/library/typing.po index bfdf129e6d..cc1d78d666 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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-12-15 14:19+0800\n" +"PO-Revision-Date: 2023-12-15 14:35+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -645,8 +645,8 @@ msgid "" "The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:" "`type variables `, and unions of any of these types. For example::" msgstr "" -":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 `以" -"及這些型別任意組合成的交集。舉例來說: ::" +":class:`type` 僅有的合法參數是類別、:data:`Any`、\\ :ref:`型別變數 " +"`\\ 以及這些型別任意組合成的交集。舉例來說: ::" #: ../../library/typing.rst:497 msgid "" From c675e5613c1312e6bd94e26847dafaad952a1627 Mon Sep 17 00:00:00 2001 From: rockleona Date: Thu, 18 Jan 2024 10:17:36 +0800 Subject: [PATCH 5/7] Fix Syntax, remove poetry.lock changer --- library/typing.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/typing.po b/library/typing.po index cc1d78d666..0a1bbb76b2 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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-12-15 14:35+0800\n" +"PO-Revision-Date: 2023-12-15 14:45+0800\n" "Last-Translator: RockLeon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -633,8 +633,8 @@ msgid "" "will accept the *class object* of ``C``. For example::" msgstr "" "一個變數被註解為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解" -"為 ``type[C]``(或 :class:`typing.Type[C] `)可以接受本身為該類別的值 " -"-- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\。舉例來說: ::" +"為 ``type[C]`` \\ (或 :class:`typing.Type[C] `)\\ 可以接受本身為該類" +"別的值 -- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\。舉例來說: ::" #: ../../library/typing.rst:469 msgid "Note that ``type[C]`` is covariant::" From b214d1c9adc89e713fefa31dc4c3f5433e984cf1 Mon Sep 17 00:00:00 2001 From: RockLeon <34214497+rockleona@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:22:35 +0800 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Jay <74105438+weijay0804@users.noreply.github.com> --- library/typing.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/typing.po b/library/typing.po index 0a1bbb76b2..8acbbd9e62 100644 --- a/library/typing.po +++ b/library/typing.po @@ -646,14 +646,14 @@ msgid "" "`type variables `, and unions of any of these types. For example::" msgstr "" ":class:`type` 僅有的合法參數是類別、:data:`Any`、\\ :ref:`型別變數 " -"`\\ 以及這些型別任意組合成的交集。舉例來說: ::" +"`\\ 以及這些型別任意組合成的聯集。舉例來說: ::" #: ../../library/typing.rst:497 msgid "" "``type[Any]`` is equivalent to :class:`type`, which is the root of Python's :" "ref:`metaclass hierarchy `." msgstr "" -"``type[Any]`` 以及 :class:`type` 是相等的,其為 Python :ref:`metaclass 階層結" +"``type[Any]`` 等價於 :class:`type` ,其為 Python :ref:`metaclass 階層結" "構 (hierachy) `。" #: ../../library/typing.rst:503 @@ -723,7 +723,7 @@ msgid "" "for each position. In the following example, ``MyIterable`` is not generic " "but implicitly inherits from ``Iterable[Any]``:" msgstr "" -"若使用泛型類別卻沒有特指型別參數,則會將每個位子視為 :data:`Any`。在下列的範" +"若使用泛型類別卻沒有特指型別參數,則會將每個位置視為 :data:`Any`。在下列的範" "例中 ``MyIterable`` 不是泛型,但隱性繼承了 ``Iterable[Any]``: ::" #: ../../library/typing.rst:608 From cf5cd9504b1d0f96528be37f4986c6881cf7e237 Mon Sep 17 00:00:00 2001 From: rockleona Date: Mon, 26 Feb 2024 15:46:25 +0800 Subject: [PATCH 7/7] feat: update with reviewer's suggestions --- library/typing.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/typing.po b/library/typing.po index 8acbbd9e62..0cab46ae8d 100644 --- a/library/typing.po +++ b/library/typing.po @@ -632,7 +632,7 @@ msgid "" "`) may accept values that are classes themselves -- specifically, it " "will accept the *class object* of ``C``. For example::" msgstr "" -"一個變數被註解為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解" +"一個變數被註釋為 ``C`` 可以接受一個型別為 ``C`` 的值。相對的,一個變數備註解" "為 ``type[C]`` \\ (或 :class:`typing.Type[C] `)\\ 可以接受本身為該類" "別的值 -- 具體來說,他可能會接受 ``C`` 的\\ *類別物件*\\。舉例來說: ::" @@ -645,7 +645,7 @@ msgid "" "The only legal parameters for :class:`type` are classes, :data:`Any`, :ref:" "`type variables `, and unions of any of these types. For example::" msgstr "" -":class:`type` 僅有的合法參數是類別、:data:`Any`、\\ :ref:`型別變數 " +":class:`type` 僅有的合法參數是類別、:data:`Any`、:ref:`型別變數 " "`\\ 以及這些型別任意組合成的聯集。舉例來說: ::" #: ../../library/typing.rst:497 @@ -658,7 +658,7 @@ msgstr "" #: ../../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." @@ -696,7 +696,7 @@ msgid "" "class:`TypeVar` are permissible as parameters for a generic type::" msgstr "" "一個泛型型別可以有任意數量的型別變數。所有種類的 :class:`TypeVar` 都可以作為" -"泛型行別的參數: ::" +"泛型型別的參數: ::" #: ../../library/typing.rst:567 msgid "" @@ -768,7 +768,7 @@ 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` 進行建" +"具有 :class:`ParamSpec` 的泛型類別可以透過顯性繼承 :class:`Generic` 進行建" "立。在這種情況下,不需要使用 ``**``: ::" #: ../../library/typing.rst:661