Django 项目中需要国际化的 JavaScript 文件应该放在哪里?
目前,所有 JavaScript 文件均由顶级项目目录中的 static/media 目录提供。运行 makemassages -d djangojs 时,它也会在顶层生成 locale 目录。
但是,javascript_catalog 只会考虑在应用程序中创建的区域设置目录,即在 INSTALLED_APPS 设置中列出。
让 makemessages 和 javascript_catalog 协同工作以实际使用 JavaScript i18n 功能的正确方法是什么?
将 js 文件移到应用程序目录中并拥有多个静态目录(恕我直言,我目前正在通过 nginx 提供静态文件,这会扰乱conf)?
我正在使用Django 1.1
Currently all JavaScript files are served from our static/media directory in the top level project directory. When running makemassages -d djangojs
it will generate the locale directory in the top level too.
However, javascript_catalog will only consider locale directories created in apps, i.e. listed in the INSTALLED_APPS setting.
What's the proper way of having makemessages and javascript_catalog work in tandem to actually use the JavaScript i18n functionality?
Move the js-files into the app dir and have multiple static directories (not appealing imho, I'm currently serving static files through nginx and this, among other things, will clutter the conf)?
I'm using Django 1.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几周前,我在每个项目目录中创建到媒体文件的符号链接时解决了这个问题,它对我来说工作得很好:-)
配置地狱,但“某种”DRY
i worked around this some weeks ago in creating symlinks in each project dir to the media files and it worked fine for me :-)
config hell but "some sort of" DRY
最干净的解决方案是将区域设置(例如,位于应用程序上方的顶级项目目录中)添加到设置文件中的 LOCALE_PATH 中:
例如
The cleanest solution is to just add the locale (eg in your top-level project directory that sits above the apps) to LOCALE_PATH in your settings file:
eg