From 6d77e6c7475916c908208ec7c5b980f6f2d5531e Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sat, 9 Dec 2023 14:21:44 +0800 Subject: [PATCH 1/2] feat: translate part of library/json.po --- library/json.po | 59 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/library/json.po b/library/json.po index f7702f267a..399debf3a8 100644 --- a/library/json.po +++ b/library/json.po @@ -150,7 +150,7 @@ msgid "" "reference check for container types will be skipped and a circular reference " "will result in a :exc:`RecursionError` (or worse)." msgstr "" -"如果 *chech_circular* 設為 false(預設是 ``True``),則針對不同容器型別的循環" +"如果 *check_circular* 設為 false(預設是 ``True``),則針對不同容器型別的循環" "參照 (circular reference) 的檢查將會被跳過,若有循環參照則最後將引發 :exc:" "`RecursionError` (或者更糟的錯誤)。" @@ -162,6 +162,11 @@ msgid "" "*allow_nan* is true, their JavaScript equivalents (``NaN``, ``Infinity``, ``-" "Infinity``) will be used." msgstr "" +"如果 *allow_nan* 設為 False(預設值為 ``True``),那麼序列化 (serialize):" +"class:`float` 的特殊值 (``nan``, ``inf``, ``-inf``) 會觸發 :exc:" +"`ValueError`,這麼設定是為了遵守較嚴格的 JSON 規範。如果設為 True,則序列化這" +"些極值不會出錯,而是會被自動代換成 JavaScript 上等價的值 (``NaN``, " +"``Infinity``, ``-Infinity``)" #: ../../library/json.rst:168 ../../library/json.rst:452 msgid "" @@ -172,10 +177,12 @@ msgid "" "indent indents that many spaces per level. If *indent* is a string (such as " "``\"\\t\"``), that string is used to indent each level." msgstr "" +"如果 *indent* 是一個非負整數或字串,那麼 JSON 序列及其所含元素,會以pretty-" +"print 的方式顯示,並會有幾個。" #: ../../library/json.rst:175 ../../library/json.rst:459 msgid "Allow strings for *indent* in addition to integers." -msgstr "" +msgstr "允許字串作為 *indent* 的值,而不只是允許整數。" #: ../../library/json.rst:178 ../../library/json.rst:462 msgid "" @@ -184,10 +191,14 @@ msgid "" "': ')`` otherwise. To get the most compact JSON representation, you should " "specify ``(',', ':')`` to eliminate whitespace." msgstr "" +"*separator* 是分隔符號,``( 項跟項 (item) 之間的分隔符號, 鍵值 (key) 之間的分" +"隔符號)`` 的 tuple。 如果 *indent* 是 ``None``,則預設值為 ``(', ', ': ')``," +"否則預設值為 ``(',', ': ')``。如果希望 JSON 更省空間,建議指定為 ``(',', " +"':')``,這樣可以消除空白。" #: ../../library/json.rst:183 ../../library/json.rst:467 msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``." -msgstr "" +msgstr "如果 *indent* 不是 ``None``,則用 ``(',', ': ')`` 當預設值" #: ../../library/json.rst:186 ../../library/json.rst:470 msgid "" @@ -196,12 +207,18 @@ msgid "" "version of the object or raise a :exc:`TypeError`. If not specified, :exc:" "`TypeError` is raised." msgstr "" +"*default* 必須一個函式,如果你有設定它的話,遇到無法 JSON 序列化的物件時會呼" +"叫你 *default* 設定的函式。該函式只能有兩種狀況:要不就回傳一個可以被 JSON 序" +"列化的物件,要不就拋出 :exc:`TypeError`。如果 *default* 沒有指定值,則只要遇" +"到無法 JSON 序列化的物件就會丟出 :exc:`TypeError`。" #: ../../library/json.rst:191 msgid "" "If *sort_keys* is true (default: ``False``), then the output of dictionaries " "will be sorted by key." msgstr "" +"如果 *sort_keys* 設為 True(預設值為 False),那麼字典的輸出會按照 " +"*sort_keys* 排序。" #: ../../library/json.rst:194 msgid "" @@ -209,11 +226,15 @@ msgid "" "meth:`~JSONEncoder.default` method to serialize additional types), specify " "it with the *cls* kwarg; otherwise :class:`JSONEncoder` is used." msgstr "" +"如果要使用自訂的 :class:`JSONEncoder` 子類別去改寫 (overrides)原來預設的 " +"meth:`~JSONEncoder.default`,請標明 *cls* 以序列化更多不同的型別。如果沒有標" +"的話,就會使用 :class:`JSONEncoder` 來序列化。" #: ../../library/json.rst:198 ../../library/json.rst:277 msgid "" "All optional parameters are now :ref:`keyword-only `." msgstr "" +"所有非必要參數現在都是 :ref:`keyword-only ` 了。" #: ../../library/json.rst:203 msgid "" @@ -221,6 +242,9 @@ msgid "" "trying to serialize multiple objects with repeated calls to :func:`dump` " "using the same *fp* will result in an invalid JSON file." msgstr "" +"JSON 和 :mod:`pickle` 跟 :mod:`marshal` 不同,JSON不是一個框架協定,所以如果" +"你試著用同一個 *fp* 來重複呼叫 :func:`dump` 來序列化多個物件,會導致無效的" +"JSON檔案。" #: ../../library/json.rst:212 msgid "" @@ -228,6 +252,8 @@ msgid "" "table `. The arguments have the same meaning as in :func:" "`dump`." msgstr "" +"用這個 :ref:`conversion table ` 來把 *obj* 序列化成JSON 格" +"式的 :class:`str`。 裡面所有引數和 :func: `dump` 裡的意義相同。" #: ../../library/json.rst:218 msgid "" @@ -237,6 +263,10 @@ msgid "" "JSON and then back into a dictionary, the dictionary may not equal the " "original one. That is, ``loads(dumps(x)) != x`` if x has non-string keys." msgstr "" +"在 JSON 的 鍵值/值對 (key/value pairs) 中,鍵值一定是 :class:`str`。當一個字" +"典物件 (dictionary) 被轉換成 JSON 時,字典的所有鍵都會被強制轉換成字串。因" +"此,如果一個字典被轉換成 JSON 然後再轉回字典,該字典可能不等於原來的字典。也" +"就是說,如果字典 x 有些鍵值不是字串,那麼 ``loads(dumps(x)) != x``。" #: ../../library/json.rst:227 msgid "" @@ -244,6 +274,9 @@ msgid "" "`binary file` containing a JSON document) to a Python object using this :ref:" "`conversion table `." msgstr "" +"將 fp(一個支持.read() 的 :term:`text file` 或包含 JSON 的:term:`binary " +"file` 反序列化 (deserialize) 為 Python 物件,轉換規則使用`conversion table " +"`。" #: ../../library/json.rst:231 msgid "" @@ -253,6 +286,10 @@ msgid "" "be used to implement custom decoders (e.g. `JSON-RPC `_ class hinting)." msgstr "" +"*object_hook* 是一個非必要性的函式,用來解碼物件 object_literal。如果沒有值" +"時,物件會被解碼成 :class:`dict`。如果有值,會 *object_hook* 的回傳值會被用來" +"取代原來的 :class:`dict`。因此,改寫 *object_hook* 就能自訂的解碼器(例如" +"`JSON-RPC `_ 類別提示)。" #: ../../library/json.rst:237 msgid "" @@ -262,6 +299,10 @@ msgid "" "`dict`. This feature can be used to implement custom decoders. If " "*object_hook* is also defined, the *object_pairs_hook* takes priority." msgstr "" +"*object_pairs_hook* 是一個非必要函式,會在解碼物件成有序值對陣列(暫譯," +"ordered list of pairs),如果有值,JSON 會使用 *object_pairs_hook* 的回傳值而" +"非原本的 :class:`dict`。此功能可以用來自訂解碼器。如果 *object_hook*也有值," +"*object_pairs_hook* 的值會優先採用。" #: ../../library/json.rst:243 ../../library/json.rst:348 msgid "Added support for *object_pairs_hook*." @@ -274,6 +315,9 @@ msgid "" "This can be used to use another datatype or parser for JSON floats (e.g. :" "class:`decimal.Decimal`)." msgstr "" +"如果 *parse_float* 有值,含浮點數的 JSON 文字會被解析。預設是" +"``float(num_str)``,但可以設成別的資料型別或 JSON 浮點數文字解析器,例如:" +"class:`decimal.Decimal`。" #: ../../library/json.rst:251 ../../library/json.rst:356 msgid "" @@ -282,6 +326,8 @@ msgid "" "can be used to use another datatype or parser for JSON integers (e.g. :class:" "`float`)." msgstr "" +"如果 *parse_int* 有值,含整數的 JSON 文字會被解析。預設是``int(num_str)``,但" +"可以設成別的資料型別或 JSON 整數文字解析器,例如:class:`float`。" #: ../../library/json.rst:256 msgid "" @@ -289,6 +335,8 @@ msgid "" "integer string via the interpreter's :ref:`integer string conversion length " "limitation ` to help avoid denial of service attacks." msgstr "" +":func:`int` 預設的 *parse_int* 現在有字數上限了,上限是直譯器的:ref:`integer " +"string conversion length limitation `" #: ../../library/json.rst:262 ../../library/json.rst:361 msgid "" @@ -296,10 +344,13 @@ msgid "" "strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to " "raise an exception if invalid JSON numbers are encountered." msgstr "" +"如果 *parse_constant* 有值,那麼遇到 ``'-Infinity'``、``'Infinity'``或" +"``'NaN'``等字串時,會被呼叫用以解析它們。 *parse_constant* 也可是設定成在遇在" +"遇無效的 JSON 數字時出錯。" #: ../../library/json.rst:267 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." -msgstr "" +msgstr "*parse_constant* 不再在遇到 'null'、 'true'、 'false' 呼叫了。" #: ../../library/json.rst:270 msgid "" From 9b0a45781626b561676e73b37f9d299ba2d94149 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sat, 9 Dec 2023 14:48:22 +0800 Subject: [PATCH 2/2] fix: refine library/json.po --- library/json.po | 105 ++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/library/json.po b/library/json.po index 399debf3a8..1086a4c8c9 100644 --- a/library/json.po +++ b/library/json.po @@ -162,11 +162,10 @@ msgid "" "*allow_nan* is true, their JavaScript equivalents (``NaN``, ``Infinity``, ``-" "Infinity``) will be used." msgstr "" -"如果 *allow_nan* 設為 False(預設值為 ``True``),那麼序列化 (serialize):" -"class:`float` 的特殊值 (``nan``, ``inf``, ``-inf``) 會觸發 :exc:" -"`ValueError`,這麼設定是為了遵守較嚴格的 JSON 規範。如果設為 True,則序列化這" -"些極值不會出錯,而是會被自動代換成 JavaScript 上等價的值 (``NaN``, " -"``Infinity``, ``-Infinity``)" +"如果 *allow_nan* 為 false(預設值:``True``\\ ),則序列化超出嚴格 JSON 規範" +"之範圍的 :class:`float` 值 (``nan``, ``inf``, ``-inf``) 會引發 :exc:" +"`ValueError`。如果 *allow_nan* 為 true,則將使用它們的 JavaScript 等效項 " +"(``NaN``, ``Infinity``, ``-Infinity``)。" #: ../../library/json.rst:168 ../../library/json.rst:452 msgid "" @@ -177,12 +176,14 @@ msgid "" "indent indents that many spaces per level. If *indent* is a string (such as " "``\"\\t\"``), that string is used to indent each level." msgstr "" -"如果 *indent* 是一個非負整數或字串,那麼 JSON 序列及其所含元素,會以pretty-" -"print 的方式顯示,並會有幾個。" +"如果 *indent* 是非負整數或字串,則 JSON 陣列元素和物件成員將使用該縮排等級進" +"行漂亮列印。縮排等級 0、負數或 ``\"\"`` 只會插入換行符號。``None``\\ (預設" +"值)選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如果 " +"*indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" #: ../../library/json.rst:175 ../../library/json.rst:459 msgid "Allow strings for *indent* in addition to integers." -msgstr "允許字串作為 *indent* 的值,而不只是允許整數。" +msgstr "除了整數之外,還允許使用字串進行 *indent*。" #: ../../library/json.rst:178 ../../library/json.rst:462 msgid "" @@ -191,10 +192,9 @@ msgid "" "': ')`` otherwise. To get the most compact JSON representation, you should " "specify ``(',', ':')`` to eliminate whitespace." msgstr "" -"*separator* 是分隔符號,``( 項跟項 (item) 之間的分隔符號, 鍵值 (key) 之間的分" -"隔符號)`` 的 tuple。 如果 *indent* 是 ``None``,則預設值為 ``(', ', ': ')``," -"否則預設值為 ``(',', ': ')``。如果希望 JSON 更省空間,建議指定為 ``(',', " -"':')``,這樣可以消除空白。" +"如果有指定,*separators* 應該是一個 ``(item_separator, key_separator)`` 元" +"組。如果 *indent* 為 ``None`` 則預設為 ``(', ', ': ')``,否則預設為 ``(',', " +"': ')``。要獲得最緊湊的 JSON 表示形式,你應該指定 ``(',', ':')`` 來消除空格。" #: ../../library/json.rst:183 ../../library/json.rst:467 msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``." @@ -207,18 +207,16 @@ msgid "" "version of the object or raise a :exc:`TypeError`. If not specified, :exc:" "`TypeError` is raised." msgstr "" -"*default* 必須一個函式,如果你有設定它的話,遇到無法 JSON 序列化的物件時會呼" -"叫你 *default* 設定的函式。該函式只能有兩種狀況:要不就回傳一個可以被 JSON 序" -"列化的物件,要不就拋出 :exc:`TypeError`。如果 *default* 沒有指定值,則只要遇" -"到無法 JSON 序列化的物件就會丟出 :exc:`TypeError`。" +"如果有指定,*default* 應該是一個為無法序列化的物件呼叫的函式。它應該傳回物件" +"的 JSON 可編碼版本或引發 :exc:`TypeError`。如果未指定,則會引發 :exc:" +"`TypeError`。" #: ../../library/json.rst:191 msgid "" "If *sort_keys* is true (default: ``False``), then the output of dictionaries " "will be sorted by key." msgstr "" -"如果 *sort_keys* 設為 True(預設值為 False),那麼字典的輸出會按照 " -"*sort_keys* 排序。" +"如果 *sort_keys* 為 true(預設值:``False``),則字典的輸出將按鍵排序。" #: ../../library/json.rst:194 msgid "" @@ -226,15 +224,15 @@ msgid "" "meth:`~JSONEncoder.default` method to serialize additional types), specify " "it with the *cls* kwarg; otherwise :class:`JSONEncoder` is used." msgstr "" -"如果要使用自訂的 :class:`JSONEncoder` 子類別去改寫 (overrides)原來預設的 " -"meth:`~JSONEncoder.default`,請標明 *cls* 以序列化更多不同的型別。如果沒有標" -"的話,就會使用 :class:`JSONEncoder` 來序列化。" +"若要使用自訂 :class:`JSONEncoder` 子類別(例如覆寫 :meth:`~JSONEncoder." +"default` 方法來序列化其他型別的子類別),請使用 *cls* kwarg 指定它;否則使" +"用 :class:`JSONEncoder`。" #: ../../library/json.rst:198 ../../library/json.rst:277 msgid "" "All optional parameters are now :ref:`keyword-only `." msgstr "" -"所有非必要參數現在都是 :ref:`keyword-only ` 了。" +"所有可選參數現在都是\\ :ref:`僅限關鍵字 `\\ 了。" #: ../../library/json.rst:203 msgid "" @@ -242,9 +240,8 @@ msgid "" "trying to serialize multiple objects with repeated calls to :func:`dump` " "using the same *fp* will result in an invalid JSON file." msgstr "" -"JSON 和 :mod:`pickle` 跟 :mod:`marshal` 不同,JSON不是一個框架協定,所以如果" -"你試著用同一個 *fp* 來重複呼叫 :func:`dump` 來序列化多個物件,會導致無效的" -"JSON檔案。" +"與 :mod:`pickle` 和 :mod:`marshal` 不同,JSON 不是框架協定,因此嘗試使用相同" +"的 *fp* 重複呼叫 :func:`dump` 來序列化多個物件將導致無效的 JSON 檔案。" #: ../../library/json.rst:212 msgid "" @@ -252,8 +249,8 @@ msgid "" "table `. The arguments have the same meaning as in :func:" "`dump`." msgstr "" -"用這個 :ref:`conversion table ` 來把 *obj* 序列化成JSON 格" -"式的 :class:`str`。 裡面所有引數和 :func: `dump` 裡的意義相同。" +"使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格式化 :" +"class:`str`。這些引數與 :func:`dump` 中的意義相同。" #: ../../library/json.rst:218 msgid "" @@ -263,10 +260,10 @@ msgid "" "JSON and then back into a dictionary, the dictionary may not equal the " "original one. That is, ``loads(dumps(x)) != x`` if x has non-string keys." msgstr "" -"在 JSON 的 鍵值/值對 (key/value pairs) 中,鍵值一定是 :class:`str`。當一個字" -"典物件 (dictionary) 被轉換成 JSON 時,字典的所有鍵都會被強制轉換成字串。因" -"此,如果一個字典被轉換成 JSON 然後再轉回字典,該字典可能不等於原來的字典。也" -"就是說,如果字典 x 有些鍵值不是字串,那麼 ``loads(dumps(x)) != x``。" +"JSON 鍵/值對中的鍵始終為 :class:`str` 型別。當字典轉換為 JSON 時,字典的所有" +"鍵都被強制轉換為字串。因此,如果將字典轉換為 JSON,然後再轉換回字典,則該字典" +"可能不等於原始字典。也就是說,如果 x 有非字串鍵,則 ``loads(dumps(x)) != " +"x``。" #: ../../library/json.rst:227 msgid "" @@ -274,9 +271,9 @@ msgid "" "`binary file` containing a JSON document) to a Python object using this :ref:" "`conversion table `." msgstr "" -"將 fp(一個支持.read() 的 :term:`text file` 或包含 JSON 的:term:`binary " -"file` 反序列化 (deserialize) 為 Python 物件,轉換規則使用`conversion table " -"`。" +"使用此\\ :ref:`轉換表 `\\ 來將 *fp*\\ (一個支援 ``." +"read()``、包含 JSON 文件的\\ :term:`文字檔案 `\\ 或\\ :term:`二進" +"位檔案 `\\ )反序列化為 Python 物件。" #: ../../library/json.rst:231 msgid "" @@ -286,10 +283,10 @@ msgid "" "be used to implement custom decoders (e.g. `JSON-RPC `_ class hinting)." msgstr "" -"*object_hook* 是一個非必要性的函式,用來解碼物件 object_literal。如果沒有值" -"時,物件會被解碼成 :class:`dict`。如果有值,會 *object_hook* 的回傳值會被用來" -"取代原來的 :class:`dict`。因此,改寫 *object_hook* 就能自訂的解碼器(例如" -"`JSON-RPC `_ 類別提示)。" +"*object_hook* 是一個可選函式,將使用任何物件文本解碼的結果(一個 :class:" +"`dict`\\ )來呼叫它。將使用 *object_hook* 的回傳值而不是 :class:`dict`。此功" +"能可用於實作自訂解碼器(例如 `JSON-RPC `_ 類別提" +"示)。" #: ../../library/json.rst:237 msgid "" @@ -299,10 +296,10 @@ msgid "" "`dict`. This feature can be used to implement custom decoders. If " "*object_hook* is also defined, the *object_pairs_hook* takes priority." msgstr "" -"*object_pairs_hook* 是一個非必要函式,會在解碼物件成有序值對陣列(暫譯," -"ordered list of pairs),如果有值,JSON 會使用 *object_pairs_hook* 的回傳值而" -"非原本的 :class:`dict`。此功能可以用來自訂解碼器。如果 *object_hook*也有值," -"*object_pairs_hook* 的值會優先採用。" +"*object_pairs_hook* 是一個可選函式,將使用使用有序對列表解碼的任何物件文本的" +"結果來呼叫該函式。將使用 *object_pairs_hook* 的回傳值而不是 :class:`dict`。此" +"功能可用於實作自訂解碼器。如果也定義了 *object_hook*,則 *object_pairs_hook* " +"優先。" #: ../../library/json.rst:243 ../../library/json.rst:348 msgid "Added support for *object_pairs_hook*." @@ -315,9 +312,9 @@ msgid "" "This can be used to use another datatype or parser for JSON floats (e.g. :" "class:`decimal.Decimal`)." msgstr "" -"如果 *parse_float* 有值,含浮點數的 JSON 文字會被解析。預設是" -"``float(num_str)``,但可以設成別的資料型別或 JSON 浮點數文字解析器,例如:" -"class:`decimal.Decimal`。" +"如有指定 *parse_float*,將使用要解碼的每個 JSON 浮點數字串進行呼叫。預設情況" +"下,這相當於 ``float(num_str)``。這可用於將另一種資料型別或剖析器用於 JSON 浮" +"點(例如 :class:`decimal.Decimal`\\ )。" #: ../../library/json.rst:251 ../../library/json.rst:356 msgid "" @@ -326,8 +323,9 @@ msgid "" "can be used to use another datatype or parser for JSON integers (e.g. :class:" "`float`)." msgstr "" -"如果 *parse_int* 有值,含整數的 JSON 文字會被解析。預設是``int(num_str)``,但" -"可以設成別的資料型別或 JSON 整數文字解析器,例如:class:`float`。" +"如有指定 *parse_int*,將使用要解碼的每個 JSON 整數字串進行呼叫。預設情況下," +"這相當於 ``int(num_str)``。這可用於對 JSON 整數使用另一種資料型別或剖析器(例" +"如 :class:`float`\\ )。" #: ../../library/json.rst:256 msgid "" @@ -335,8 +333,9 @@ msgid "" "integer string via the interpreter's :ref:`integer string conversion length " "limitation ` to help avoid denial of service attacks." msgstr "" -":func:`int` 預設的 *parse_int* 現在有字數上限了,上限是直譯器的:ref:`integer " -"string conversion length limitation `" +":func:`int` 預設的 *parse_int* 現在對於整數字串有長度上限,上限是直譯器的\\ :" +"ref:`整數字串轉換長度限制 `,這能防止阻斷服務攻擊 " +"(denial of service attacks)。" #: ../../library/json.rst:262 ../../library/json.rst:361 msgid "" @@ -344,13 +343,13 @@ msgid "" "strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to " "raise an exception if invalid JSON numbers are encountered." msgstr "" -"如果 *parse_constant* 有值,那麼遇到 ``'-Infinity'``、``'Infinity'``或" -"``'NaN'``等字串時,會被呼叫用以解析它們。 *parse_constant* 也可是設定成在遇在" -"遇無效的 JSON 數字時出錯。" +"如果 *parse_constant* 有值,那麼以 ``'-Infinity'``、``'Infinity'`` 或 " +"``'NaN'`` 字串其中之一來呼叫。這也可用於在遇到無效的 JSON 數字時引發一個例" +"外。" #: ../../library/json.rst:267 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." -msgstr "*parse_constant* 不再在遇到 'null'、 'true'、 'false' 呼叫了。" +msgstr "*parse_constant* 不再以 'null'、 'true'、 'false' 呼叫了。" #: ../../library/json.rst:270 msgid ""