Skip to content

Commit 8a4e5d3

Browse files
[po] auto sync
1 parent 82a2310 commit 8a4e5d3

15 files changed

+669
-574
lines changed

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "81.57%", "updated_at": "2025-07-11T15:57:31Z"}
1+
{"translation": "81.61%", "updated_at": "2025-07-11T23:56:55Z"}

glossary.po

Lines changed: 442 additions & 526 deletions
Large diffs are not rendered by default.

howto/logging-cookbook.po

Lines changed: 148 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ msgid ""
1212
msgstr ""
1313
"Project-Id-Version: Python 3.13\n"
1414
"Report-Msgid-Bugs-To: \n"
15-
"POT-Creation-Date: 2025-05-30 14:58+0000\n"
15+
"POT-Creation-Date: 2025-07-11 15:02+0000\n"
1616
"PO-Revision-Date: 2025-05-08 05:09+0000\n"
1717
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2025\n"
1818
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
@@ -7788,11 +7788,132 @@ msgstr ""
77887788
"WARNING:demo: 1/0\n"
77897789
"WARNING:demo:ZeroDivisionError: division by zero"
77907790

7791-
#: ../../howto/logging-cookbook.rst:4072
7791+
#: ../../howto/logging-cookbook.rst:4069
7792+
msgid "How to uniformly handle newlines in logging output"
7793+
msgstr "如何统一地处理日志记录输出中的换行符"
7794+
7795+
#: ../../howto/logging-cookbook.rst:4071
7796+
msgid ""
7797+
"Usually, messages that are logged (say to console or file) consist of a "
7798+
"single line of text. However, sometimes there is a need to handle messages "
7799+
"with multiple lines - whether because a logging format string contains "
7800+
"newlines, or logged data contains newlines. If you want to handle such "
7801+
"messages uniformly, so that each line in the logged message appears "
7802+
"uniformly formatted as if it was logged separately, you can do this using a "
7803+
"handler mixin, as in the following snippet:"
7804+
msgstr ""
7805+
7806+
#: ../../howto/logging-cookbook.rst:4079
7807+
msgid ""
7808+
"# Assume this is in a module mymixins.py\n"
7809+
"import copy\n"
7810+
"\n"
7811+
"class MultilineMixin:\n"
7812+
" def emit(self, record):\n"
7813+
" s = record.getMessage()\n"
7814+
" if '\\n' not in s:\n"
7815+
" super().emit(record)\n"
7816+
" else:\n"
7817+
" lines = s.splitlines()\n"
7818+
" rec = copy.copy(record)\n"
7819+
" rec.args = None\n"
7820+
" for line in lines:\n"
7821+
" rec.msg = line\n"
7822+
" super().emit(rec)"
7823+
msgstr ""
7824+
7825+
#: ../../howto/logging-cookbook.rst:4097
7826+
msgid "You can use the mixin as in the following script:"
7827+
msgstr ""
7828+
7829+
#: ../../howto/logging-cookbook.rst:4099
7830+
msgid ""
7831+
"import logging\n"
7832+
"\n"
7833+
"from mymixins import MultilineMixin\n"
7834+
"\n"
7835+
"logger = logging.getLogger(__name__)\n"
7836+
"\n"
7837+
"class StreamHandler(MultilineMixin, logging.StreamHandler):\n"
7838+
" pass\n"
7839+
"\n"
7840+
"if __name__ == '__main__':\n"
7841+
" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s',\n"
7842+
" handlers = [StreamHandler()])\n"
7843+
" logger.debug('Single line')\n"
7844+
" logger.debug('Multiple lines:\\nfool me once ...')\n"
7845+
" logger.debug('Another single line')\n"
7846+
" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled again')"
7847+
msgstr ""
7848+
7849+
#: ../../howto/logging-cookbook.rst:4118
7850+
msgid "The script, when run, prints something like:"
7851+
msgstr ""
7852+
7853+
#: ../../howto/logging-cookbook.rst:4120
7854+
msgid ""
7855+
"2025-07-02 13:54:47,234 DEBUG Single line\n"
7856+
"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n"
7857+
"2025-07-02 13:54:47,234 DEBUG fool me once ...\n"
7858+
"2025-07-02 13:54:47,234 DEBUG Another single line\n"
7859+
"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n"
7860+
"2025-07-02 13:54:47,234 DEBUG fool me ...\n"
7861+
"2025-07-02 13:54:47,234 DEBUG can't get fooled again"
7862+
msgstr ""
7863+
7864+
#: ../../howto/logging-cookbook.rst:4130
7865+
msgid ""
7866+
"If, on the other hand, you are concerned about `log injection "
7867+
"<https://owasp.org/www-community/attacks/Log_Injection>`_, you can use a "
7868+
"formatter which escapes newlines, as per the following example:"
7869+
msgstr ""
7870+
7871+
#: ../../howto/logging-cookbook.rst:4134
7872+
msgid ""
7873+
"import logging\n"
7874+
"\n"
7875+
"logger = logging.getLogger(__name__)\n"
7876+
"\n"
7877+
"class EscapingFormatter(logging.Formatter):\n"
7878+
" def format(self, record):\n"
7879+
" s = super().format(record)\n"
7880+
" return s.replace('\\n', r'\\n')\n"
7881+
"\n"
7882+
"if __name__ == '__main__':\n"
7883+
" h = logging.StreamHandler()\n"
7884+
" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s'))\n"
7885+
" logging.basicConfig(level=logging.DEBUG, handlers = [h])\n"
7886+
" logger.debug('Single line')\n"
7887+
" logger.debug('Multiple lines:\\nfool me once ...')\n"
7888+
" logger.debug('Another single line')\n"
7889+
" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled again')"
7890+
msgstr ""
7891+
7892+
#: ../../howto/logging-cookbook.rst:4154
7893+
msgid ""
7894+
"You can, of course, use whatever escaping scheme makes the most sense for "
7895+
"you. The script, when run, should produce output like this:"
7896+
msgstr ""
7897+
7898+
#: ../../howto/logging-cookbook.rst:4157
7899+
msgid ""
7900+
"2025-07-09 06:47:33,783 DEBUG Single line\n"
7901+
"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me once ...\n"
7902+
"2025-07-09 06:47:33,783 DEBUG Another single line\n"
7903+
"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get fooled again"
7904+
msgstr ""
7905+
7906+
#: ../../howto/logging-cookbook.rst:4164
7907+
msgid ""
7908+
"Escaping behaviour can't be the stdlib default , as it would break backwards"
7909+
" compatibility."
7910+
msgstr "转义行为不能是标准库默认设置,因为它会破坏向下兼容性。"
7911+
7912+
#: ../../howto/logging-cookbook.rst:4170
77927913
msgid "Patterns to avoid"
77937914
msgstr "理应避免的用法"
77947915

