Answer the question
In order to leave comments, you need to log in
How to do internationalization in Django templates?
I want to make a Django site available in a second language.
I register in settings.py
MIDDLEWARE = [
...
'django.middleware.locale.LocaleMiddleware',
]
LANGUAGE_CODE = 'en-us'
LANGUAGES = (
('en', 'English'),
('nl', 'Dutch'),
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
from django.utils.translation import ugettext as _
...
context = {
"variable": _("value")
...
}
{% load i18n %}
....
{% trans "My text for translation" %}
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