我的设置文件是:
我为kk-ar,kk-kz,kk-latn语言创建要翻译的消息文件。这些语言代码在不同的书写系统中是同一种语言的。但这在django设置中不支持,所以我将其添加到设置中,但是当我运行服务器django时不显示我的翻译。在
这是为什么?在
由“django admin startproject”使用django 1.8.5和Python生成 3.4条
gettext = lambda s: s
BASE_DIR = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'task.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
],
},
},
]
WSGI_APPLICATION = 'task.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGES = (
('kk-kz', gettext('Kazakh')),
('kk-latn', gettext('Kazakh Latin')),
('kk-ar', gettext('Kazakh Arab')),
)
EXTRA_LANG_INFO = {
'kk-ar': {
'bidi': True, # right-to-left
'code': 'kk-ar',
'name': 'Kazakh Arab',
# unicode codepoints here
'name_local': u'\u0642\u0627\u0632\u0627\u0642\u0634\u0627',
},
'kk-latn': {
'bidi': False, # right-to-left
'code': 'kk-latn',
'name': 'Kazakh Latin',
# unicode codepoints here
'name_local': u'Qazaq',
},
}
# Add custom languages not provided by Django
laninfo = django.conf.locale.LANG_INFO
laninfo.update(EXTRA_LANG_INFO)
django.conf.locale.LANG_INFO = laninfo
# Languages using BiDi (right-to-left) layout
LANGUAGES_BIDI = global_settings.LANGUAGES_BIDI + ("kk-ar",)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
LANGUAGE_CODE = 'kk-ar'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = False
USE_TZ = True
还有我的网址.py是这样的: 从django.conf.url导入include,url
^{pr2}$
在Django中实现翻译有三个步骤:
这里的本地化指南:https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-to-create-language-files有一个很好的过程分步指南。在
相关问题 更多 >
编程相关推荐