问题
How can I generate messages (manage.py makemessages) from 3rd party library which is located in virtualenv directory?
I tried simply add the messages to the .po file, but everytime I run makemessages command my translation vanishes.
Many thanks
回答1:
manage.py makemessages
looks only for directories under the current dir. So you have to create symlink from 3rd party app to your project's directory:
ln -s ~/.virtualenvs/myvenv/local/lib/python2.7/site-packages/app app
mkdir locale
python manage.py makemessages -l cz -s
Note the -s
option. It forces makemessages
to follow symlinks.
The other caveat is if the app
is already localized then .po
file will be created under app/locale/cz
directory instead of your locale
.
来源:https://stackoverflow.com/questions/27988805/collecting-messages-from-3rd-party-apps-in-django