@@ -652,6 +652,10 @@ msgid ""
652652"object. This is signalled by an absolute import path to the factory being "
653653"made available under the special key ``'()'``. Here's a concrete example:"
654654msgstr ""
655+ "要配置的对象是由字典描述的,其中包含它们的配置详情。 "
656+ "在某些地方,日志记录系统将能够从上下文中推断出如何实例化一个对象,但是当要实例化一个用户自定义对象时,系统将不知道要如何做。 "
657+ "为了提供用户自定义对象实例化的完全灵活性,用户需要提供一个‘工厂’函数 —— 即在调用时传入配置字典并返回实例化对象的可调用对象。 这是用一个通过特殊键"
658+ " ``'()'`` 来访问的工厂函数的绝对导入路径来标示的。 下面是一个实际的例子:"
655659
656660#: ../../library/logging.config.rst:446
657661msgid ""
@@ -663,6 +667,11 @@ msgid ""
663667" in Python source form, the ``brief`` and ``default`` formatters have "
664668"configuration sub-dictionaries::"
665669msgstr ""
670+ "上面的 YAML 代码片段定义了三个格式化器。 第一个的 ID 为 ``brief``,是带有特殊格式字符串的标准 "
671+ ":class:`logging.Formatter` 实例。 第二个的 ID 为 "
672+ "``default``,具有更长的格式同时还显式地定义了时间格式,并将最终实例化一个带有这两个格式字符串的 "
673+ ":class:`logging.Formatter`。 以 Python 源代码形式显示的 ``brief`` 和 ``default`` "
674+ "格式化器具有下列配置子字典::"
666675
667676#: ../../library/logging.config.rst:458
668677msgid "and::"
@@ -676,6 +685,8 @@ msgid ""
676685"configuration sub-dictionary for the third formatter, with id ``custom``, "
677686"is::"
678687msgstr ""
688+ "并且由于这些字典不包含特殊键 ``'()'``,实例化方式是从上下文中推断出来的:结果会创建标准的 :class:`logging.Formatter`"
689+ " 实例。 第三个格式器的 ID 为 ``custom``,对应配置子字典为::"
679690
680691#: ../../library/logging.config.rst:478
681692msgid ""
@@ -688,6 +699,9 @@ msgid ""
688699"arguments. In the above example, the formatter with id ``custom`` will be "
689700"assumed to be returned by the call::"
690701msgstr ""
702+ "并且它包含特殊键 ``'()'``,这意味着需要用户自定义实例化方式。 在此情况下,将使用指定的工厂可调用对象。 "
703+ "如果它本身就是一个可调用对象则将被直接使用 —— 否则如果你指定了一个字符串(如这个例子所示)则将使用正常的导入机制来定位实例的可调用对象。 "
704+ "调用该可调用对象将传入配置子字典中 **剩余的** 条目作为关键字参数。 在上面的例子中,调用将预期返回 ID 为 ``custom`` 的格式化器::"
691705
692706#: ../../library/logging.config.rst:490
693707msgid ""
0 commit comments