7795-
#: ../../howto/logging-cookbook.rst:4074
7916+
#: ../../howto/logging-cookbook.rst:4172
77967917
msgid ""
77977918
"Although the preceding sections have described ways of doing things you "
77987919
"might need to do or deal with, it is worth mentioning some usage patterns "
@@ -7801,11 +7922,11 @@ msgid ""
78017922
msgstr ""
78027923
"前几节虽介绍了几种方案,描述了可能需要处理的操作,但值得一提的是,有些用法是 *没有好处* 的,大多数情况下应该避免使用。下面几节的顺序不分先后。"
78037924

7804-
#: ../../howto/logging-cookbook.rst:4080
7925+
#: ../../howto/logging-cookbook.rst:4178
78057926
msgid "Opening the same log file multiple times"
78067927
msgstr "多次打开同一个日志文件"
78077928

7808-
#: ../../howto/logging-cookbook.rst:4082
7929+
#: ../../howto/logging-cookbook.rst:4180
78097930
msgid ""
78107931
"On Windows, you will generally not be able to open the same file multiple "
78117932
"times as this will lead to a \"file is in use by another process\" error. "
@@ -7815,33 +7936,33 @@ msgstr ""
78157936
"因会导致 \"文件被其他进程占用 \"错误,所以在 Windows 中一般无法多次打开同一个文件。但在 POSIX "
78167937
"平台中,多次打开同一个文件不会报任何错误。这种操作可能是意外发生的,比如:"
78177938

