Skip to content

Commit e59fc65

Browse files
[po] auto sync
1 parent e57783b commit e59fc65

File tree

3 files changed

+34751
-19326
lines changed

3 files changed

+34751
-19326
lines changed

.stat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation": "81.07%", "updated_at": "2025-07-12T04:21:41Z"}
1+
{"translation": "97.18%", "updated_at": "2025-07-12T06:16:15Z"}

howto/logging-cookbook.po

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7835,6 +7835,9 @@ msgid ""
78357835
"uniformly formatted as if it was logged separately, you can do this using a "
78367836
"handler mixin, as in the following snippet:"
78377837
msgstr ""
7838+
"通常,被记录的消息(输出到控制台或文件)是由单行文本组成的。 不过,在某些时候也会需要处理具有多行的消息 —— "
7839+
"不论是因为日志格式字符串包含换行符,还是因为被记录的数据包含换行符。 "
7840+
"如果你想以统一的方式处理此类消息,使得被记录的消息中的每一行格式看起来保持一致就像它是被单独记录的,你可以使用处理器混入类做到这一点,如下面的代码片段所示:"
78387841

78397842
#: ../../howto/logging-cookbook.rst:4092
78407843
msgid ""
@@ -7854,10 +7857,25 @@ msgid ""
78547857
" rec.msg = line\n"
78557858
" super().emit(rec)"
78567859
msgstr ""
7860+
"# 假定这是在一个模块的 mymixins.py 中\n"
7861+
"import copy\n"
7862+
"\n"
7863+
"class MultilineMixin:\n"
7864+
" def emit(self, record):\n"
7865+
" s = record.getMessage()\n"
7866+
" if '\\n' not in s:\n"
7867+
" super().emit(record)\n"
7868+
" else:\n"
7869+
" lines = s.splitlines()\n"
7870+
" rec = copy.copy(record)\n"
7871+
" rec.args = None\n"
7872+
" for line in lines:\n"
7873+
" rec.msg = line\n"
7874+
" super().emit(rec)"
78577875

78587876
#: ../../howto/logging-cookbook.rst:4110
78597877
msgid "You can use the mixin as in the following script:"
7860-
msgstr ""
7878+
msgstr "你可以像下面的脚本一样使用该混入类:"
78617879

78627880
#: ../../howto/logging-cookbook.rst:4112
78637881
msgid ""
@@ -7878,10 +7896,26 @@ msgid ""
78787896
" logger.debug('Another single line')\n"
78797897
" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled again')"
78807898
msgstr ""
7899+
"import logging\n"
7900+
"\n"
7901+
"from mymixins import MultilineMixin\n"
7902+
"\n"
7903+
"logger = logging.getLogger(__name__)\n"
7904+
"\n"
7905+
"class StreamHandler(MultilineMixin, logging.StreamHandler):\n"
7906+
" pass\n"
7907+
"\n"
7908+
"if __name__ == '__main__':\n"
7909+
" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s',\n"
7910+
" handlers = [StreamHandler()])\n"
7911+
" logger.debug('Single line')\n"
7912+
" logger.debug('Multiple lines:\\nfool me once ...')\n"
7913+
" logger.debug('Another single line')\n"
7914+
" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled again')"
78817915

78827916
#: ../../howto/logging-cookbook.rst:4131
78837917
msgid "The script, when run, prints something like:"
7884-
msgstr ""
7918+
msgstr "在运行时,这个脚本将打印如下内容:"
78857919

78867920
#: ../../howto/logging-cookbook.rst:4133
78877921
msgid ""
@@ -7893,6 +7927,13 @@ msgid ""
78937927
"2025-07-02 13:54:47,234 DEBUG fool me ...\n"
78947928
"2025-07-02 13:54:47,234 DEBUG can't get fooled again"
78957929
msgstr ""
7930+
"2025-07-02 13:54:47,234 DEBUG Single line\n"
7931+
"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n"
7932+
"2025-07-02 13:54:47,234 DEBUG fool me once ...\n"
7933+
"2025-07-02 13:54:47,234 DEBUG Another single line\n"
7934+
"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n"
7935+
"2025-07-02 13:54:47,234 DEBUG fool me ...\n"
7936+
"2025-07-02 13:54:47,234 DEBUG can't get fooled again"
78967937

78977938
#: ../../howto/logging-cookbook.rst:4143
78987939
msgid ""

0 commit comments

Comments
 (0)