[Django]-How to translate whole html page in another language in Django?

3👍

1) Add a LOCALE_PATHS var in your settings.py. For example:


USE_I18N = True

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)

LANGUAGES = (
    ('en', _('English')),
    ('fr', _('French')),
)

2) change your main urls.py

from django.conf.urls.i18n import i18n_patterns 
    urlpatterns = i18n_patterns('',

      ...
    )

3) in your templates add

{% load i18n %}

and {% trans 'Lorem ipsum ...' %}

4) now you can run

python manage.py makemessages

open ‘locale/fr/django.po’ and translate all sentences you need.

Don’t forget to
python manage.py compilemessages

Leave a comment