@@ -1839,12 +1839,16 @@ msgid ""
1839
1839
"codes (such as ``%i`` or ``%h`` for IntEnum) treat the enum member as its "
1840
1840
"mixed-in type."
1841
1841
msgstr ""
1842
+ "% 形式的格式化: ``%s`` 和 ``%r`` 会分别调用 :class:`Enum` 类的 :meth:`~object.__str__` 和 "
1843
+ ":meth:`~object.__repr__`;其他代码(如 ``%i`` 或 ``%h`` 用于 IntEnum)会将枚举成员当作对应的混入类型。"
1842
1844
1843
1845
#: ../../howto/enum.rst:917
1844
1846
msgid ""
1845
1847
":ref:`Formatted string literals <f-strings>`, :meth:`str.format`, and "
1846
1848
":func:`format` will use the enum's :meth:`~object.__str__` method."
1847
1849
msgstr ""
1850
+ ":ref:`格式化字符串字面值 <f-strings>`, :meth:`str.format` 和 :func:`format` 将使用枚举的 "
1851
+ ":meth:`~object.__str__` 方法。"
1848
1852
1849
1853
#: ../../howto/enum.rst:922
1850
1854
msgid ""
@@ -1853,10 +1857,12 @@ msgid ""
1853
1857
":meth:`~object.__str__` method has been reset to their data types' "
1854
1858
":meth:`~object.__str__` method."
1855
1859
msgstr ""
1860
+ "由于 :class:`IntEnum`, :class:`IntFlag` 和 :class:`StrEnum` 被设计为现有常量的无缝替换,它们的 "
1861
+ ":meth:`~object.__str__` 方法已被重置为其数据类型的 :meth:`~object.__str__` 方法。"
1856
1862
1857
1863
#: ../../howto/enum.rst:930
1858
1864
msgid "When to use :meth:`~object.__new__` vs. :meth:`~object.__init__`"
1859
- msgstr ""
1865
+ msgstr "何时应使用 :meth:`~object.__new__` 或 :meth:`~object.__init__` "
1860
1866
1861
1867
#: ../../howto/enum.rst:932
1862
1868
msgid ""
@@ -1865,6 +1871,9 @@ msgid ""
1865
1871
" either :meth:`~object.__new__` or :meth:`~object.__init__`, with "
1866
1872
":meth:`~object.__init__` being preferred."
1867
1873
msgstr ""
1874
+ "当你想要定制 :class:`Enum` 成员的实际值时你必须使用 :meth:`~object.__new__`。 任何其他修改则可使用 "
1875
+ ":meth:`~object.__new__` 或 :meth:`~object.__init__`,其中 "
1876
+ ":meth:`~object.__init__` 更为推荐。"
1868
1877
1869
1878
#: ../../howto/enum.rst:936
1870
1879
msgid ""
@@ -2033,6 +2042,8 @@ msgid ""
2033
2042
"attribute can be provided. It will be checked against the actual order of "
2034
2043
"the enumeration and raise an error if the two do not match::"
2035
2044
msgstr ""
2045
+ "用于帮助 Python 2 / Python 3 代码保持同步以便提供 :attr:`~Enum._order_` 属性。 "
2046
+ "它将与枚举的实际顺序进行检查并会在两者不匹配时引发错误::"
2036
2047
2037
2048
#: ../../howto/enum.rst:1017
2038
2049
msgid ""
@@ -2437,6 +2448,12 @@ msgid ""
2437
2448
"correct (such as :meth:`~object.__new__`, :meth:`~object.__getnewargs__`, "
2438
2449
":meth:`~object.__str__` and :meth:`~object.__repr__`)."
2439
2450
msgstr ""
2451
+ ":class:`EnumType` 元类负责提供 :meth:`~object.__contains__`, "
2452
+ ":meth:`~object.__dir__`, :meth:`~object.__iter__` 及其他方法来允许人们在 :class:`Enum` "
2453
+ "类上做一些在常规类上会失败的事情,比如 ``list(Color)`` 或 ``some_enum_var in Color``。 "
2454
+ ":class:`EnumType` 负责确保最终的 :class:`Enum` 类上的各种其他方法是正确的(比如 "
2455
+ ":meth:`~object.__new__`, :meth:`~object.__getnewargs__`, "
2456
+ ":meth:`~object.__str__` 和 :meth:`~object.__repr__` 等)。"
2440
2457
2441
2458
#: ../../howto/enum.rst:1228
2442
2459
msgid "Flag Classes"
@@ -2465,6 +2482,8 @@ msgid ""
2465
2482
"that no new ones are ever instantiated by returning only the existing member"
2466
2483
" instances."
2467
2484
msgstr ""
2485
+ "有关枚举成员的最有趣的一点在于它们都是单例。 :class:`EnumType` 会在创建枚举类本身时全部创建它们,然后放置一个自定义的 "
2486
+ ":meth:`~object.__new__` 以通过只返回现有的成员实例来确保没有新的成员被实例化。"
2468
2487
2469
2488
#: ../../howto/enum.rst:1244
2470
2489
msgid "Flag Members"
@@ -2976,6 +2995,7 @@ msgid ""
2976
2995
"If :meth:`~object.__new__` or :meth:`~object.__init__` is defined, the value"
2977
2996
" of the enum member will be passed to those methods::"
2978
2997
msgstr ""
2998
+ "如果定义了 :meth:`~object.__new__` 或 :meth:`~object.__init__`,则枚举成员的值将被传给这些方法::"
2979
2999
2980
3000
#: ../../howto/enum.rst:1511
2981
3001
msgid ""
@@ -3031,7 +3051,7 @@ msgstr "TimePeriod"
3031
3051
3032
3052
#: ../../howto/enum.rst:1539
3033
3053
msgid "An example to show the :attr:`~Enum._ignore_` attribute in use::"
3034
- msgstr ""
3054
+ msgstr "一个演示如何使用 :attr:`~Enum._ignore_` 属性的例子:: "
3035
3055
3036
3056
#: ../../howto/enum.rst:1541
3037
3057
msgid ""
0 commit comments