This post is deprecated. Please follow the official documentation.
When comes to using multiple languages in one single site, Django is very handy. You can use .po file to do your translation for you.
Process is very simple: First create .po file. To make .po file I would suggest to use poedit or Rosetta. Here is another option that is using django’s very own Localisation. Second create a folder name locale within tour django project and add the language named (for example: ru__RU for Russian language) within locale. Within ru___RU folder, create another folder named ‘LC__MESSAGES’. There save the .po file you have created. Save the .po file in name django.po. File Map:
Project ├── locale │ ├── ru_RU │ │ └── LC_MESSAGES │ │ └── django.po │ └── en_GB │ └── LC_MESSAGES │ └── django.po
Now run this command:
django-admin.py compilemessages to generate .mo file(django.mo). Third comes to final touch. in Language settings in your settings.py add ru_RU like this:
LANGUAGES = ( ('en-us', 'English'), ('ru_RU', 'Russian'), ) LANGUAGE_CODE = 'en-us' 'ru_RU'
Add locale path :
LOCALE_PATHS = ( os.path.join(PROJECT_PATH, '../locale'), )
and finally add a middleware in in MIDDLEWARE_CLASSES or MIDDLEWARES.
That should the trick.
Last updated: Feb 25, 2021