Issue
I have a small Django application, which I tried to localize. In the urls.py I have
urlpatterns += i18n_patterns(
path('add_request/',AddRequest.as_view(),name='add_request'),
path('add_offer/', AddOffer.as_view(), name='add_offer'),
)
In the settings.py I have
MIDDLEWARE = [
'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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
and
LANGUAGE_CODE = 'de'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
LOCAL_PATHS = (
os.path.join(BASE_DIR, 'locale/'),
)
USE_TZ = True
LANGUAGES= [
('en', 'English'),
('de', 'German')
]
I have marked strings for translation in my models.py (verbose_name), the forms.py (label) and in a template.
I extracted po files via
django-admin makemessages -l en
django-admin makemessages -l de
Translated them and ran
django-admin compilemessages
Now I have the prefixes de/ and en/ for my urls. The Locale seems to be set correctly, as date input fields change to the right date format, but the translations are not used.
Solution
I'm an idiot. It is of course supposed to be LOCALE_PATHS, instead of LOCAL_PATHS.
Answered By - loreson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.