从Django中的第三方应用收集消息 [英] Collecting messages from 3rd party apps in Django
问题描述
如何从位于virtualenv目录中的第3方库生成消息(manage.py makemessages)?
How can I generate messages (manage.py makemessages) from 3rd party library which is located in virtualenv directory?
我尝试只是将消息添加到.po文件中,但是每次我运行makemessages命令时,我的翻译都消失了.
I tried simply add the messages to the .po file, but everytime I run makemessages command my translation vanishes.
非常感谢
推荐答案
manage.py makemessages
仅查找当前目录下的目录.因此,您必须创建从第三方应用程序到项目目录的符号链接:
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
请注意-s
选项.它强制makemessages
遵循符号链接.
Note the -s
option. It forces makemessages
to follow symlinks.
另一个警告是,如果app
已经本地化,则将在app/locale/cz
目录而不是locale
下创建.po
文件.
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
.
这篇关于从Django中的第三方应用收集消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!