2016-04-03 5 views
0

Django allauthモジュールには、私のページをフランス語で表示するために使用したいi18nのテンプレートとビューが付属しています。ただし、_()でレンダリングされたテキストのみが正しく翻訳されます。django all-authでi18nを使用できません

テンプレート内で{% trans %}{% blocktrans %}は翻訳されたテキストを出力しませんが、{% get_current_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 /パス/に/ロケール/ FR/LC_MESSAGES/django.po、ライン666から667:

msgid "Signup" 
msgstr "Inscription" 

私はどこから見ているのか分からず、サーバーと空のキャッシュを再起動しようとしましたが、成功しませんでした。どんな助けでも大歓迎です。

EDIT:python manage.py compilemessagesを実行して問題を解決しました。自己への注意:RTFM

+1

翻訳ファイルをコンパイルしましたか? – pkacprzak

+1

いいえ、私の悪い!私はこのステップを逃した。今は完璧に動作します。あなたは答えて受け入れることができます:) –

+0

@ArthurHavlicek私はあなたと同じ設定が、まだ英語で表示されます。どのパスをLOCALE_PATHSとして設定する必要がありますか?.... – user3595632

答えて

1

翻訳を含むファイルをコンパイルしたかどうかを再度確認します。

関連する問題