7818-
#: ../../howto/logging-cookbook.rst:4087
7939+
#: ../../howto/logging-cookbook.rst:4185
78197940
msgid ""
78207941
"Adding a file handler more than once which references the same file (e.g. by"
78217942
" a copy/paste/forget-to-change error)."
78227943
msgstr "多次添加指向同一文件的 handler(比如通过复制/粘贴,或忘记修改)。"
78237944

7824-
#: ../../howto/logging-cookbook.rst:4090
7945+
#: ../../howto/logging-cookbook.rst:4188
78257946
msgid ""
78267947
"Opening two files that look different, as they have different names, but are"
78277948
" the same because one is a symbolic link to the other."
78287949
msgstr "打开两个貌似不同(文件名不一样)的文件,但一个是另一个的符号链接,所以其实是同一个文件。"
78297950

7830-
#: ../../howto/logging-cookbook.rst:4093
7951+
#: ../../howto/logging-cookbook.rst:4191
78317952
msgid ""
78327953
"Forking a process, following which both parent and child have a reference to"
78337954
" the same file. This might be through use of the :mod:`multiprocessing` "
78347955
"module, for example."
78357956
msgstr ""
78367957
"进程 fork,然后父进程和子进程都有对同一文件的引用。 例如,这可能是通过使用 :mod:`multiprocessing` 模块实现的。"
78377958

7838-
#: ../../howto/logging-cookbook.rst:4097
7959+
#: ../../howto/logging-cookbook.rst:4195
78397960
msgid ""
78407961
"Opening a file multiple times might *appear* to work most of the time, but "
78417962
"can lead to a number of problems in practice:"
78427963
msgstr "在大多数情况下,多次打开同一个文件 *貌似* 一切正常,但实际会导致很多问题。"
78437964

7844-
#: ../../howto/logging-cookbook.rst:4100
7965+
#: ../../howto/logging-cookbook.rst:4198
78457966
msgid ""
78467967
"Logging output can be garbled because multiple threads or processes try to "
78477968
"write to the same file. Although logging guards against concurrent use of "
@@ -7852,7 +7973,7 @@ msgstr ""
78527973
"由于多个线程或进程会尝试写入同一个文件,日志输出可能会出现乱码。尽管日志对象可以防止多个线程同时使用同一个 handler "
78537974
"实例,但如果两个不同的线程使用不同的 handler 实例同时写入文件,而这两个 handler 又恰好指向同一个文件,那么就失去了这种防护。"
78547975

7855-
#: ../../howto/logging-cookbook.rst:4106
7976+
#: ../../howto/logging-cookbook.rst:4204
78567977
msgid ""
78577978
"An attempt to delete a file (e.g. during file rotation) silently fails, "
78587979
"because there is another reference pointing to it. This can lead to "
@@ -7865,17 +7986,17 @@ msgstr ""
78657986
"日志条目会出现在意想不到的地方,或者完全丢失。 "
78667987
"或者会有应当移除的文件仍然保持存在,文件还会在已经设置了基于文件大小的轮换的情况下仍然增长到预料之外的大小。"
78677988

7868-
#: ../../howto/logging-cookbook.rst:4113
7989+
#: ../../howto/logging-cookbook.rst:4211
78697990
msgid ""
78707991
"Use the techniques outlined in :ref:`multiple-processes` to circumvent such "
78717992
"issues."
78727993
msgstr "请用 :ref:`multiple-processes` 中介绍的技术来避免上述问题。"
78737994

7874-
#: ../../howto/logging-cookbook.rst:4117
7995+
#: ../../howto/logging-cookbook.rst:4215
78757996
msgid "Using loggers as attributes in a class or passing them as parameters"
78767997
msgstr "将日志对象用作属性或传递参数"
78777998

7878-
#: ../../howto/logging-cookbook.rst:4119
7999+
#: ../../howto/logging-cookbook.rst:4217
78798000
msgid ""
78808001
"While there might be unusual cases where you'll need to do this, in general "
78818002
"there is no point because loggers are singletons. Code can always access a "
@@ -7889,13 +8010,13 @@ msgstr ""
78898010
"用名称访问一个已有的日志对象实例,因此将实例作为参数来传递,或作为属性留存,都是毫无意义的。请注意,在其他语言中,如 Java 和 "
78908011
"C#,日志对象通常是静态类属性。但在 Python 中是没有意义的,因为软件拆分的单位是模块(而不是类)。"
78918012

