从Django中的第三方应用收集消息 [英] Collecting messages from 3rd party apps in Django

查看:69
本文介绍了从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