Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法在django all auth中使用i18n_Python_Django_Django Allauth_Django I18n - Fatal编程技术网

Python 无法在django all auth中使用i18n

Python 无法在django all auth中使用i18n,python,django,django-allauth,django-i18n,Python,Django,Django Allauth,Django I18n,Django allauth模块附带i18n'd模板和视图,我希望使用这些模板和视图以法语显示我的页面。但是,只有使用ux()呈现的文本才能正确翻译 在模板内部,{%trans%}和{%blocktrans%}不输出翻译文本,但{%get\u current\u language%}返回正确的标记 设置示例: USE_I18N = True django.core.context_processors.i18n TEMPLATES = [{ 'BACKEND':'django.templ

Django allauth模块附带i18n'd模板和视图,我希望使用这些模板和视图以法语显示我的页面。但是,只有使用ux()呈现的文本才能正确翻译

在模板内部,
{%trans%}
{%blocktrans%}
不输出翻译文本,但
{%get\u current\u language%}
返回正确的标记

设置示例:

USE_I18N = True
django.core.context_processors.i18n
TEMPLATES = [{
    'BACKEND':'django.template.backends.django.DjangoTemplates',
    'DIRS': ['mydir/templates'],                
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.template.context_processors.i18n',
            'django.contrib.messages.context_processors.messages',
            ],
        },
    },
},]
LOCALE_PATHS = ['/abs/path/to/locale',]
MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    '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',
]
LANGUAGE_CODE = 'fr'
LANGUAGES = ('fr',)
模板:

{% extends "account/base.html" %}
{% load i18n %}
...
{% trans "Signup" %}
...
abs/path/to/locale/fr/LC_MESSAGES/django.po,第666-667行:

msgid "Signup"
msgstr "Inscription"
我不知道该去哪里看,我尝试重新启动服务器并清空缓存,但没有成功。任何帮助都将不胜感激


编辑:通过运行
python manage.py compilemessages
解决问题。自我提示:RTFM

仔细检查是否编译了带有翻译的文件。

是否编译了带有翻译的文件?不,我的错!我错过了这一步。现在效果很好。你可以回答并被接受:)@ArthurHavlicek我与你有相同的设置,但仍以英语显示。我必须将哪个路径设置为区域设置\路径?。。。。