在Jinja模板中,语法_()
和_l()
有效。但是当我使用Enum
时,该值未被翻译。我该怎么办?
from enum import Enum
from flask_babel import _
from flask_babel import lazy_gettext as _l
class DFNError(Enum):
def __new__(cls, *args, **kwds):
value = len(cls.__members__) + 1
obj = object.__new__(cls)
obj._value_ = value
return obj
def __init__(self, code, message, developer_message):
self.code = code
self.message = message
self.developer_message = developer_message
UNKNOWN_ERROR_CODE = (name + str(0), _l('Internal Server Error'), _('d'))
答案 0 :(得分:0)
由于某种原因,它现在有效。我只是重新启动应用程序......