Django国际化

本文在django 1.7验证过 1 在项目settings.py中添加两行(+表示添加行): + LOCALE_PATHS = (BASE_DIR+ “/locale”,) MIDDLEWARE_CLASSES = ( ‘django.middleware.common.CommonMiddleware’, ‘django.contrib.sessions.middleware.SessionMiddleware’, + ‘django.middleware.locale.LocaleMiddleware’, ‘django.middleware.csrf.CsrfViewMiddleware’, ) 2 在views.py中标记要翻译的字符串,格式为{% trans ‘字符串’%} 如 {% load i18n %} {% trans ‘User’ %} 3 建立locale目录结构 $ mkdir … Continue reading