8

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

Termininja
  • 6,620
  • 12
  • 48
  • 49
n1_
  • 4,227
  • 4
  • 34
  • 35

1 Answers1

11

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.

catavaran
  • 44,703
  • 8
  • 98
  • 85
  • And if I remove the symlink and re-make messages again, will they disappear from the .po file? – n1_ Jan 17 '15 at 20:32
  • 1
    Yes, they will disappear. To prevent this move translation from `locale` dir to some other directory and set `LOCALE_PATHS` setting. Next time you run `makemessages` this translation will be untouched. – catavaran Jan 17 '15 at 22:55