From 5a43d23e628664e7ebec6726d10773c6eb52c591 Mon Sep 17 00:00:00 2001 From: rockleona Date: Mon, 18 Mar 2024 18:59:58 +0800 Subject: [PATCH 1/3] feat: finish translate parts --- library/typing.po | 87 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 21 deletions(-) diff --git a/library/typing.po b/library/typing.po index 6ff0ebf67a..70592ea98d 100644 --- a/library/typing.po +++ b/library/typing.po @@ -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: 2023-12-15 14:45+0800\n" -"Last-Translator: RockLeon \n" +"PO-Revision-Date: 2024-03-18 18:59+0800\n" +"Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -890,7 +890,7 @@ msgstr "" #: ../../library/typing.rst:767 msgid "Nominal vs structural subtyping" -msgstr "" +msgstr "標稱子型別 (nominal subtyping) vs 建構子型別" #: ../../library/typing.rst:769 msgid "" @@ -898,6 +898,8 @@ msgid "" "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,6 +922,10 @@ 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 "" @@ -923,6 +933,8 @@ msgid "" "define new custom protocols to fully enjoy structural subtyping (see " "examples below)." msgstr "" +"而且,基於一個特別的型別 :class:`Protocol` 建立子型別時,使用者可以定義新的" +"協定並完整的享受建構子型別(請見下方範例)。" #: ../../library/typing.rst:807 msgid "Module contents" @@ -932,33 +944,33 @@ msgstr "模組內容" msgid "" "The ``typing`` module defines the following classes, functions and " "decorators." -msgstr "" +msgstr "模組 ``typing``定義了下列的類別、函式以及裝飾器。" #: ../../library/typing.rst:812 msgid "Special typing primitives" -msgstr "" +msgstr "特別型別原語 (primitive)" #: ../../library/typing.rst:815 msgid "Special types" -msgstr "" +msgstr "特別型別" #: ../../library/typing.rst:817 msgid "" "These can be used as types in annotations. They do not support subscription " "using ``[]``." -msgstr "" +msgstr "這些可以在註釋中做為型別。他們並不支援 ``[]`` 的下標使用。" #: ../../library/typing.rst:822 msgid "Special type indicating an unconstrained type." -msgstr "" +msgstr "特別型別,指出一個不受約束 (unconstrained) 的型別。" #: ../../library/typing.rst:824 msgid "Every type is compatible with :data:`Any`." -msgstr "" +msgstr "所有型別皆與 :data:`Any` 相容。" #: ../../library/typing.rst:825 msgid ":data:`Any` is compatible with every type." -msgstr "" +msgstr ":data:`Any` 相容於所有型別。" #: ../../library/typing.rst:827 msgid "" @@ -966,20 +978,24 @@ msgid "" "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 `." -msgstr "" +msgstr "一個\\ :ref:`不受約束的型別變數 `。" #: ../../library/typing.rst:836 msgid "Definition::" -msgstr "" +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 "" +msgstr "特別型別,只包含文本字串。" #: ../../library/typing.rst:871 msgid "" @@ -1009,6 +1028,9 @@ 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:" @@ -1023,7 +1045,7 @@ msgid "" "generated strings could generate problems. For example, the two cases above " "that generate type checker errors could be vulnerable to an SQL injection " "attack." -msgstr "" +msgstr "``LiteralString``" #: ../../library/typing.rst:898 msgid "See :pep:`675` for more details." @@ -1034,22 +1056,26 @@ msgid "" "The `bottom type `_, a type that " "has no members." msgstr "" +"`底部型別 (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 "" +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 "" +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`` 可以用來作為一個\\ `底部型別`_,一個沒有值的型別。從 Python 3.11 開始,型別 :data:`Never` 應" +"該改用這個概念。型別檢查器應該將這兩種型別視為相等的。" #: ../../library/typing.rst:951 msgid "Special type to represent the current enclosed class." -msgstr "" +msgstr "特別型別,用來表示當前類別之內 (enclosed class)。" #: ../../library/typing.rst:967 msgid "" "This annotation is semantically equivalent to the following, albeit in a " "more succinct fashion::" -msgstr "" +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 "" +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 "" +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,7 +1143,7 @@ msgstr "更多細節請見 :pep:`673`。" msgid "" "Special annotation for explicitly declaring a :ref:`type alias `." -msgstr "" +msgstr "特別註釋,做為顯性宣告一個\\ :ref:`型別別名 `。" #: ../../library/typing.rst:1016 msgid "" @@ -1114,6 +1151,9 @@ msgid "" "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" From 0d0b648c0857a69673d63c81c0dde4ea0810aa28 Mon Sep 17 00:00:00 2001 From: rockleona Date: Tue, 19 Mar 2024 10:41:01 +0800 Subject: [PATCH 2/3] fix: update syntax --- library/typing.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/typing.po b/library/typing.po index 70592ea98d..3f76890680 100644 --- a/library/typing.po +++ b/library/typing.po @@ -944,7 +944,7 @@ msgstr "模組內容" msgid "" "The ``typing`` module defines the following classes, functions and " "decorators." -msgstr "模組 ``typing``定義了下列的類別、函式以及裝飾器。" +msgstr "模組 ``typing`` 定義了下列的類別、函式以及裝飾器。" #: ../../library/typing.rst:812 msgid "Special typing primitives" @@ -1014,7 +1014,7 @@ msgid "" "``str | bytes`` are different from each other and have different use cases::" msgstr "" "請注意,除了他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任" -"何文串」的意思。尤其,``AnyStr`` 與 ``str | bytes``兩者不同且具有不同的使用情" +"何文串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用情" "境: ::" #: ../../library/typing.rst:869 @@ -1084,7 +1084,7 @@ msgid "" "the :data:`Never` type should be used for this concept instead. Type " "checkers should treat the two equivalently." msgstr "" -"``NoReturn`` 可以用來作為一個\\ `底部型別`_,一個沒有值的型別。從 Python 3.11 開始,型別 :data:`Never` 應" "該改用這個概念。型別檢查器應該將這兩種型別視為相等的。" From cba2279fb95416c88e5563ca3c118736cec820e8 Mon Sep 17 00:00:00 2001 From: rockleona <34214497+rockleona@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:30:37 +0800 Subject: [PATCH 3/3] fix(library/typing.po): update with reviewer's suggestion --- library/typing.po | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/library/typing.po b/library/typing.po index 3f76890680..379df25e8a 100644 --- a/library/typing.po +++ b/library/typing.po @@ -7,7 +7,7 @@ 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-18 18:59+0800\n" +"PO-Revision-Date: 2024-03-26 11:30+0800\n" "Last-Translator: Li-Hung Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-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)" +":pep:`544`: 協定:結構子型別 (Structural Subtyping) (靜態鴨子型別,Static " +"Duck Typing)" #: ../../library/typing.rst:80 msgid "" @@ -890,7 +890,7 @@ msgstr "" #: ../../library/typing.rst:767 msgid "Nominal vs structural subtyping" -msgstr "標稱子型別 (nominal subtyping) vs 建構子型別" +msgstr "標稱 (nominal) 子型別 vs 結構子型別" #: ../../library/typing.rst:769 msgid "" @@ -899,7 +899,7 @@ msgid "" "expected if and only if ``A`` is a subclass of ``B``." msgstr "" "最初 :pep:`484` 定義 Python 靜態型別系統使用\\ *標稱子型別*。這意味著只有 " -"``A`` 為 ``B`` 的子類別時,``A`` 才被允許使用在預期類別 ``B`` 的地方。" +"``A`` 為 ``B`` 的子類別時,``A`` 才被允許使用在預期是類別 ``B`` 出現的地方。" #: ../../library/typing.rst:773 msgid "" @@ -924,7 +924,7 @@ msgid "" msgstr "" ":pep:`544` 可以透過使用上方的程式碼,且在類別定義時不用顯式基底類別解決這個問" "題,讓 ``Bucket`` 被靜態型別檢查器隱性認為是 ``Sized`` 以及 " -"``Iterable[int]`` 兩者的子型別。這就是眾所周知的\\ *建構子型別*\\ (或是靜態" +"``Iterable[int]`` 兩者的子型別。這就是眾所周知的\\ *結構子型別*\\ (或是靜態" "鴨子型別): ::" #: ../../library/typing.rst:802 @@ -934,7 +934,7 @@ msgid "" "examples below)." msgstr "" "而且,基於一個特別的型別 :class:`Protocol` 建立子型別時,使用者可以定義新的" -"協定並完整的享受建構子型別(請見下方範例)。" +"協定並充份發揮結構子型別的優勢(請見下方範例)。" #: ../../library/typing.rst:807 msgid "Module contents" @@ -1013,9 +1013,9 @@ 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`` 兩者不同且具有不同的使用情" -"境: ::" +"請注意,儘管他的名稱相近,``AnyStr`` 與 :class:`Any` 型別無關,更不代表是「任" +"何字串」的意思。尤其,``AnyStr`` 與 ``str | bytes`` 兩者不同且具有不同的使用" +"情境: ::" #: ../../library/typing.rst:869 msgid "Special type that includes only literal strings." @@ -1028,16 +1028,13 @@ msgid "" "created by composing ``LiteralString``-typed objects is also acceptable as a " "``LiteralString``." msgstr "" -"任何文本字串都相容於 ``LiteralString``,其他 ``LiteralString`` 亦同。然而,若" -"一個物件型別為 ``str`` 則不相容。一個字串透過組合 ``LiteralString`` 建立 -- " -"這些該型別物件也可以視為 ``LiteralString``。" +"任何文本字串都相容於 ``LiteralString``,對於另一個 ``LiteralString`` 亦是如" +"此。然而,若是一個型別僅為 ``str`` 的物件則不相容。一個字串若是透過組合多個 " +"``LiteralString`` 型別的物件建立,則此字串也可以視為 ``LiteralString``。" #: ../../library/typing.rst:877 ../../library/typing.rst:1957 msgid "Example:" -msgstr "" -"舉例來說:\n" -"\n" -"::" +msgstr "舉例來說: ::" #: ../../library/typing.rst:893 msgid "" @@ -1045,7 +1042,10 @@ msgid "" "generated strings could generate problems. For example, the two cases above " "that generate type checker errors could be vulnerable to an SQL injection " "attack." -msgstr "``LiteralString``" +msgstr "" +"``LiteralString`` 對於敏感的 API 來說是有用的,其中任意的使用者產生的字串可能" +"會產生問題。舉例來說,上面兩個案例中產生的型別檢查器錯誤是脆弱的且容易受到 " +"SQL 注入攻擊。" #: ../../library/typing.rst:898 msgid "See :pep:`675` for more details." @@ -1063,7 +1063,7 @@ msgstr "" msgid "" "This can be used to define a function that should never be called, or a " "function that never returns::" -msgstr "這可以被用來定義一個可能永遠不呼叫的函式,或是一個不會回傳的函式: ::" +msgstr "這可以被用來定義一個不應被呼叫的函式,或是一個不會回傳的函式: ::" #: ../../library/typing.rst:927 msgid "" @@ -1071,7 +1071,7 @@ msgid "" "concept. ``Never`` was added to make the intended meaning more explicit." msgstr "" "在舊的 Python 版本當中,:data:`NoReturn` 可以用來當作一樣的概念使用。新增 " -"``Never`` 之後,則讓這個意圖變得更為顯性。" +"``Never`` 之後,則讓這個含義變得更為明確。" #: ../../library/typing.rst:932 msgid "Special type indicating that a function never returns." @@ -1106,10 +1106,10 @@ msgid "" "object returned from ``SubclassOfFoo.return_self`` as being of type ``Foo`` " "rather than ``SubclassOfFoo``." msgstr "" -"一般來說,如果某個東西回傳 ``self``,而在上方的範例之中,你應該使用 ``Self`` " +"一般來說,如果某個東西回傳 ``self`` 如上方的範例所示,你則應該使用 ``Self`` " "做為回傳值的註釋。若 ``Foo.return_self`` 被註釋為回傳 ``\"Foo\"``,則型別檢查" -"器應該推論這個物件是從 ``SubclassOfFoo.return_self`` 進行回傳 ``Foo``,而並非" -"回傳 ``SubclassOfFoo``。" +"器應該推論這個從 ``SubclassOfFoo.return_self`` 回傳的物件為 ``Foo`` 型別,而" +"並非回傳 ``SubclassOfFoo`` 型別。" #: ../../library/typing.rst:985 msgid "Other common use cases include:" @@ -1132,8 +1132,8 @@ 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`` 作為回傳註釋: ::" +"當類別被子類別化時,若方法不保證回傳一個子類別的實例,你不應該使用 ``Self`` " +"作為回傳註釋: ::" #: ../../library/typing.rst:1002 msgid "See :pep:`673` for more details." @@ -1143,7 +1143,7 @@ msgstr "更多細節請見 :pep:`673`。" msgid "" "Special annotation for explicitly declaring a :ref:`type alias `." -msgstr "特別註釋,做為顯性宣告一個\\ :ref:`型別別名 `。" +msgstr "做為明確宣告一個\\ :ref:`型別別名 ` 的特別註釋。" #: ../../library/typing.rst:1016 msgid "" @@ -1152,8 +1152,8 @@ msgid "" "checkers to distinguish these from normal variable assignments:" msgstr "" "``TypeAlias`` 在舊的 Python 版本中特別有用,其註釋別名可以用來進行傳遞參照 " -"(forward reference),對於型別檢查器來說,分辨這些別名與一般的變數賦值相當困" -"難: ::" +"(forward reference),因為對於型別檢查器來說,分辨這些別名與一般的變數賦值相當" +"困難: ::" #: ../../library/typing.rst:1036 msgid "See :pep:`613` for more details." @@ -1172,8 +1172,8 @@ msgstr "" ":data:`TypeAlias` 被棄用,請改用 :keyword:`type` 陳述式來建立 :class:" "`TypeAliasType` 的實例,其自然可以支援傳遞參照的使用。請注意,雖然 :data:" "`TypeAlias` 以及 :class:`TypeAliasType` 提供相似的用途且具有相似的名稱,他們" -"是不同的,且後者與前者的型別不同。現在還沒有移除 :data:`TypeAlias` 的計畫,但" -"鼓勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" +"是不同的,且後者不是前者的型別。現在還沒有移除 :data:`TypeAlias` 的計畫,但鼓" +"勵使用者們遷移 (migrate) 至 :keyword:`type` 陳述式。" #: ../../library/typing.rst:1051 msgid "Special forms"