Answer the question
In order to leave comments, you need to log in
Why doesn't translation work in Django templates?
Python Django 3.0 project.
I want to translate the text both in the code and in the template.
There are all the necessary presets:
1.
2.USE_I18N = True
LANGUAGES = [('uk', 'Ukrainian'), ('en', 'English')]
LANGUAGE_CODE = 'uk'
'OPTIONS': {'context_processors': ['django.core.context_processors.i18n', ...]
MIDDLEWARE = ['django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware', ...]
INSTALLED_APPS = [..., 'master', 'administrator']
LOCALE_PATHS = [
os.path.join(PROJECT_ROOT, 'apps', 'master', 'locale'),
os.path.join(PROJECT_ROOT, 'apps', 'administrator', 'locale'),
]
path('i18n/', include('django.conf.urls.i18n')),
django-admin makemessages --locale=uk --extension=html,txt,py
django.po
does not contain any lines from the templates, and when starting the server and entering the page with the translation, it throws an error:Invalid block tag on line 32: 'translate', expected 'endblock'. Did you forget to register or load this tag?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question