@@ -189,12 +189,14 @@ msgid ""
189189"platforms use UTF-8 locale by default. This causes bugs because the locale "
190190"encoding is not UTF-8 for most Windows users. For example::"
191191msgstr ""
192+ "但是,很多开发者在打开以 UTF-8 编码的文本文件 (例如 JSON, TOML, Markdown 等等...) 时会忘记指定编码格式,因为大多数 "
193+ "Unix 平台默认使用 UTF-8 语言区域。 这会导致各种错误因为大多数 Windows 用户的语言区域编码格式并不是 UTF-8。 例如::"
192194
193195#: ../../library/io.rst:126
194196msgid ""
195197"Additionally, while there is no concrete plan as of yet, Python may change "
196198"the default text file encoding to UTF-8 in the future."
197- msgstr ""
199+ msgstr "此外,虽然暂时还没有确定的计划,但 Python 可能会在未来将默认的文本文件编码格式改为 UTF-8。 "
198200
199201#: ../../library/io.rst:129
200202msgid ""
@@ -203,21 +205,25 @@ msgid ""
203205"``encoding=\" utf-8\" ``. To use the current locale encoding, "
204206"``encoding=\" locale\" `` is supported in Python 3.10."
205207msgstr ""
208+ "为此,强烈建议你在打开文本文件时显式地指定编码格式。 如果你想要使用 UTF-8,请传入 ``encoding=\" utf-8\" ``。 "
209+ "要使用当前语言区域的编码格式,``encoding=\" locale\" `` 已在 Python 3.10 中被支持。"
206210
207211#: ../../library/io.rst:134
208212msgid ""
209213"When you need to run existing code on Windows that attempts to opens UTF-8 "
210214"files using the default locale encoding, you can enable the UTF-8 mode. See "
211215":ref:`UTF-8 mode on Windows <win-utf8-mode>`."
212216msgstr ""
217+ "当你需要在 Windows 上运行尝试使用默认语言区域的编码格式打开使用 UTF-8 的文件的现有代码时,你可以启动 UTF-8 模式。 参见 "
218+ ":ref:`Windows 上的 UTF-8 模式 <win-utf8-mode>`。"
213219
214220#: ../../library/io.rst:141
215221msgid "Opt-in EncodingWarning"
216- msgstr ""
222+ msgstr "选择性的 EncodingWarning "
217223
218224#: ../../library/io.rst:143
219225msgid "See :pep:`597` for more details."
220- msgstr ""
226+ msgstr "请参阅 :pep:`597` 了解详情。 "
221227
222228#: ../../library/io.rst:146
223229msgid ""
@@ -226,6 +232,9 @@ msgid ""
226232":envvar:`PYTHONWARNDEFAULTENCODING` environment variable, which will emit an"
227233" :exc:`EncodingWarning` when the default encoding is used."
228234msgstr ""
235+ "要找出哪里使用了默认语言区域的编码格式,你可以启用 ``-X warn_default_encoding`` 命令行选项或设置 "
236+ ":envvar:`PYTHONWARNDEFAULTENCODING` 环境变量,这将在使用默认编码格式时发出 "
237+ ":exc:`EncodingWarning`。"
229238
230239#: ../../library/io.rst:151
231240msgid ""
@@ -235,6 +244,10 @@ msgid ""
235244":exc:`EncodingWarning` if they don't pass an ``encoding``. However, please "
236245"consider using UTF-8 by default (i.e. ``encoding=\" utf-8\" ``) for new APIs."
237246msgstr ""
247+ "如果你提供了使用 :func:`open` 或 :class:`TextIOWrapper` 的 API 并将 ``encoding=None`` "
248+ "作为形参传入,你可以使用 :func:`text_encoding` 以便 API 的调用方在没有传入 ``encoding`` 的时候将发出 "
249+ ":exc:`EncodingWarning`。 但是,对于新的 API 请考虑默认就使用 UTF-8 (即 "
250+ "``encoding=\" utf-8\" ``)。"
238251
239252#: ../../library/io.rst:160
240253msgid "High-level Module Interface"
@@ -295,29 +308,35 @@ msgid ""
295308"This is a helper function for callables that use :func:`open` or "
296309":class:`TextIOWrapper` and have an ``encoding=None`` parameter."
297310msgstr ""
311+ "这是一个针对使用 :func:`open` 或 :class:`TextIOWrapper` 的可调用对象的辅助函数并且具有 "
312+ "``encoding=None`` 形参。"
298313
299314#: ../../library/io.rst:201
300315msgid ""
301316"This function returns *encoding* if it is not ``None`` and ``\" locale\" `` if"
302317" *encoding* is ``None``."
303318msgstr ""
319+ "此函数会返回 *encoding*,如果它不为 ``None`` 的话,或是 ``\" locale\" `` ,如果 *encoding* 为 "
320+ "``None`` 的话。"
304321
305322#: ../../library/io.rst:204
306323msgid ""
307324"This function emits an :class:`EncodingWarning` if "
308325":data:`sys.flags.warn_default_encoding <sys.flags>` is true and *encoding* "
309326"is None. *stacklevel* specifies where the warning is emitted. For example::"
310327msgstr ""
328+ "如果 :data:`sys.flags.warn_default_encoding <sys.flags>` 为真值并且 *encoding* 为 "
329+ "None 则此函数会发出 :class:`EncodingWarning`。 *stacklevel* 指定在哪里发出警告。 例如::"
311330
312331#: ../../library/io.rst:214
313332msgid ""
314333"In this example, an :class:`EncodingWarning` is emitted for the caller of "
315334"``read_text()``."
316- msgstr ""
335+ msgstr "在这个例子中,将为 ``read_text()`` 的调用方发出 :class:`EncodingWarning`。 "
317336
318337#: ../../library/io.rst:217
319338msgid "See :ref:`io-text-encoding` for more information."
320- msgstr ""
339+ msgstr "请参阅 :ref:`io-text-encoding` 了解更多信息。 "
321340
322341#: ../../library/io.rst:224
323342msgid ""
@@ -1471,6 +1490,10 @@ msgid ""
14711490"specify the current locale's encoding explicitly. See :ref:`io-text-"
14721491"encoding` for more information."
14731492msgstr ""
1493+ "*encoding* 给出流的解码和编码将会使用的编码格式的名称。 它默认为 "
1494+ ":func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>`。 "
1495+ "``encoding=\" locale\" `` 可被用来地指定当前语言区域的编码格式。 请参阅 :ref:`io-text-encoding` "
1496+ "了解更多信息。"
14741497
14751498#: ../../library/io.rst:954
14761499msgid ""
@@ -1562,7 +1585,7 @@ msgstr ""
15621585#: ../../library/io.rst:1004
15631586msgid ""
15641587"The *encoding* argument now supports the ``\" locale\" `` dummy encoding name."
1565- msgstr ""
1588+ msgstr "*encoding* 参数现在支持 `` \" locale \" `` 作为编码格式名称。 "
15661589
15671590#: ../../library/io.rst:1007
15681591msgid ""
0 commit comments