from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
label=ugettext_lazy(u"日期")
# ......
opt = {"data": [], "name": _(u'销售额({first},{last})')
创建locale目录,在locale目录中创建语言目录,为每一个语言目录创建LC_MESSAGES目录,结构和下面的结构类似
locale
├── en
│ └── LC_MESSAGES
└── zh_hans
└── LC_MESSAGES
django-admin.py compilemessages --all
生成po文件django-admin.py compilemessages
生成mo文件配置如下
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'zh-cn'
TIME_ZONE = 'Asia/Shanghai'
LANGUAGES = (
('en', ugettext_lazy(u"英文")),
('zh-cn',ugettext_lazy(u"中文")),
)