@@ -1070,6 +1070,8 @@ msgid ""
10701070"expression used to parse template strings. To do this, you can override "
10711071"these class attributes:"
10721072msgstr ""
1073+ "进阶用法:你可以派生 :class:`Template` 的子类来自定义占位符语法、分隔符,或用于解析模板字符串的整个正则表达式。 "
1074+ "为此目的,你可以重载这些类属性:"
10731075
10741076#: ../../library/string.rst:778
10751077msgid ""
@@ -1080,6 +1082,9 @@ msgid ""
10801082"change the delimiter after class creation (i.e. a different delimiter must "
10811083"be set in the subclass's class namespace)."
10821084msgstr ""
1085+ "*delimiter* -- 这是用来表示占位符的起始的分隔符的字符串字面值。 默认值为 ``$``。 请注意此参数 *不能* "
1086+ "为正则表达式,因为其实现将在必要时对此字符串调用 :meth:`re.escape`。 "
1087+ "还要注意你不能在创建类之后改变此分隔符(例如在子类的类命名空间中必须设置不同的分隔符)。"
10831088
10841089#: ../../library/string.rst:785
10851090msgid ""
@@ -1088,18 +1093,23 @@ msgid ""
10881093"``(?a:[_a-z][_a-z0-9]*)``. If this is given and *braceidpattern* is "
10891094"``None`` this pattern will also apply to braced placeholders."
10901095msgstr ""
1096+ "*idpattern* -- 这是用来描述不带花括号的占位符的模式的正则表达式。 默认值为正则表达式 "
1097+ "``(?a:[_a-z][_a-z0-9]*)``。 如果给出了此属性并且 *braceidpattern* 为 ``None`` "
1098+ "则此模式也将作用于带花括号的占位符。"
10911099
10921100#: ../../library/string.rst:792
10931101msgid ""
10941102"Since default *flags* is ``re.IGNORECASE``, pattern ``[a-z]`` can match with"
10951103" some non-ASCII characters. That's why we use the local ``a`` flag here."
10961104msgstr ""
1105+ "由于默认的 *flags* 为 ``re.IGNORECASE``,模式 ``[a-z]`` 可以匹配某些非 ASCII 字符。 "
1106+ "因此我们在这里使用了局部旗标 ``a``。"
10971107
10981108#: ../../library/string.rst:796
10991109msgid ""
11001110"*braceidpattern* can be used to define separate patterns used inside and "
11011111"outside the braces."
1102- msgstr ""
1112+ msgstr "*braceidpattern* 可被用来定义对花括号内部和外部进行区分的模式。 "
11031113
11041114#: ../../library/string.rst:800
11051115msgid ""
@@ -1109,6 +1119,8 @@ msgid ""
11091119"If given, this allows you to define different patterns for braced and "
11101120"unbraced placeholders."
11111121msgstr ""
1122+ "*braceidpattern* -- 此属性类似于 *idpattern* 但是用来描述带花括号的占位符的模式。 默认值 ``None`` "
1123+ "意味着回退到 *idpattern* (即在花括号内部和外部使用相同的模式)。 如果给出此属性,这将允许你为带花括号和不带花括号的占位符定义不同的模式。"
11121124
11131125#: ../../library/string.rst:808
11141126msgid ""
@@ -1118,6 +1130,8 @@ msgid ""
11181130"to the flags, so custom *idpattern*\\ s must follow conventions for verbose "
11191131"regular expressions."
11201132msgstr ""
1133+ "*flags* -- 将在编译用于识别替换内容的正则表达式被应用的正则表达式旗标。 默认值为 ``re.IGNORECASE``。 请注意 "
1134+ "``re.VERBOSE`` 总是会被加为旗标,因此自定义的 *idpattern* 必须遵循详细正则表达式的约定。"
11211135
11221136#: ../../library/string.rst:816
11231137msgid ""
@@ -1127,6 +1141,8 @@ msgid ""
11271141"capturing groups correspond to the rules given above, along with the invalid"
11281142" placeholder rule:"
11291143msgstr ""
1144+ "作为另一种选项,你可以通过重载类属性 *pattern* 来提供整个正则表达式模式。 如果你这样做,该值必须为一个具有四个命名捕获组的正则表达式对象。 "
1145+ "这些捕获组对应于上面已经给出的规则,以及无效占位符的规则:"
11301146
11311147#: ../../library/string.rst:822
11321148msgid ""
0 commit comments