1
アラビア語をサポートするために私のdjangoプロジェクトを設定しようとしていますが、まだ何も正しくできません。Django translations RTL langauge
私のsettings.py:
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',
],
},
},
]
USE_I18N = True
LANGUAGES = (
('ar', _('Arabic')),
('en', _('English')),
)
LANGUAGE_CODE = 'en-us'
LOCAL_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
私のindex.html
{% trans "Hello and welcome" %}
<p>{% blocktrans %}
hello dear friends, i would be very happy if you
can help!!
{% endblocktrans %}</p>
</br>
{{ request.LANGUAGE_CODE }}
urls.py
urlpatterns += i18n_patterns(
url(r'^admin/', admin.site.urls),
url(r'^$', views.home, name='home'),
)
その後、私はコマンドを使用した.poファイルを作成するには:
python manage.py mak emessages -l「AR」
と私はの.poファイルを取得した後、私は、 は、翻訳された文字列コンパイルするには、次のコマンドを使用し「msgStrを」に私の翻訳を追加しました:
のpython manage.pyのcompilemassagesを
私はログインして、言語コードを 'ar'に変更しました。(127.0.0.1:8000/ar)、まだ英語の文字列を取得しています。私は間違っているのですか? 感謝とにかくみんな、私が書いたLOCAL_PATHS .. おかげ