Multilanguage & Translation
Adding Required Settings
The infrastructure required to add multilanguage support has already been implemented in Project Zero. Languages to be used and default language should be added to the settings.
omnife_base/settings.py
LANGUAGE_CODE = 'tr'
LANGUAGES = [
('tr', 'Türkçe'),
('en-us', 'English')
]
Creating Language Files
In order to create the relevant language files, a "locale" directory must be created in the root directory of the project. In addition, the corresponding directory for each of the language codes in settings.py must be created under "locale". (Example: locale/en, locale/fr etc.)
After the directories are created, the following commands should be executed to create editable language files (.po).
For translations in Django templates:
python manage.py makemessages --ignore venv
For translations in Javascript:
python manage.py makemessages -d djangojs --ignore node_modules
After executing these commands, .po files will be created under the relevant directory for each language. (Example: locale/en/LC_MESSAGES/django.po, locale/en/LC_MESSAGES/djangojs.po).
After the necessary translations are made in these files, the .po files must be compiled with the following command.
python manage.py compilemessages -l en
Changing Language
To change the language, the language code must be passed to the setlang url with the language parameter. Example:
POST
example.com/setlang
language: en-us