'Django uses untranslated strings instead of translations

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 1:[1]

I'm an idiot. It is of course supposed to be LOCALE_PATHS, instead of LOCAL_PATHS.

Solution 2:[2]

haha, yes it's really easy to miss something when you do the localization manually. I can advise trying platforms for localization and automate most processes. Here is a short article about the localization of Django with Crowdin. You can test the platform for free :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 loreson
Solution 2 Diana Voroniak