Avatar ·

How to change the language for the user on a Django website?

📁 Advanced Python Topics, django

I have the ability to switch between Russian, English, and Ukrainian versions on the site. I wrapped the lines in templates that need to be translated with the {% trans %} tag, translated the lines in the code, and compiled the translation. I also installed locale_url.

LANGUAGE_CODE = 'ru-RU'
LANGUAGES = (
    ('en', 'English'),
    ('ru', 'Russian'),
    ('uk', 'Ukrainian'),
)
TIME_ZONE = 'Europe/Kiev'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (
    'locale',
)