Reputation: 4651
I have my translation strings only in templates (stored in the project_dir/Templates), I tried running the $ django-admin.py createmessages -l ru
both in the project root directory and in the app directories that use templates with trans. strings. It created folders locale/ru/LC_MESSAGES but the folders were empty. I tried to add the django.po files manually (with the syntax mentioned in the l10n docs). And ran the createmessages -a and compilemessages commands. It created the .mo files, but the translations didn't appear in the browser.
Upvotes: 12
Views: 23503
Reputation: 1
To fix empty po files:
locale
directory in your templates
directory and add its path to the LOCALE_PATHS
list. (Optional, but helpful to make sure that the template directory is included in step 4)django-admin makemessages -l ru
Upvotes: 0
Reputation: 692
For newer versions of Django (e.g. 3.2):
in the root directory create folder "locale"
run command django-admin makemessages -l ru
update your language files (located in the locale folder)
run django-admin compilemessages
Configure the LOCALE_PATHS in settings.py, otherwise you won't see the translations:
LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]
LANGUAGE_CODE = 'ru'
Upvotes: 1
Reputation: 11521
did you try :
python manage.py makemessages -a
from project root and app ?
this should create a .po that you have to edit. be sure to remove 'fuzzy' stuff everywhere.
then :
python manage.py compilemessages
You need to restart the server
Upvotes: 24