7892-
#: ../../howto/logging-cookbook.rst:4128
8013+
#: ../../howto/logging-cookbook.rst:4226
78938014
msgid ""
78948015
"Adding handlers other than :class:`~logging.NullHandler` to a logger in a "
78958016
"library"
78968017
msgstr "为库中的日志记录器添加 :class:`~logging.NullHandler` 以外的处理器"
78978018

7898-
#: ../../howto/logging-cookbook.rst:4130
8019+
#: ../../howto/logging-cookbook.rst:4228
78998020
msgid ""
79008021
"Configuring logging by adding handlers, formatters and filters is the "
79018022
"responsibility of the application developer, not the library developer. If "
@@ -7906,11 +8027,11 @@ msgstr ""
79068027
"来配置日志,这是应用程序开发人员的责任,而不是库开发人员该做的。如果正在维护一个库,请确保不要向任何日志对象添加 "
79078028
":class:`~logging.NullHandler` 实例以外的 handler。"
79088029

7909-
#: ../../howto/logging-cookbook.rst:4136
8030+
#: ../../howto/logging-cookbook.rst:4234
79108031
msgid "Creating a lot of loggers"
79118032
msgstr "创建大量的日志对象"
79128033

7913-
#: ../../howto/logging-cookbook.rst:4138
8034+
#: ../../howto/logging-cookbook.rst:4236
79148035
msgid ""
79158036
"Loggers are singletons that are never freed during a script execution, and "
79168037
"so creating lots of loggers will use up memory which can't then be freed. "
@@ -7924,38 +8045,38 @@ msgstr ""
79248045
" :ref:`已有机制 <context-info>` "
79258046
"将上下文信息传给自定义日志对象,并将创建的日志对象限制在应用程序内的指定区域(通常是模块,但偶尔会再精细些)使用。"
79268047

7927-
#: ../../howto/logging-cookbook.rst:4149
8048+
#: ../../howto/logging-cookbook.rst:4247
79288049
msgid "Other resources"
79298050
msgstr "其他资源"
79308051

7931-
#: ../../howto/logging-cookbook.rst:4153
8052+
#: ../../howto/logging-cookbook.rst:4251
79328053
msgid "Module :mod:`logging`"
79338054
msgstr "模块 :mod:`logging`"
79348055

7935-
#: ../../howto/logging-cookbook.rst:4154
8056+
#: ../../howto/logging-cookbook.rst:4252
79368057
msgid "API reference for the logging module."
79378058
msgstr "日志记录模块的 API 参考。"
79388059

7939-
#: ../../howto/logging-cookbook.rst:4156
8060+
#: ../../howto/logging-cookbook.rst:4254
79408061
msgid "Module :mod:`logging.config`"
79418062
msgstr ":mod:`logging.config` 模块"
79428063

7943-
#: ../../howto/logging-cookbook.rst:4157
8064+
#: ../../howto/logging-cookbook.rst:4255
79448065
msgid "Configuration API for the logging module."
79458066
msgstr "日志记录模块的配置 API 。"
79468067

7947-
#: ../../howto/logging-cookbook.rst:4159
8068+
#: ../../howto/logging-cookbook.rst:4257
79488069
msgid "Module :mod:`logging.handlers`"
79498070
msgstr ":mod:`logging.handlers` 模块"
79508071

7951-
#: ../../howto/logging-cookbook.rst:4160
8072+
#: ../../howto/logging-cookbook.rst:4258
79528073
msgid "Useful handlers included with the logging module."
79538074
msgstr "日志记录模块附带的有用处理器。"
79548075

7955-
#: ../../howto/logging-cookbook.rst:4162
8076+
#: ../../howto/logging-cookbook.rst:4260
79568077
msgid ":ref:`Basic Tutorial <logging-basic-tutorial>`"
79578078
msgstr ":ref:`基础教程 <logging-basic-tutorial>`"
79588079

7959-
#: ../../howto/logging-cookbook.rst:4164
8080+
#: ../../howto/logging-cookbook.rst:4262
79608081
msgid ":ref:`Advanced Tutorial <logging-advanced-tutorial>`"
79618082
msgstr ":ref:`进阶教程 <logging-advanced-tutorial>`"

