Django makemessages 用于站点包中的应用程序
如何使用 Django 的内置 收集项目文件夹之外的翻译字符串makemessages
设施?管理命令 makemessages 非常方便,我想将它用于位于站点包中的应用程序。
How can I collect translation strings outside of my project folder using Django's built-in makemessages
facility? The management command makemessages
is very convenient and I'd like to use it for applications located in site-packages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(1) 激活安装Django的虚拟环境。
(2) 转到要为其生成消息的应用程序的目录:
(3) 确保它具有“locale”目录。如果没有 - 制作一个。
(4) 从您的应用程序目录运行以下命令:
荷兰语示例:
俄语示例:
(1) Activate a virtual environment where Django is installed.
(2) Go directory of the app for which you want the messages to be generated:
(3) Make sure it has "locale" directory. If not - make one.
(4) From your app directory run the following command:
Example for Dutch:
Example for Russian:
除了 makemessages 之外,我发现 PyBabel 非常有用。这是对 Django 本身的绑定: http://babel.edgewall.org/wiki/BabelDjango
Other than makemessages I found PyBabel very useful. Here is a bind to Django itself: http://babel.edgewall.org/wiki/BabelDjango
有符号链接(ln -s)但不是很方便。通常,如果应用程序位于 PYTHONPATH 上,那么翻译文件夹不应该被 makemessages 捕获吗?
With symbol links (ln -s) but it's not very convenient. Usually if the apps are on PYTHONPATH shouldn't the translations folders be catched by makemessages ?