library/codecs.po

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ msgid ""
334334
":term:`generator`. The *errors* argument (as well as any other keyword "
335335
"argument) is passed through to the incremental encoder."
336336
msgstr ""
337+
"使用增量式编码器通过迭代来编码由 *iterator* 提供的输入。 *iterator* 必须产生 :class:`str` 对象。 此函数属于 "
338+
":term:`generator`。 *errors* 参数(以及任何其他关键字参数)会被传递给增量式编码器。"
337339

338340
#: ../../library/codecs.rst:246
339341
msgid ""
@@ -350,6 +352,8 @@ msgid ""
350352
" :term:`generator`. The *errors* argument (as well as any other keyword "
351353
"argument) is passed through to the incremental decoder."
352354
msgstr ""
355+
"使用增量式解码器通过迭代来解码由 *iterator* 提供的输入。 *iterator* 必须产生 :class:`bytes` 对象。 此函数属于 "
356+
":term:`generator`。 *errors* 参数(以及任何其他关键字参数)会被传递给增量式解码器。"
353357

354358
#: ../../library/codecs.rst:258
355359
msgid ""
@@ -367,16 +371,20 @@ msgid ""
367371
":ref:`buffer-compatible object <bufferobjects>` or :class:`str` (encoded to "
368372
"UTF-8 before processing), and their length in bytes."
369373
msgstr ""
374+
"返回一个包含 *buffer* 中原始字节数据的 :class:`tuple`,一个 :ref:`缓冲区兼容对象 <bufferobjects>` 或 "
375+
":class:`str` (在处理前已编码为 UTF-8),及其字节长度。"
370376

371377
#: ../../library/codecs.rst:270
372378
msgid "The *errors* argument is ignored."
373-
msgstr ""
379+
msgstr "*errors* 参数会被忽略。"
374380

375381
#: ../../library/codecs.rst:272
376382
msgid ""
377383
">>> codecs.readbuffer_encode(b\"Zito\")\n"
378384
"(b'Zito', 4)"
379385
msgstr ""
386+
">>> codecs.readbuffer_encode(b\"Zito\")\n"
387+
"(b'Zito', 4)"
380388

381389
#: ../../library/codecs.rst:278
382390
msgid ""
@@ -2631,7 +2639,7 @@ msgstr "undefined"
26312639

26322640
#: ../../library/codecs.rst:1387
26332641
msgid "This Codec should only be used for testing purposes."
2634-
msgstr ""
2642+
msgstr "该编解码器应当仅用于测试目的。"
26352643

26362644
#: ../../library/codecs.rst:1391
26372645
msgid ""
@@ -2825,7 +2833,7 @@ msgstr "恢复 ``rot13`` 别名。"
28252833

28262834
#: ../../library/codecs.rst:1495
28272835
msgid ":mod:`encodings` --- Encodings package"
2828-
msgstr ""
2836+
msgstr ":mod:`encodings` --- 编码格式包"
28292837

28302838
#: ../../library/codecs.rst:1500
28312839
msgid "This module implements the following functions:"

library/pyexpat.po

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# Translators:
77
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
8+
# Freesand Leo <yuqinju@163.com>, 2025
89
#
910
#, fuzzy
1011
msgid ""
@@ -13,7 +14,7 @@ msgstr ""
1314
"Report-Msgid-Bugs-To: \n"
1415
"POT-Creation-Date: 2025-07-11 15:02+0000\n"
1516
"PO-Revision-Date: 2025-05-08 05:10+0000\n"
16-
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n"
17+
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2025\n"
1718
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
1819
"MIME-Version: 1.0\n"
1920
"Content-Type: text/plain; charset=UTF-8\n"
@@ -29,7 +30,7 @@ msgstr ":mod:`!xml.parsers.expat` --- 使用 Expat 进行快速 XML 解析"
2930
msgid ""
3031
"If you need to parse untrusted or unauthenticated data, see :ref:`xml-"
3132
"security`."
32-
msgstr ""
33+
msgstr "如果你需要解析不受信任或未经身份验证的数据,请参阅 :ref:`xml-security`。"
3334

3435
#: ../../library/pyexpat.rst:27
3536
msgid ""

0 commit comments

Comments
 (0)